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
debugging.
set cwd
[directory]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 ~ in directory is a short for the
home directory, usually pointed to by the HOME environment
variable. On MS-Windows, if HOME is not defined, gdb
uses the concatenation of HOMEDRIVE and HOMEPATH as
fallback.
You can also change gdb's current working directory by using
the cd
command.
See cd command.
show cwd
cd
[directory]The gdb working directory serves as a default for the commands that specify files for gdb to operate on. See Commands to Specify Files. See set cwd command.
pwd
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
the info proc
command (see Process Information), you can
use the info proc
command to find out the
current working directory of the debuggee.