Next: Command Options, Previous: Completion, Up: Commands [Contents][Index]
When passing filenames (or directory names) as arguments to a command, if the filename argument does not include any whitespace, double quotes, or single quotes, then for all commands the filename can be written as a simple string, for example:
(gdb) file /path/to/some/file
If the filename does include whitespace, double quotes, or single quotes, then GDB has two approaches for how these filenames should be formatted; which format to use depends on which command is being used.
Most GDB commands don’t require, or support, quoting and escaping. These commands treat any text after the command name, that is not a command option (see Command Options), as the filename, even if the filename contains whitespace or quote characters. In the following example the user is adding /path/that contains/two spaces/ to the auto-load safe-path (see add-auto-load-safe-path):
(gdb) add-auto-load-safe-path /path/that contains/two spaces/
A small number of commands require that filenames containing whitespace or quote characters are either quoted, or have the special characters escaped with a backslash. Commands that support this style are marked as such in the manual, any command not marked as accepting quoting and escaping of its filename argument, does not accept this filename argument style.
For example, to load the file /path/with spaces/to/a file
with the file
command (see Commands to Specify
Files), you can escape the whitespace characters with a backslash:
(gdb) file /path/with\ spaces/to/a\ file
Alternatively the entire filename can be wrapped in either single or double quotes, in which case no backlsashes are needed, for example:
(gdb) symbol-file "/path/with spaces/to/a file" (gdb) exec-file '/path/with spaces/to/a file'
It is possible to include a quote character within a quoted filename by escaping it with a backslash, for example, within a filename surrounded by double quotes, a double quote character should be escaped with a backslash, but a single quote character should not be escaped. Within a single quoted string a single quote character needs to be escaped, but a double quote character does not.
A literal backslash character can also be included by escaping it with a backslash.
Next: Command Options, Previous: Completion, Up: Commands [Contents][Index]