Working Directory (Debugging with ROCGDB)

Next: Input/Output, Previous: Environment, Up: Running [Contents][Index]

### 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 ROCGDB’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 ROCGDB’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, ROCGDB uses the concatenation of `HOMEDRIVE` and `HOMEPATH` as fallback.

  You can also change ROCGDB’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 ROCGDB’s working directory.

`cd [directory]`

  Set the ROCGDB working directory to directory. If not given, directory uses `'~'`.

  The ROCGDB working directory serves as a default for the commands that specify files for ROCGDB to operate on. See Commands to Specify Files. See set cwd command.

`pwd`

  Print the ROCGDB 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 ROCGDB 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]