You can use the string '$cwd' to refer to whatever is the current working directory at the time GDB searches the path. If you use '.' instead, it refers to the directory where you executed the path command. GDB replaces '.' in the directory argument (with the current path) before adding directory to the search path.

4.5 Working directory

Each time you start your program with run, it inherits its working directory from the current working directory of GDB. The GDB working directory is initially whatever it inherited from its parent process (typically the shell), but you can specify a new working directory in GDB with the cd command.

The GDB working directory also serves as a default for the commands that specify files for GDB to operate on. See “Commands to specify files” (page 125).

Following commands are used to set the working directory for your program:

cd directory Set the GDB working directory to directory.

pwd

Print the GDB working directory.

4.6 Program Input and Output

By default, the program you run under GDB does input and output to the same terminal that GDB uses. GDB switches the terminal to its own terminal modes to interact with you, but it records the terminal modes your program was using and switches back to them when you continue running your program.

Following commands are used for redirecting the input and output:

info terminal

Displays information recorded by GDB about the terminal modes

 

your program is using.

tty

Another way to specify where your program should do input

 

and output is with the tty command. This command accepts a

 

file name as argument, and causes this file to be the default for

 

future run commands. It also resets the controlling terminal for

 

the child process, for future run commands. For example,

 

tty /dev/ttyb

 

directs that processes started with subsequent run commands

 

default to do input and output on the terminal '/dev/ttyb' and

 

have that as their controlling terminal.

4.5 Working directory

43