diff options
author | Marc Khouzam | 2012-07-24 17:13:32 +0000 |
---|---|---|
committer | Marc Khouzam | 2012-07-25 14:36:09 +0000 |
commit | 03af322a6fc2a686bfe275d6c4f3a0c0ad2bc1f0 (patch) | |
tree | 09116abc6bb925ecf9661404600003504828c28e /dsf-gdb/org.eclipse.cdt.dsf.gdb.ui | |
parent | 6500f4755fbedc07f8e7172d39f8cc21798ee3c7 (diff) | |
download | org.eclipse.cdt-03af322a6fc2a686bfe275d6c4f3a0c0ad2bc1f0.tar.gz org.eclipse.cdt-03af322a6fc2a686bfe275d6c4f3a0c0ad2bc1f0.tar.xz org.eclipse.cdt-03af322a6fc2a686bfe275d6c4f3a0c0ad2bc1f0.zip |
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>
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.dsf.gdb.ui')
-rwxr-xr-x | dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/connect.gif | bin | 189 -> 0 bytes | |||
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties | 3 | ||||
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml | 48 | ||||
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java | 8 | ||||
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ConnectActionDelegate.java | 84 | ||||
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java | 2 | ||||
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java (renamed from dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbConnectCommand.java) | 129 |
7 files changed, 90 insertions, 184 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/connect.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/connect.gif Binary files differdeleted file mode 100755 index 866ad338250..00000000000 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/connect.gif +++ /dev/null diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties index 4a343bfaf70..6248385f21a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties @@ -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 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml index 62f27c7673e..b59f15537b5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml @@ -211,54 +211,6 @@ </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 id="org.eclipse.cdt.dsf.gdb.ui.testIsGdbUIPluginActive"> diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java index da17bba5f5c..f899c0c487b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java @@ -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); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ConnectActionDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ConnectActionDelegate.java deleted file mode 100644 index 81cba62accb..00000000000 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ConnectActionDelegate.java +++ /dev/null @@ -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; - } -} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java index 6b763246435..8bfd5882874 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java @@ -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; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbConnectCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java index 04ca9d980ee..d90dc5752ac 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbConnectCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java @@ -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; - } - - // 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. + 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 + } + } + + /* + * 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; + } } |