Debugging with GDB Manual HP WDB v6.3 (5900-2180, August 2012)
variables to be given to your program. You can abbreviate
environment as env.
set environment varname
[=value]
Set environment variable varname to value. The value
changes for your program only, not for GDB itself. The
value may be any string; the values of environment
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.
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 95).
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.
4.5 Working directory 33