mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 344892: Deadlock when trying to attach to more than one process on a remote target
This commit is contained in:
parent
b6a00cad30
commit
8de6de9d51
1 changed files with 50 additions and 17 deletions
|
@ -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)
|
public void connect(RequestMonitor requestMonitor)
|
||||||
{
|
{
|
||||||
// Create a fake rm to avoid null pointer exceptions
|
// 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?
|
// khouzam, maybe we should at least pass stopOnMain?
|
||||||
new HashMap<String, Object>(), new DataRequestMonitor<IDMContext>(fExecutor, rm));
|
new HashMap<String, Object>(), new DataRequestMonitor<IDMContext>(fExecutor, rm));
|
||||||
} else if (data instanceof Integer) {
|
} else if (data instanceof Integer) {
|
||||||
final String[] binaryPath = new String[1];
|
String pidStr = Integer.toString((Integer)data);
|
||||||
binaryPath[0] = null;
|
|
||||||
final IGDBBackend backend = fTracker.getService(IGDBBackend.class);
|
final IGDBBackend backend = fTracker.getService(IGDBBackend.class);
|
||||||
if (backend != null && backend.getSessionType() == SessionType.REMOTE) {
|
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,
|
// For a local attach, GDB can figure out the binary automatically,
|
||||||
// so we don't specify it.
|
// so we don't need to prompt for it.
|
||||||
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
|
IProcessDMContext procDmc = procService.createProcessContext(controlCtx, pidStr);
|
||||||
public void run() {
|
procService.attachDebuggerToProcess(procDmc, null, new DataRequestMonitor<IDMContext>(fExecutor, rm));
|
||||||
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, binaryPath[0], new DataRequestMonitor<IDMContext>(fExecutor, rm));
|
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Invalid return type for process prompter", null)); //$NON-NLS-1$
|
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();
|
||||||
|
|
Loading…
Add table
Reference in a new issue