Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2011-05-05 22:05:27 -0400
committerMarc Khouzam2011-05-05 22:05:27 -0400
commit8de6de9d5140bddd27f77b0aafdc90c3ec6dc5a9 (patch)
treeaccaf321fb226df4a22ea67a84ef325948f5510c
parentb6a00cad3049794c39e79f5e21786c8cadf1489c (diff)
downloadorg.eclipse.cdt-8de6de9d5140bddd27f77b0aafdc90c3ec6dc5a9.tar.gz
org.eclipse.cdt-8de6de9d5140bddd27f77b0aafdc90c3ec6dc5a9.tar.xz
org.eclipse.cdt-8de6de9d5140bddd27f77b0aafdc90c3ec6dc5a9.zip
Bug 344892: Deadlock when trying to attach to more than one process on a remote target
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbConnectCommand.java67
1 files changed, 50 insertions, 17 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 f25797c023c..7925a5b2be4 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
@@ -145,6 +145,46 @@ public class GdbConnectCommand implements IConnect {
}
};
+ // Need a job to free the executor while we prompt the user for a binary path
+ // Bug 344892
+ private class PromptAndAttachToProcessJob extends Job {
+ private final String fPid;
+ private final RequestMonitor fRm;
+
+ public PromptAndAttachToProcessJob(String pid, RequestMonitor rm) {
+ super(""); //$NON-NLS-1$
+ fPid = pid;
+ fRm = rm;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ final String[] binaryPath = new String[1];
+ binaryPath[0] = null;
+ 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();
+ }
+ }
+ });
+
+ fExecutor.execute(new DsfRunnable() {
+ public void run() {
+ IGDBProcesses procService = fTracker.getService(IGDBProcesses.class);
+ ICommandControlService commandControl = fTracker.getService(ICommandControlService.class);
+
+ IProcessDMContext procDmc = procService.createProcessContext(commandControl.getContext(), fPid);
+ procService.attachDebuggerToProcess(procDmc, binaryPath[0], new DataRequestMonitor<IDMContext>(fExecutor, fRm));
+ }
+ });
+
+ return Status.OK_STATUS;
+ }
+ }
+
public void connect(RequestMonitor requestMonitor)
{
// Create a fake rm to avoid null pointer exceptions
@@ -206,27 +246,20 @@ 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;
+ String pidStr = Integer.toString((Integer)data);
final IGDBBackend backend = fTracker.getService(IGDBBackend.class);
if (backend != null && backend.getSessionType() == SessionType.REMOTE) {
- // For remote attach, we must set the binary first
+ // For remote attach, we must set the binary first so we need to prompt the user.
+ // Because the prompt is a very long operation, we need to run outside the
+ // executor, so we don't lock it.
+ // Bug 344892
+ new PromptAndAttachToProcessJob(pidStr, rm).schedule();
+ } else {
// 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();
- }
- }
- });
+ // so we don't need to prompt for it.
+ IProcessDMContext procDmc = procService.createProcessContext(controlCtx, pidStr);
+ procService.attachDebuggerToProcess(procDmc, null, new DataRequestMonitor<IDMContext>(fExecutor, rm));
}
-
- IProcessDMContext procDmc = procService.createProcessContext(controlCtx,
- Integer.toString((Integer)getData()));
- 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();

Back to the top