Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Dumais2017-01-23 12:57:02 -0500
committerMarc Dumais2017-02-07 12:47:09 -0500
commit0e074ad3c1c3e1fe83501d97845c291ea7df0876 (patch)
tree4fdbda4556f94ec81d996d54f0824e18cbe7f7c1
parent01ead0227aedb9130c37f7e6e756bb6dbd1bf3df (diff)
downloadorg.eclipse.cdt-0e074ad3c1c3e1fe83501d97845c291ea7df0876.tar.gz
org.eclipse.cdt-0e074ad3c1c3e1fe83501d97845c291ea7df0876.tar.xz
org.eclipse.cdt-0e074ad3c1c3e1fe83501d97845c291ea7df0876.zip
Bug 510615 - Launch dialog, handle spaces in gdb path
The path to GDB is set in the launch dialog, under the Debugger tab. If the path to GDB contains one or more spaces, and is not within double quotes, GDB will not be found and the launch will fail. This patch improves the use cases around the "Browse" button, to select GDB's path. 1) if the user clicks on the "Browse" button, the browse dialog will open in the correct place, no matter the presence of space(s). 2) When GDB's path is selected with the "Browse" button, it's then set in the "GDB debugger" field. This patch looks at the selected path and adds surrounding double quotes if there is any space within, and strips any double quotes if there are no spaces. Change-Id: I202f574772965af3a491d449b9e9a97e8c61e2b0 (cherry picked from commit 7f6e7f8c9b5785a2e219d1fb030a3a197bedb665)
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java11
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java11
-rw-r--r--launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/GdbDebuggerPage.java12
-rw-r--r--llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/LLDBCDebuggerPage.java11
4 files changed, 40 insertions, 5 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java
index 43230042c6..18e1b8e8a9 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java
@@ -207,12 +207,21 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ
String gdbCommand = fGDBCommandText.getText().trim();
int lastSeparatorIndex = gdbCommand.lastIndexOf(File.separator);
if (lastSeparatorIndex != -1) {
- dialog.setFilterPath(gdbCommand.substring(0, lastSeparatorIndex));
+ String cmd = gdbCommand.substring(0, lastSeparatorIndex);
+ // remove double quotes, since they interfere with
+ // "setFilterPath()" below
+ cmd = cmd.replaceAll("\\\"", ""); //$NON-NLS-1$//$NON-NLS-2$
+ dialog.setFilterPath(cmd);
}
String res = dialog.open();
if (res == null) {
return;
}
+ // path contains space(s)?
+ if (res.contains(" ")) { //$NON-NLS-1$
+ // surround it in double quotes
+ res = '"' + res + '"';
+ }
fGDBCommandText.setText(res);
}
});
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java
index 8f96caeebb..751aeca274 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java
@@ -365,12 +365,21 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer {
String gdbCommand = fGDBCommandText.getText().trim();
int lastSeparatorIndex = gdbCommand.lastIndexOf(File.separator);
if (lastSeparatorIndex != -1) {
- dialog.setFilterPath(gdbCommand.substring(0, lastSeparatorIndex));
+ String cmd = gdbCommand.substring(0, lastSeparatorIndex);
+ // remove double quotes, since they interfere with
+ // "setFilterPath()" below
+ cmd = cmd.replaceAll("\\\"", ""); //$NON-NLS-1$//$NON-NLS-2$
+ dialog.setFilterPath(cmd);
}
String res = dialog.open();
if (res == null) {
return;
}
+ // path contains space(s)?
+ if (res.contains(" ")) { //$NON-NLS-1$
+ // surround it in double quotes
+ res = '"' + res + '"';
+ }
fGDBCommandText.setText(res);
}
});
diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/GdbDebuggerPage.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/GdbDebuggerPage.java
index 01ad626dfa..073ba62eff 100644
--- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/GdbDebuggerPage.java
+++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/GdbDebuggerPage.java
@@ -347,13 +347,21 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer {
String gdbCommand = fGDBCommandText.getText().trim();
int lastSeparatorIndex = gdbCommand.lastIndexOf(File.separator);
if (lastSeparatorIndex != -1) {
- dialog.setFilterPath(
- gdbCommand.substring(0, lastSeparatorIndex));
+ String cmd = gdbCommand.substring(0, lastSeparatorIndex);
+ // remove double quotes, since they interfere with
+ // "setFilterPath()" below
+ cmd = cmd.replaceAll("\\\"", ""); //$NON-NLS-1$//$NON-NLS-2$
+ dialog.setFilterPath(cmd);
}
String res = dialog.open();
if (res == null) {
return;
}
+ // path contains space(s)?
+ if (res.contains(" ")) { //$NON-NLS-1$
+ // surround it in double quotes
+ res = '"' + res + '"';
+ }
fGDBCommandText.setText(res);
}
});
diff --git a/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/LLDBCDebuggerPage.java b/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/LLDBCDebuggerPage.java
index 1d5eafa72e..abba8a1a24 100644
--- a/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/LLDBCDebuggerPage.java
+++ b/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/LLDBCDebuggerPage.java
@@ -72,12 +72,21 @@ public class LLDBCDebuggerPage extends AbstractCDebuggerPage {
String lldbCommand = fLLDBCommandText.getText().trim();
int lastSeparatorIndex = lldbCommand.lastIndexOf(File.separator);
if (lastSeparatorIndex != -1) {
- dialog.setFilterPath(lldbCommand.substring(0, lastSeparatorIndex));
+ String cmd = lldbCommand.substring(0, lastSeparatorIndex);
+ // remove double quotes, since they interfere with
+ // "setFilterPath()" below
+ cmd = cmd.replaceAll("\\\"", ""); //$NON-NLS-1$//$NON-NLS-2$
+ dialog.setFilterPath(cmd);
}
String res = dialog.open();
if (res == null) {
return;
}
+ // path contains space(s)?
+ if (res.contains(" ")) { //$NON-NLS-1$
+ // surround it in double quotes
+ res = '"' + res + '"';
+ }
fLLDBCommandText.setText(res);
}
});

Back to the top