diff --git a/plugins/org.eclipse.dd.dsf.debug.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.dsf.debug.ui/META-INF/MANIFEST.MF
index 2e778523daa..52e4ccfd716 100644
--- a/plugins/org.eclipse.dd.dsf.debug.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.dd.dsf.debug.ui/META-INF/MANIFEST.MF
@@ -30,6 +30,7 @@ Require-Bundle: org.eclipse.ui,
Bundle-ActivationPolicy: lazy
Export-Package:
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel,
+ org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.actions,
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.expression,
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.launch,
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.modules,
diff --git a/plugins/org.eclipse.dd.gdb.ui/icons/full/obj16/connect.gif b/plugins/org.eclipse.dd.gdb.ui/icons/full/obj16/connect.gif
new file mode 100755
index 00000000000..866ad338250
Binary files /dev/null and b/plugins/org.eclipse.dd.gdb.ui/icons/full/obj16/connect.gif differ
diff --git a/plugins/org.eclipse.dd.gdb.ui/plugin.properties b/plugins/org.eclipse.dd.gdb.ui/plugin.properties
new file mode 100644
index 00000000000..44a50b455c8
--- /dev/null
+++ b/plugins/org.eclipse.dd.gdb.ui/plugin.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2008 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
+###############################################################################
+pluginName=Debug Services Framework GDB UI Plug-in
+providerName=Eclipse.org
+
+action.connect.label = Connect...
+action.connect.tooltip = Connect to a process
diff --git a/plugins/org.eclipse.dd.gdb.ui/plugin.xml b/plugins/org.eclipse.dd.gdb.ui/plugin.xml
index 1ab367f9d24..0d1528ea453 100644
--- a/plugins/org.eclipse.dd.gdb.ui/plugin.xml
+++ b/plugins/org.eclipse.dd.gdb.ui/plugin.xml
@@ -58,5 +58,37 @@
id="org.eclipse.dd.gdb.ui.GdbServerDebuggerPage">
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/GdbAdapterFactory.java b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/GdbAdapterFactory.java
index 4114088decd..1141877cd89 100644
--- a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/GdbAdapterFactory.java
+++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/GdbAdapterFactory.java
@@ -30,9 +30,11 @@ import org.eclipse.dd.dsf.debug.ui.actions.DsfSuspendCommand;
import org.eclipse.dd.dsf.debug.ui.contexts.DsfSuspendTrigger;
import org.eclipse.dd.dsf.debug.ui.sourcelookup.DsfSourceDisplayAdapter;
import org.eclipse.dd.dsf.service.DsfSession;
+import org.eclipse.dd.gdb.internal.provisional.actions.IConnect;
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunchDelegate;
import org.eclipse.dd.gdb.internal.ui.actions.DsfTerminateCommand;
+import org.eclipse.dd.gdb.internal.ui.actions.GdbConnectCommand;
import org.eclipse.dd.gdb.internal.ui.actions.GdbRestartCommand;
import org.eclipse.dd.gdb.internal.ui.viewmodel.GdbViewModelAdapter;
import org.eclipse.debug.core.DebugPlugin;
@@ -76,6 +78,7 @@ public class GdbAdapterFactory
final DsfResumeCommand fResumeCommand;
final GdbRestartCommand fRestartCommand;
final DsfTerminateCommand fTerminateCommand;
+ final GdbConnectCommand fConnectCommand;
final IDebugModelProvider fDebugModelProvider;
final DsfSuspendTrigger fSuspendTrigger;
final DsfSteppingModeTarget fSteppingModeTarget;
@@ -107,6 +110,7 @@ public class GdbAdapterFactory
fResumeCommand = new DsfResumeCommand(session);
fRestartCommand = new GdbRestartCommand(session, fLaunch);
fTerminateCommand = new DsfTerminateCommand(session);
+ fConnectCommand = new GdbConnectCommand(session);
fSuspendTrigger = new DsfSuspendTrigger(session, fLaunch);
fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory();
@@ -118,6 +122,7 @@ public class GdbAdapterFactory
session.registerModelAdapter(IResumeHandler.class, fResumeCommand);
session.registerModelAdapter(IRestart.class, fRestartCommand);
session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
+ session.registerModelAdapter(IConnect.class, fConnectCommand);
session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory);
fDebugModelProvider = new IDebugModelProvider() {
@@ -155,6 +160,7 @@ public class GdbAdapterFactory
session.unregisterModelAdapter(IResumeHandler.class);
session.unregisterModelAdapter(IRestart.class);
session.unregisterModelAdapter(ITerminateHandler.class);
+ session.unregisterModelAdapter(IConnect.class);
session.unregisterModelAdapter(IModelSelectionPolicyFactory.class);
fStepIntoCommand.dispose();
@@ -164,6 +170,7 @@ public class GdbAdapterFactory
fResumeCommand.dispose();
fRestartCommand.dispose();
fTerminateCommand.dispose();
+ fConnectCommand.dispose();
fSuspendTrigger.dispose();
}
diff --git a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/actions/ConnectActionDelegate.java b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/actions/ConnectActionDelegate.java
new file mode 100644
index 00000000000..7a56710ccb1
--- /dev/null
+++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/actions/ConnectActionDelegate.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.dd.gdb.internal.ui.actions;
+
+import org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.actions.AbstractVMProviderActionDelegate;
+import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
+import org.eclipse.dd.gdb.internal.provisional.actions.IConnect;
+import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
+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)
+ */
+ 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/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/actions/GdbConnectCommand.java b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/actions/GdbConnectCommand.java
new file mode 100644
index 00000000000..2d247743d05
--- /dev/null
+++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/actions/GdbConnectCommand.java
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.dd.gdb.internal.ui.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+
+import org.eclipse.cdt.core.IProcessInfo;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.dd.dsf.concurrent.CountingRequestMonitor;
+import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
+import org.eclipse.dd.dsf.concurrent.DsfExecutor;
+import org.eclipse.dd.dsf.concurrent.DsfRunnable;
+import org.eclipse.dd.dsf.concurrent.Query;
+import org.eclipse.dd.dsf.concurrent.RequestMonitor;
+import org.eclipse.dd.dsf.datamodel.IDMContext;
+import org.eclipse.dd.dsf.debug.service.IProcesses;
+import org.eclipse.dd.dsf.debug.service.IProcesses.IProcessDMContext;
+import org.eclipse.dd.dsf.debug.service.IProcesses.IThreadDMData;
+import org.eclipse.dd.dsf.service.DsfServicesTracker;
+import org.eclipse.dd.dsf.service.DsfSession;
+import org.eclipse.dd.gdb.internal.provisional.actions.IConnect;
+import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages;
+import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin;
+import org.eclipse.dd.mi.service.MIProcesses;
+import org.eclipse.dd.mi.service.ProcessInfo;
+import org.eclipse.dd.mi.service.command.AbstractMIControl;
+import org.eclipse.dd.mi.service.command.MIControlDMContext;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IStatusHandler;
+
+public class GdbConnectCommand implements IConnect {
+
+ private final DsfExecutor fExecutor;
+ private final DsfServicesTracker fTracker;
+
+ public GdbConnectCommand(DsfSession session) {
+ fExecutor = session.getExecutor();
+ fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
+ }
+
+ public void dispose() {
+ fTracker.dispose();
+ }
+
+ public boolean canConnect() {
+ Query canConnectQuery = new Query() {
+ @Override
+ public void execute(DataRequestMonitor rm) {
+ IProcesses procService = fTracker.getService(IProcesses.class);
+ AbstractMIControl miControl = fTracker.getService(AbstractMIControl.class);
+
+ if (procService != null && miControl != null) {
+ procService.isDebuggerAttachSupported(miControl.getControlDMContext(), rm);
+ } else {
+ rm.setData(false);
+ rm.done();
+ }
+ }
+ };
+
+ fExecutor.execute(canConnectQuery);
+ try {
+ return canConnectQuery.get();
+ } catch (InterruptedException e) {
+ } catch (ExecutionException e) {
+ }
+ return false;
+ }
+
+ // Need a job because prompter.handleStatus will block
+ class PromptForPidJob extends Job {
+
+ // The list of processes used in the case of an ATTACH session
+ IProcessInfo[] fProcessList = null;
+ DataRequestMonitor fRequestMonitor;
+
+ public PromptForPidJob(String name, IProcessInfo[] procs, DataRequestMonitor rm) {
+ super(name);
+ fProcessList = procs;
+ fRequestMonitor = rm;
+ }
+
+ @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.dd.gdb.ui", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$
+
+ final IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
+
+ 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 {
+ Object result = prompter.handleStatus(processPromptStatus, fProcessList);
+ if (result instanceof Integer) {
+ fRequestMonitor.setData((Integer)result);
+ } else {
+ fRequestMonitor.setStatus(NO_PID_STATUS);
+ }
+ } catch (CoreException e) {
+ fRequestMonitor.setStatus(NO_PID_STATUS);
+ }
+ fRequestMonitor.done();
+
+ return Status.OK_STATUS;
+ }
+ };
+
+ 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.
+ fExecutor.execute(new DsfRunnable() {
+ public void run() {
+ final IProcesses procService = fTracker.getService(IProcesses.class);
+ AbstractMIControl miControl = fTracker.getService(AbstractMIControl.class);
+ final MIControlDMContext controlCtx = miControl.getControlDMContext();
+
+ if (procService != null && miControl != null) {
+ procService.getRunningProcesses(
+ controlCtx,
+ new DataRequestMonitor(fExecutor, rm) {
+ @Override
+ protected void handleSuccess() {
+
+ final List procInfoList = new ArrayList();
+
+ // For each process, obtain its name
+ // Once all the names are obtained, prompt the user for the pid to use
+ final CountingRequestMonitor countingRm =
+ new CountingRequestMonitor(fExecutor, rm) {
+ @Override
+ protected void handleSuccess() {
+ new PromptForPidJob(
+ "Prompt for Process", procInfoList.toArray(new IProcessInfo[0]), //$NON-NLS-1$
+ new DataRequestMonitor(fExecutor, rm) {
+ @Override
+ protected void handleSuccess() {
+ // New cycle, look for service again
+ final MIProcesses procService = fTracker.getService(MIProcesses.class);
+ if (procService != null) {
+ IProcessDMContext procDmc = procService.createProcessContext(controlCtx,
+ Integer.toString(getData()));
+ procService.attachDebuggerToProcess(procDmc, new DataRequestMonitor(fExecutor, rm));
+ }
+ }
+ }).schedule();
+ }
+ };
+
+ // New cycle, look for service again
+ final IProcesses procService = fTracker.getService(IProcesses.class);
+
+ if (procService != null) {
+ countingRm.setDoneCount(getData().length);
+
+ for (IProcessDMContext processCtx : getData()) {
+ procService.getExecutionData(
+ processCtx,
+ new DataRequestMonitor (fExecutor, countingRm) {
+ @Override
+ protected void handleSuccess() {
+ int pid = 0;
+ try {
+ pid = Integer.parseInt(getData().getId());
+ } catch (NumberFormatException e) {
+ }
+ procInfoList.add(new ProcessInfo(pid, getData().getName()));
+ countingRm.done();
+ }
+ });
+ }
+ } else {
+ countingRm.setDoneCount(1);
+ countingRm.done();
+ }
+ }
+ });
+ } else {
+ rm.done();
+ }
+ }
+ });
+ }
+}
diff --git a/plugins/org.eclipse.dd.gdb/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.gdb/META-INF/MANIFEST.MF
index df5e6b7a72d..694df39b150 100644
--- a/plugins/org.eclipse.dd.gdb/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.dd.gdb/META-INF/MANIFEST.MF
@@ -16,6 +16,7 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.dd.gdb.internal.provisional,
+ org.eclipse.dd.gdb.internal.provisional.actions,
org.eclipse.dd.gdb.internal.provisional.breakpoints,
org.eclipse.dd.gdb.internal.provisional.launching,
org.eclipse.dd.gdb.internal.provisional.service,
diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/actions/IConnect.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/actions/IConnect.java
new file mode 100644
index 00000000000..766aee60f0d
--- /dev/null
+++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/actions/IConnect.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.dd.gdb.internal.provisional.actions;
+
+import org.eclipse.dd.dsf.concurrent.RequestMonitor;
+
+public interface IConnect {
+ /**
+ * Returns whether this element can currently attempt to
+ * connect to a new process.
+ */
+ public boolean canConnect();
+
+ /**
+ * Causes this element to attempt to connect to a new process.
+ */
+ public void connect(RequestMonitor rm);
+}
diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java
index 879b68d8257..7e1e4fd191d 100644
--- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java
+++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java
@@ -15,7 +15,6 @@ import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.cdt.core.IProcessInfo;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
@@ -25,29 +24,24 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
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.core.variables.VariablesPlugin;
-import org.eclipse.dd.dsf.concurrent.CountingRequestMonitor;
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
import org.eclipse.dd.dsf.concurrent.DsfExecutor;
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
import org.eclipse.dd.dsf.concurrent.Sequence;
import org.eclipse.dd.dsf.datamodel.IDMContext;
-import org.eclipse.dd.dsf.debug.service.IProcesses.IProcessDMContext;
-import org.eclipse.dd.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.dd.dsf.service.DsfServicesTracker;
import org.eclipse.dd.gdb.internal.GdbPlugin;
import org.eclipse.dd.gdb.internal.provisional.IGDBLaunchConfigurationConstants;
+import org.eclipse.dd.gdb.internal.provisional.actions.IConnect;
import org.eclipse.dd.gdb.internal.provisional.service.GDBProcesses;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
import org.eclipse.dd.mi.service.CSourceLookup;
import org.eclipse.dd.mi.service.MIBreakpointsManager;
-import org.eclipse.dd.mi.service.ProcessInfo;
import org.eclipse.dd.mi.service.command.commands.CLISource;
import org.eclipse.dd.mi.service.command.commands.MIEnvironmentCD;
import org.eclipse.dd.mi.service.command.commands.MIFileExecAndSymbols;
@@ -59,8 +53,6 @@ import org.eclipse.dd.mi.service.command.commands.MIGDBSetSysroot;
import org.eclipse.dd.mi.service.command.commands.MITargetSelect;
import org.eclipse.dd.mi.service.command.commands.RawCommand;
import org.eclipse.dd.mi.service.command.output.MIInfo;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IStatusHandler;
public class FinalLaunchSequence extends Sequence {
@@ -406,54 +398,6 @@ public class FinalLaunchSequence extends Sequence {
* If attach session, perform the attach.
*/
new Step() {
-
- // Need a job because prompter.handleStatus will block
- class PromptForPidJob extends Job {
-
- // The list of processes used in the case of an ATTACH session
- IProcessInfo[] fProcessList = null;
- DataRequestMonitor fRequestMonitor;
-
- public PromptForPidJob(String name, IProcessInfo[] procs, DataRequestMonitor rm) {
- super(name);
- fProcessList = procs;
- fRequestMonitor = rm;
- }
-
- @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.dd.gdb.ui", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$
-
- final IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
-
- final Status NO_PID_STATUS = new Status(IStatus.ERROR, GdbPlugin.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 {
- Object result = prompter.handleStatus(processPromptStatus, fProcessList);
- if (result instanceof Integer) {
- fRequestMonitor.setData(fProcService.createProcessContext(fCommandControl.getGDBDMContext(),
- Integer.toString((Integer)result)));
- } else {
- fRequestMonitor.setStatus(NO_PID_STATUS);
- }
- } catch (CoreException e) {
- fRequestMonitor.setStatus(NO_PID_STATUS);
- }
- fRequestMonitor.done();
-
- return Status.OK_STATUS;
- }
- };
-
@Override
public void execute(final RequestMonitor requestMonitor) {
if (fAttach) {
@@ -468,56 +412,15 @@ public class FinalLaunchSequence extends Sequence {
if (pid != -1) {
fProcService.attachDebuggerToProcess(
- fProcService.createProcessContext(fCommandControl.getGDBDMContext(), Integer.toString(pid)),
+ fProcService.createProcessContext(fCommandControl.getGDBDMContext(), Integer.toString(pid)),
new DataRequestMonitor(getExecutor(), requestMonitor));
} else {
- fProcService.getRunningProcesses(
- fCommandControl.getGDBDMContext(),
- new DataRequestMonitor(getExecutor(), requestMonitor) {
- @Override
- protected void handleSuccess() {
-
- final List procInfoList = new ArrayList();
-
- // For each process, obtain its name
- // Once all the names are obtained, prompt the user the pid to use
- final CountingRequestMonitor countingRm =
- new CountingRequestMonitor(getExecutor(), requestMonitor) {
- @Override
- protected void handleSuccess() {
- new PromptForPidJob(
- "Prompt for Process", procInfoList.toArray(new IProcessInfo[0]), //$NON-NLS-1$
- new DataRequestMonitor(getExecutor(), requestMonitor) {
- @Override
- protected void handleSuccess() {
- fProcService.attachDebuggerToProcess(
- getData(),
- new DataRequestMonitor(getExecutor(), requestMonitor));
- }
- }).schedule();
- }
- };
-
- countingRm.setDoneCount(getData().length);
-
- for (IProcessDMContext processCtx : getData()) {
- fProcService.getExecutionData(
- processCtx,
- new DataRequestMonitor (getExecutor(), countingRm) {
- @Override
- protected void handleSuccess() {
- int pid = 0;
- try {
- pid = Integer.parseInt(getData().getId());
- } catch (NumberFormatException e) {
- }
- procInfoList.add(new ProcessInfo(pid, getData().getName()));
- countingRm.done();
- }
- });
- }
- }
- });
+ IConnect connectCommand = (IConnect)fLaunch.getSession().getModelAdapter(IConnect.class);
+ if (connectCommand != null) {
+ connectCommand.connect(requestMonitor);
+ } else {
+ requestMonitor.done();
+ }
}
} else {
requestMonitor.done();
diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/GDBProcesses.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/GDBProcesses.java
index 66f465d42ab..5141a7b2c29 100644
--- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/GDBProcesses.java
+++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/GDBProcesses.java
@@ -116,7 +116,13 @@ public class GDBProcesses extends MIProcesses {
super.getExecutionData(dmc, rm);
}
}
-
+
+ @Override
+ public void isDebuggerAttachSupported(IDMContext dmc, DataRequestMonitor rm) {
+ rm.setData(!fGdb.isConnected());
+ rm.done();
+ }
+
@Override
public void getProcessesBeingDebugged(IDMContext dmc, DataRequestMonitor rm) {
MIInferiorProcess inferiorProcess = fGdb.getInferiorProcess();
diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl.java
index 376a987bcbc..e9400c68fcf 100644
--- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl.java
+++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/service/command/GDBControl.java
@@ -96,7 +96,7 @@ public class GDBControl extends AbstractMIControl {
public boolean fAttach;
- private boolean fConnected = false;
+ private boolean fConnected = true;
private MonitorJob fMonitorJob;
private IPath fGdbPath;
diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIProcesses.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIProcesses.java
index aaf5ac4efdd..397438ffa64 100644
--- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIProcesses.java
+++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIProcesses.java
@@ -356,7 +356,7 @@ public class MIProcesses extends AbstractDsfService implements IProcesses {
}
public void isDebuggerAttachSupported(IDMContext dmc, DataRequestMonitor rm) {
- rm.setData(true);
+ rm.setData(false);
rm.done();
}