diff options
author | Marc Khouzam | 2011-03-11 16:35:34 +0000 |
---|---|---|
committer | Marc Khouzam | 2011-03-11 16:35:34 +0000 |
commit | c2239d41b83e8383ce88e61d1925c0ca0ae76425 (patch) | |
tree | 0f72c7571edf7044e638dd7b2fd91d6216f4f9f7 /dsf-gdb | |
parent | 461e44b498af4b9f1b0102ae9be82635db3fcaf1 (diff) | |
download | org.eclipse.cdt-c2239d41b83e8383ce88e61d1925c0ca0ae76425.tar.gz org.eclipse.cdt-c2239d41b83e8383ce88e61d1925c0ca0ae76425.tar.xz org.eclipse.cdt-c2239d41b83e8383ce88e61d1925c0ca0ae76425.zip |
Bug 237306: Support for Multi-Process debugging. Prompting the user for the path to the binary when doing a remote attach.v201103111317
Diffstat (limited to 'dsf-gdb')
6 files changed, 82 insertions, 41 deletions
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/actions/GdbConnectCommand.java index b6a45f8f4ce..5d36b7d44bf 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/actions/GdbConnectCommand.java @@ -34,8 +34,10 @@ import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.PrompterInfo; import org.eclipse.cdt.dsf.gdb.launching.IProcessExtendedInfo; import org.eclipse.cdt.dsf.gdb.launching.LaunchMessages; +import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; +import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses; import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData; -import org.eclipse.cdt.dsf.mi.service.IMIProcesses; +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.core.runtime.CoreException; @@ -45,6 +47,11 @@ 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.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; public class GdbConnectCommand implements IConnect { @@ -181,7 +188,7 @@ public class GdbConnectCommand implements IConnect { @Override protected void handleSuccess() { // New cycle, look for service again - final IMIProcesses procService = fTracker.getService(IMIProcesses.class); + final IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); if (procService != null) { Object data = getData(); if (data instanceof String) { @@ -192,9 +199,27 @@ public class GdbConnectCommand implements IConnect { // khouzam, maybe we should at least pass stopOnMain? new HashMap<String, Object>(), new DataRequestMonitor<IDMContext>(fExecutor, rm)); } else if (data instanceof Integer) { + final String[] binaryPath = new String[1]; + binaryPath[0] = null; + final IGDBBackend backend = fTracker.getService(IGDBBackend.class); + if (backend != null && backend.getSessionType() == SessionType.REMOTE) { + // For remote attach, we must set the binary first + // For a local attach, GDB can figure out the binary automatically, + // so we don't specify it. + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + public void run() { + Shell shell = Display.getCurrent().getActiveShell(); + if (shell != null) { + FileDialog fd = new FileDialog(shell, SWT.NONE); + binaryPath[0] = fd.open(); + } + } + }); + } + IProcessDMContext procDmc = procService.createProcessContext(controlCtx, Integer.toString((Integer)getData())); - procService.attachDebuggerToProcess(procDmc, new DataRequestMonitor<IDMContext>(fExecutor, rm)); + procService.attachDebuggerToProcess(procDmc, binaryPath[0], new DataRequestMonitor<IDMContext>(fExecutor, 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(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java index 9e5dbb6111c..86bb9ea0fb4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java @@ -30,7 +30,7 @@ public class ProcessPrompterDialog extends TwoPaneElementSelector { @Override protected void buttonPressed(int buttonId) { if (buttonId == NEW_BUTTON_ID) { - FileDialog fd = new FileDialog(getShell(), SWT.SAVE); + FileDialog fd = new FileDialog(getShell(), SWT.NONE); fBinaryPath = fd.open(); setReturnCode(OK); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java index e1fc50d9d92..ecf5a721474 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java @@ -57,7 +57,6 @@ import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.utils.pty.PTY; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; @@ -224,11 +223,14 @@ public class GDBProcesses extends MIProcesses implements IGDBProcesses { } @Override - public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> rm) { - // For remote attach, we must set the binary first - // For a local attach, GDB can figure out the binary automatically, - // so we don't specify it. - + public void attachDebuggerToProcess(IProcessDMContext procCtx, DataRequestMonitor<IDMContext> rm) { + attachDebuggerToProcess(procCtx, null, rm); + } + + /** + * @since 4.0 + */ + public void attachDebuggerToProcess(final IProcessDMContext procCtx, String binaryPath, final DataRequestMonitor<IDMContext> rm) { final IMIContainerDMContext containerDmc = createContainerContext(procCtx, MIProcesses.UNIQUE_GROUP_ID); DataRequestMonitor<MIInfo> attachRm = new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm) { @@ -253,14 +255,11 @@ public class GDBProcesses extends MIProcesses implements IGDBProcesses { } }; - if (fBackend.getSessionType() == SessionType.REMOTE) { - final IPath execPath = fBackend.getProgramPath(); - if (execPath != null && !execPath.isEmpty()) { - fGdb.queueCommand( - fCommandFactory.createMIFileExecAndSymbols(containerDmc, execPath.toPortableString()), - attachRm); - return; - } + if (binaryPath != null) { + fGdb.queueCommand( + fCommandFactory.createMIFileExecAndSymbols(containerDmc, binaryPath), + attachRm); + return; } // If we get here, let's do the attach by completing the requestMonitor diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java index bcffcdb9ae0..3de4c33dc6a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java @@ -79,7 +79,6 @@ import org.eclipse.cdt.dsf.service.AbstractDsfService; import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; @@ -754,7 +753,14 @@ public class GDBProcesses_7_0 extends AbstractDsfService rm.done(); } - public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> dataRm) { + public void attachDebuggerToProcess(IProcessDMContext procCtx, DataRequestMonitor<IDMContext> rm) { + attachDebuggerToProcess(procCtx, null, rm); + } + + /** + * @since 4.0 + */ + public void attachDebuggerToProcess(final IProcessDMContext procCtx, final String binaryPath, final DataRequestMonitor<IDMContext> dataRm) { if (procCtx instanceof IMIProcessDMContext) { if (!doIsDebuggerAttachSupported()) { dataRm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Attach not supported.", null)); //$NON-NLS-1$ @@ -784,14 +790,11 @@ public class GDBProcesses_7_0 extends AbstractDsfService // There is no groupId until we attach, so we can use the default groupId fContainerDmc = createContainerContext(procCtx, MIProcesses.UNIQUE_GROUP_ID); - if (fBackend.getSessionType() == SessionType.REMOTE) { - final IPath execPath = fBackend.getProgramPath(); - if (execPath != null && !execPath.isEmpty()) { - fCommandControl.queueCommand( - fCommandFactory.createMIFileExecAndSymbols(fContainerDmc, execPath.toPortableString()), - new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm)); - return; - } + if (binaryPath != null) { + fCommandControl.queueCommand( + fCommandFactory.createMIFileExecAndSymbols(fContainerDmc, binaryPath), + new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm)); + return; } rm.done(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java index d42949861b4..ed3c0032f21 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java @@ -33,7 +33,6 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunch; @@ -100,7 +99,15 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 { } @Override - public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> dataRm) { + public void attachDebuggerToProcess(IProcessDMContext procCtx, DataRequestMonitor<IDMContext> rm) { + attachDebuggerToProcess(procCtx, null, rm); + } + + /** + * @since 4.0 + */ + @Override + public void attachDebuggerToProcess(final IProcessDMContext procCtx, final String binaryPath, final DataRequestMonitor<IDMContext> dataRm) { if (procCtx instanceof IMIProcessDMContext) { if (!doIsDebuggerAttachSupported()) { dataRm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Attach not supported.", null)); //$NON-NLS-1$ @@ -143,20 +150,14 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 { }); } }, - // For remote attach, we must set the binary first - // For a local attach, GDB can figure out the binary automatically, - // so we don't specify it. new Step() { @Override public void execute(RequestMonitor rm) { - if (fBackend.getSessionType() == SessionType.REMOTE) { - final IPath execPath = fBackend.getProgramPath(); - if (execPath != null && !execPath.isEmpty()) { - fCommandControl.queueCommand( - fCommandFactory.createMIFileExecAndSymbols(fContainerDmc, execPath.toPortableString()), - new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm)); - return; - } + if (binaryPath != null) { + fCommandControl.queueCommand( + fCommandFactory.createMIFileExecAndSymbols(fContainerDmc, binaryPath), + new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm)); + return; } rm.done(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBProcesses.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBProcesses.java index fa1bd0c3353..9191a28b573 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBProcesses.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBProcesses.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.dsf.gdb.service; import java.util.Map; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; @@ -90,5 +91,17 @@ public interface IGDBProcesses extends IMIProcesses { * @since 4.0 */ void start(IContainerDMContext containerDmc, Map<String, Object> attributes, DataRequestMonitor<IContainerDMContext> rm); + + /** + * Attaches debugger to the given process. + * When attaching to a process, a debugging context can now be used to characterize the process. + * This method can optionally choose to return this IDMContext inside the DataRequestMonitor. + * This can be useful for backends that do not have the ability to obtain the different + * debugging IDMContexts through {@link #getProcessesBeingDebugged(IDMContext, DataRequestMonitor) + * + * @param file Binary to use for the process. + * @since 4.0 + */ + void attachDebuggerToProcess(IProcessDMContext procCtx, String file, DataRequestMonitor<IDMContext> rm); } |