1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-30 21:55:31 +02:00

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
This commit is contained in:
Marc Dumais 2017-01-23 12:57:02 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent ff23fc9dbe
commit 7f6e7f8c9b
4 changed files with 40 additions and 5 deletions

View file

@ -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);
}
});

View file

@ -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);
}
});

View file

@ -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);
}
});

View file

@ -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);
}
});