Debugging with GDB Manual The GNU Source-Level Debugger (769148-001, March 2014)

variables are just strings, and any interpretation is supplied
by your program itself. The value parameter is optional; if
it is eliminated, the variable is set to a null value.
For example, this command:
set env USER = foo
tells the debugged program, when subsequently run, that
its user is named 'foo'. (The spaces around '=' are used
for clarity here; they are not actually required.)
unset environment varname Remove variable varname from the environment to be
passed to your program. This is different from 'set env
varname ='; unset environment removes the
variable from the environment, rather than assigning it an
empty value.
path directory Add directory to the front of the PATH environment
variable (the search path for executables), for both GDB
and your program. You may specify several directory names,
separated by whitespace or by a system-dependent
separator character (`:' on Unix, `;' on MS-DOS and
MS-Windows). If directory is already in the path, it is
moved to the front, so it is searched sooner.
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.
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 88).
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.
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
30 Running Programs Under GDB