Next: Input/Output, Previous: Environment, Up: Running [Contents][Index]
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]
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 ~ 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
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.
cd [directory]
Set the GDB working directory to directory. If not given, directory uses '~'.
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
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
the info proc
command (see Process Information), you can
use the info proc
command to find out the
current working directory of the debuggee.
Next: Input/Output, Previous: Environment, Up: Running [Contents][Index]