gdb: Working Directory

 
 4.5 Your Program's Working Directory
 ====================================
 
 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.  Seecd 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.  SeeCommands to Specify
      Files Files.  Seeset 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 (SeeProcess Information), you can use the 'info proc'
 command to find out the current working directory of the debuggee.