1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-16 13:35:22 +02:00

Bug 290173: Migrate the Connect command to the asynchronous platform API

Change-Id: Id5025b8936ad88f42e6fa7e07094b04923d0f7a7
Reviewed-on: https://git.eclipse.org/r/6816
Reviewed-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
IP-Clean: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
Tested-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
This commit is contained in:
Marc Khouzam 2012-07-24 13:13:32 -04:00
parent 6500f4755f
commit 03af322a6f
17 changed files with 191 additions and 192 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true
Bundle-Version: 7.2.0.qualifier
Bundle-Version: 7.3.0.qualifier
Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<version>7.2.0-SNAPSHOT</version>
<version>7.3.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.debug.core</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

View file

@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.commands.IDebugCommandHandler;
/**
* Handler interface to for the connect command
*
* @since 7.3
*/
public interface IConnectHandler extends IDebugCommandHandler {
}

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.debug.ui; singleton:=true
Bundle-Version: 7.2.0.qualifier
Bundle-Version: 7.3.0.qualifier
Bundle-Activator: org.eclipse.cdt.debug.ui.CDebugUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin

View file

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 189 B

View file

@ -10,6 +10,7 @@
# IBM Corporation
# Patrick Chuong (Texas Instruments) - Pin and Clone Supports (Bug 331781)
# Dobrin Alexiev (Texas Instruments) - initial API and implementation (bug 336876)
# Marc Khouzam (Ericsson) - Added support for connect command (Bug 365601)
###############################################################################
pluginName=C/C++ Development Tools Debugger UI
@ -200,6 +201,12 @@ Uncall.name = Uncall
Uncall.description = Perform Uncall
Uncall.label = Uncall
# Connect command
Connect.name = Connect
Connect.description = Connect to a process
Connect.label = Connect...
Connect.tooltip = Connect to a process
# Debug View layout
DebugViewLayoutActionSet.label = Debug View Layout
DebugViewLayoutCategory.name = Debug View Layout Commands

View file

@ -1990,6 +1990,13 @@
id="org.eclipse.cdt.debug.ui.command.ungroupDebugContexts"
name="%UngroupDebugContexts.name">
</command>
<command
categoryId="org.eclipse.cdt.debug.ui.category.debugViewLayout"
description="%Connect.description"
id="org.eclipse.cdt.debug.ui.command.connect"
name="%Connect.name">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
@ -2052,6 +2059,10 @@
class="org.eclipse.cdt.debug.internal.ui.commands.UngroupDebugContextsCommandHandler"
commandId="org.eclipse.cdt.debug.ui.command.ungroupDebugContexts">
</handler>
<handler
class="org.eclipse.cdt.debug.internal.ui.commands.ConnectCommandHandler"
commandId="org.eclipse.cdt.debug.ui.command.connect">
</handler>
</extension>
<extension
point="org.eclipse.core.expressions.definitions">
@ -2494,6 +2505,27 @@
</command>
</menuContribution>
<!-- Connect contributions to debug view menu, toolbar menu -->
<menuContribution
locationURI="toolbar:org.eclipse.debug.ui.DebugView?before=stepGroup">
<command
commandId="org.eclipse.cdt.debug.ui.command.connect"
icon="icons/obj16/connect.gif"
label="%Connect.label"
style="push"
tooltip="%Connect.tooltip">
</command>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.debug.ui.DebugView?before=emptyLaunchGroup">
<command
commandId="org.eclipse.cdt.debug.ui.command.connect"
icon="icons/obj16/connect.gif"
label="%Connect.label"
style="push"
tooltip="%Connect.tooltip">
</command>
</menuContribution>
</extension>
<!-- Cast to Type / Display as Array -->

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<version>7.2.0-SNAPSHOT</version>
<version>7.3.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.debug.ui</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

View file

@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.commands;
import org.eclipse.cdt.debug.core.model.IConnectHandler;
import org.eclipse.debug.ui.actions.DebugCommandHandler;
/**
* Command handler to trigger a connect operation
*
* @since 7.3
*/
public class ConnectCommandHandler extends DebugCommandHandler {
@Override
protected Class<?> getCommandType() {
return IConnectHandler.class;
}
}

View file

@ -13,9 +13,6 @@
pluginName=GDB DSF Debugger Integration UI
providerName=Eclipse CDT
action.connect.label = Connect...
action.connect.tooltip = Connect to a process
gdbPreferencePage.name = GDB
launchTab.main.name=Main

View file

@ -210,54 +210,6 @@
plugin="org.eclipse.cdt.dsf.gdb.ui">
</statusHandler>
</extension>
<extension
point="org.eclipse.ui.popupMenus">
<viewerContribution
id="org.eclipse.cdt.dsf.gdb.ui.debugview.context"
targetID="org.eclipse.debug.ui.DebugView">
<action
class="org.eclipse.cdt.dsf.gdb.internal.ui.actions.ConnectActionDelegate"
icon="icons/full/obj16/connect.gif"
id="org.eclipse.cdt.dsf.gdb.ui.connect"
label="%action.connect.label"
menubarPath="threadGroup"
tooltip="%action.connect.tooltip">
<enablement>
<pluginState
id="org.eclipse.cdt.dsf.gdb.ui"
value="activated">
</pluginState>
</enablement>
</action>
<visibility>
<pluginState
id="org.eclipse.cdt.dsf.gdb.ui"
value="activated">
</pluginState>
</visibility>
</viewerContribution>
</extension>
<extension
point="org.eclipse.ui.viewActions">
<viewContribution
id="org.eclipse.cdt.dsf.gdb.ui.debugview.toolbar"
targetID="org.eclipse.debug.ui.DebugView">
<action
class="org.eclipse.cdt.dsf.gdb.internal.ui.actions.ConnectActionDelegate"
icon="icons/full/obj16/connect.gif"
id="org.eclipse.cdt.dsf.gdb.ui.connect"
label="%action.connect.label"
toolbarPath="threadGroup"
tooltip="%action.connect.tooltip">
<enablement>
<pluginState
id="org.eclipse.cdt.dsf.gdb.ui"
value="activated">
</pluginState>
</enablement>
</action>
</viewContribution>
</extension>
<extension
point="org.eclipse.core.expressions.definitions">
<definition

View file

@ -18,6 +18,7 @@ import java.util.Map;
import java.util.WeakHashMap;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.IConnectHandler;
import org.eclipse.cdt.debug.core.model.IResumeWithoutSignalHandler;
import org.eclipse.cdt.debug.core.model.IReverseResumeHandler;
import org.eclipse.cdt.debug.core.model.IReverseStepIntoHandler;
@ -41,14 +42,13 @@ import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.DefaultRefreshAllTarget;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.IRefreshAllTarget;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.DefaultDsfModelSelectionPolicyFactory;
import org.eclipse.cdt.dsf.gdb.actions.IConnect;
import org.eclipse.cdt.dsf.gdb.internal.commands.ISelectNextTraceRecordHandler;
import org.eclipse.cdt.dsf.gdb.internal.commands.ISelectPrevTraceRecordHandler;
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.DsfTerminateCommand;
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbConnectCommand;
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbDisconnectCommand;
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbRestartCommand;
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbSteppingModeTarget;
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbConnectCommand;
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbResumeWithoutSignalCommand;
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseResumeCommand;
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseStepIntoCommand;
@ -188,7 +188,7 @@ public class GdbAdapterFactory
session.registerModelAdapter(IResumeWithoutSignalHandler.class, fResumeWithoutSignalCommand);
session.registerModelAdapter(IRestartHandler.class, fRestartCommand);
session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
session.registerModelAdapter(IConnect.class, fConnectCommand);
session.registerModelAdapter(IConnectHandler.class, fConnectCommand);
session.registerModelAdapter(IDisconnectHandler.class, fDisconnectCommand);
session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory);
session.registerModelAdapter(IRefreshAllTarget.class, fRefreshAllTarget);
@ -248,7 +248,7 @@ public class GdbAdapterFactory
session.unregisterModelAdapter(IResumeWithoutSignalHandler.class);
session.unregisterModelAdapter(IRestartHandler.class);
session.unregisterModelAdapter(ITerminateHandler.class);
session.unregisterModelAdapter(IConnect.class);
session.unregisterModelAdapter(IConnectHandler.class);
session.unregisterModelAdapter(IDisconnectHandler.class);
session.unregisterModelAdapter(IModelSelectionPolicyFactory.class);
session.unregisterModelAdapter(IRefreshAllTarget.class);

View file

@ -1,84 +0,0 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Ericsson - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.AbstractVMProviderActionDelegate;
import org.eclipse.cdt.dsf.gdb.actions.IConnect;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IViewPart;
/*
* Action to trigger a prompt for a process to attach to
*/
public class ConnectActionDelegate extends AbstractVMProviderActionDelegate {
/*
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
if (action.isEnabled()) {
// disable the action so it cannot be run again until an event or
// selection change updates the enablement
action.setEnabled(false);
final IConnect connectCommand = getConnectCommand();
if (connectCommand != null) {
connectCommand.connect(null);
}
}
}
@Override
public void init(IViewPart view) {
super.init(view);
updateEnablement();
}
@Override
public void debugContextChanged(DebugContextEvent event) {
super.debugContextChanged(event);
updateEnablement();
}
@Override
public void selectionChanged(IAction action, ISelection selection) {
super.selectionChanged(action, selection);
updateEnablement();
}
private void updateEnablement() {
boolean enabled = false;
final IConnect connectCommand = getConnectCommand();
if (connectCommand != null) {
enabled = connectCommand.canConnect();
}
getAction().setEnabled(enabled);
}
private IConnect getConnectCommand() {
IConnect command = null;
Object element = getViewerInput();
if (element instanceof IDMVMContext) {
IDMVMContext dmc = (IDMVMContext)element;
command = (IConnect)dmc.getAdapter(IConnect.class);
} else if (element instanceof GdbLaunch) {
GdbLaunch launch = (GdbLaunch)element;
command = (IConnect)launch.getSession().getModelAdapter(IConnect.class);
}
return command;
}
}

View file

@ -14,7 +14,7 @@ import org.eclipse.cdt.dsf.concurrent.Immutable;
import org.eclipse.cdt.dsf.gdb.launching.IProcessExtendedInfo;
@Immutable
class ProcessInfo implements IProcessExtendedInfo, Comparable<ProcessInfo> {
public class ProcessInfo implements IProcessExtendedInfo, Comparable<ProcessInfo> {
private final int pid;
private final String name;
private final String[] cores;

View file

@ -9,16 +9,18 @@
* Ericsson - initial API and implementation
* Marc Khouzam (Ericsson) - Add support for multi-attach (Bug 293679)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
package org.eclipse.cdt.dsf.gdb.internal.ui.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import org.eclipse.cdt.debug.core.model.IConnectHandler;
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
@ -35,8 +37,11 @@ import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
import org.eclipse.cdt.dsf.gdb.actions.IConnect;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.ProcessInfo;
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.LaunchUIMessages;
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter;
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.PrompterInfo;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
import org.eclipse.cdt.dsf.gdb.launching.IProcessExtendedInfo;
import org.eclipse.cdt.dsf.gdb.launching.LaunchMessages;
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
@ -45,22 +50,24 @@ import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
import org.eclipse.cdt.dsf.gdb.service.SessionType;
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.IRequest;
import org.eclipse.debug.core.commands.AbstractDebugCommand;
import org.eclipse.debug.core.commands.IDebugCommandRequest;
import org.eclipse.debug.core.commands.IEnabledStateRequest;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.progress.UIJob;
public class GdbConnectCommand implements IConnect {
public class GdbConnectCommand extends AbstractDebugCommand implements IConnectHandler, IConnect {
private final DsfExecutor fExecutor;
private final DsfServicesTracker fTracker;
@ -85,7 +92,19 @@ public class GdbConnectCommand implements IConnect {
}
@Override
public boolean canConnect() {
protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request)
throws CoreException
{
return canConnect();
}
/*
* This method should not be called from the UI thread.
* (non-Javadoc)
* @see org.eclipse.cdt.dsf.gdb.actions.IConnect#canConnect()
*/
@Override
public boolean canConnect() {
Query<Boolean> canConnectQuery = new Query<Boolean>() {
@Override
public void execute(DataRequestMonitor<Boolean> rm) {
@ -115,10 +134,10 @@ public class GdbConnectCommand implements IConnect {
/**
* This job will prompt the user to select a set of processes
* to attach too.
* We need a job because prompter.handleStatus will block and
* We need a job because the ProcessPrompter will block and
* we don't want to block the executor.
*/
protected class PromptForPidJob extends Job {
protected class PromptForPidJob extends UIJob {
// The list of processes used in the case of an ATTACH session
IProcessExtendedInfo[] fProcessList = null;
@ -133,25 +152,14 @@ public class GdbConnectCommand implements IConnect {
}
@Override
protected IStatus run(IProgressMonitor monitor) {
IStatus promptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200/*STATUS_HANDLER_PROMPT*/, "", null); //$NON-NLS-1$//$NON-NLS-2$
final IStatus processPromptStatus = new Status(IStatus.INFO, "org.eclipse.cdt.dsf.gdb.ui", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$
final IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
public IStatus runInUIThread(IProgressMonitor monitor) {
final Status NO_PID_STATUS = new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, -1,
LaunchMessages.getString("LocalAttachLaunchDelegate.No_Process_ID_selected"), //$NON-NLS-1$
null);
if (prompter == null) {
fRequestMonitor.setStatus(NO_PID_STATUS);
fRequestMonitor.done();
return Status.OK_STATUS;
}
try {
PrompterInfo info = new PrompterInfo(fNewProcessSupported, fProcessList);
Object result = prompter.handleStatus(processPromptStatus, info);
Object result = new ProcessPrompter().handleStatus(null, info);
if (result == null) {
fRequestMonitor.cancel();
} else if (result instanceof IProcessExtendedInfo[] || result instanceof String) {
@ -242,21 +250,34 @@ public class GdbConnectCommand implements IConnect {
}
@Override
public void connect(RequestMonitor requestMonitor)
{
// Create a fake rm to avoid null pointer exceptions
final RequestMonitor rm;
if (requestMonitor == null) {
rm = new RequestMonitor(fExecutor, null);
} else {
rm = requestMonitor;
}
protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException {
Query<Boolean> connectQuery = new Query<Boolean>() {
@Override
public void execute(DataRequestMonitor<Boolean> rm) {
connect(rm);
}
};
try {
fExecutor.execute(connectQuery);
connectQuery.get();
} catch (InterruptedException e) {
} catch (ExecutionException e) {
} catch (CancellationException e) {
// Nothing to do, just ignore the command since the user
// cancelled it.
} catch (RejectedExecutionException e) {
// Can be thrown if the session is shutdown
}
}
// Don't wait for the operation to finish because this
// method can be called from the UI thread, and it will
// block it, which is bad, because we need to use the UI
// thread to prompt the user for the process to choose.
// This is why we simply use a DsfRunnable.
/*
* This method should not be called from the UI thread.
* (non-Javadoc)
* @see org.eclipse.cdt.dsf.gdb.actions.IConnect#canConnect()
*/
@Override
public void connect(final RequestMonitor rm)
{
fExecutor.execute(new DsfRunnable() {
@Override
public void run() {
@ -265,12 +286,15 @@ public class GdbConnectCommand implements IConnect {
if (procService != null && commandControl != null) {
final ICommandControlDMContext controlCtx = commandControl.getContext();
procService.isDebugNewProcessSupported(controlCtx, new DataRequestMonitor<Boolean>(fExecutor, null) {
// First check if the "New..." button should be enabled.
procService.isDebugNewProcessSupported(controlCtx, new DataRequestMonitor<Boolean>(fExecutor, rm) {
@Override
protected void handleCompleted() {
final boolean newProcessSupported = isSuccess() && getData();
procService.getRunningProcesses(
// Now get the list of all processes
procService.getRunningProcesses(
controlCtx,
new DataRequestMonitor<IProcessDMContext[]>(fExecutor, rm) {
@Override
@ -282,8 +306,11 @@ public class GdbConnectCommand implements IConnect {
new CountingRequestMonitor(fExecutor, rm) {
@Override
protected void handleSuccess() {
// Prompt the user to choose one or more processes, or to start a new one
new PromptForPidJob(
LaunchUIMessages.getString("ProcessPrompter.PromptJob"), newProcessSupported, procInfoList.toArray(new IProcessExtendedInfo[0]), //$NON-NLS-1$
LaunchUIMessages.getString("ProcessPrompter.PromptJob"), //$NON-NLS-1$
newProcessSupported,
procInfoList.toArray(new IProcessExtendedInfo[procInfoList.size()]),
new DataRequestMonitor<Object>(fExecutor, rm) {
@Override
protected void handleCancel() {
@ -299,8 +326,7 @@ public class GdbConnectCommand implements IConnect {
} else if (data instanceof IProcessExtendedInfo[]) {
attachToProcesses(controlCtx, (IProcessExtendedInfo[])data, rm);
} else {
rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Invalid return type for process prompter", null)); //$NON-NLS-1$
rm.done();
rm.done(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Invalid return type for process prompter", null)); //$NON-NLS-1$
}
}
}).schedule();
@ -382,7 +408,7 @@ public class GdbConnectCommand implements IConnect {
}
private void startNewProcess(ICommandControlDMContext controlDmc, String binaryPath, RequestMonitor rm) {
final IGDBProcesses procService = fTracker.getService(IGDBProcesses.class);
IGDBProcesses procService = fTracker.getService(IGDBProcesses.class);
procService.debugNewProcess(
controlDmc, binaryPath,
new HashMap<String, Object>(), new DataRequestMonitor<IDMContext>(fExecutor, rm));
@ -457,6 +483,8 @@ public class GdbConnectCommand implements IConnect {
LaunchUIMessages.getString("ProcessPrompterDialog.TitlePrefix") + process.getName(), //$NON-NLS-1$
processShortName, new AttachToProcessRequestMonitor()).schedule();
} else {
// For a local attach, we can attach directly without looking for the binary
// since GDB will figure it out by itself
IProcessDMContext procDmc = procService.createProcessContext(controlDmc, pidStr);
procService.attachDebuggerToProcess(procDmc, null, new AttachToProcessRequestMonitor());
}
@ -477,11 +505,24 @@ public class GdbConnectCommand implements IConnect {
new AttachToProcessRequestMonitor().done();
} else {
rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Cannot find service", null)); //$NON-NLS-1$
rm.done();
rm.done(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Cannot find service", null)); //$NON-NLS-1$
}
}
@Override
protected Object getTarget(Object element) {
if (element instanceof GdbLaunch ||
element instanceof IDMVMContext) {
return element;
}
return null;
}
@Override
protected boolean isRemainEnabled(IDebugCommandRequest request) {
return false;
}
}

View file

@ -22,6 +22,7 @@ import java.util.Map;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.model.IConnectHandler;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
@ -520,9 +521,9 @@ public class FinalLaunchSequence extends ReflectionSequence {
fProcService.createProcessContext(fCommandControl.getContext(), Integer.toString(pid)),
new DataRequestMonitor<IDMContext>(getExecutor(), requestMonitor));
} else {
IConnect connectCommand = (IConnect)fSession.getModelAdapter(IConnect.class);
if (connectCommand != null) {
connectCommand.connect(requestMonitor);
IConnectHandler connectCommand = (IConnectHandler)fSession.getModelAdapter(IConnectHandler.class);
if (connectCommand instanceof IConnect) {
((IConnect)connectCommand).connect(requestMonitor);
} else {
requestMonitor.done();
}

View file

@ -18,6 +18,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import org.eclipse.cdt.debug.core.model.IConnectHandler;
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
@ -289,7 +290,12 @@ public class GdbLaunch extends DsfLaunch
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=377447.
if (adapter.equals(ITerminateHandler.class))
return getSession().getModelAdapter(adapter);
// Must force adapters to be loaded.
// Allow to call the connect handler when the launch is selected
if (adapter.equals(IConnectHandler.class))
return getSession().getModelAdapter(adapter);
// Must force adapters to be loaded.
Platform.getAdapterManager().loadAdapter(this, adapter.getName());
return super.getAdapter(adapter);
}