From 32ce139214d585d7a1576d641850f8133855b258 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 25 Jul 2011 15:10:16 -0400 Subject: [PATCH] Bug 353005: [remote][attach] Wrong path keeps being re-used after user mistaken when attaching --- .../internal/ui/actions/GdbConnectCommand.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 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 9484ccc188c..0a3effa6dae 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 @@ -191,9 +191,6 @@ public class GdbConnectCommand implements IConnect { // The user pressed the cancel button, so we cancel the attach gracefully fRm.done(); } else { - // Store the path of the binary so we can use it again for another process - // with the same name - fProcessNameToBinaryMap.put(fProcName, binaryPath); final String finalBinaryPath = binaryPath; fExecutor.execute(new DsfRunnable() { @@ -203,7 +200,17 @@ public class GdbConnectCommand implements IConnect { if (procService != null && commandControl != null) { IProcessDMContext procDmc = procService.createProcessContext(commandControl.getContext(), fPid); - procService.attachDebuggerToProcess(procDmc, finalBinaryPath, new DataRequestMonitor(fExecutor, fRm)); + procService.attachDebuggerToProcess(procDmc, finalBinaryPath, new DataRequestMonitor(fExecutor, fRm) { + @Override + protected void handleSuccess() { + // Store the path of the binary so we can use it again for another process + // with the same name. Only do this on success, to avoid being stuck with + // a path that is invalid + fProcessNameToBinaryMap.put(fProcName, finalBinaryPath); + fRm.done(); + }; + }); + } else { fRm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Cannot find services", null)); //$NON-NLS-1$ fRm.done();