Each time you start your program with
run, the inferior will be
initialized with the current working directory specified by the
set cwd command. If no directory has been specified by this
command, then the inferior will inherit GDB’s current working
directory as its working directory if native debugging, or it will
inherit the remote server’s current working directory if remote
set cwd [directory]
Set the inferior’s working directory to
directory, which will be
glob-expanded in order to resolve tildes (
~). If no
argument has been specified, the command clears the setting and resets
it to an empty state. This setting has no effect on GDB’s
working directory, and it only takes effect the next time you start
the inferior. The
directory is a short for the
home directory, usually pointed to by the
variable. On MS-Windows, if
HOME is not defined, GDB
uses the concatenation of
You can also change GDB’s current working directory by using
See cd command.
Show the inferior’s working directory. If no directory has been specified by set cwd, then the default inferior’s working directory is the same as GDB’s working directory.
Set the GDB working directory to
directory. If not
Print the GDB working directory.
It is generally impossible to find the current working directory of
the process being debugged (since a program can change its directory
during its run). If you work on a system where GDB supports
info proc command (see Process Information), you can
info proc command to find out the
current working directory of the debuggee.