Debugging with GDB Manual (5900-1473; WDB 6.2; January 2011)

Table Of Contents
On non-Unix systems, the program is usually invoked directly by GDB, which emulates
I/O redirection via the appropriate system calls, and the wildcard characters are
expanded by the startup code of the program, not by the shell.
The run command used with no arguments uses the same arguments used by the previous
run, or those set by the set args command.
Following commands are used to pass the argument values to your program:
set args Specify the arguments to be used the next time your program is run. If
set args has no arguments, run executes your program with no
arguments. Once you have run your program with arguments, using set
args before the next run is the only way to run it again without
arguments.
show args Show the arguments to give your program when it is started.
4.4 Program Environment
The environment consists of a set of environment variables and their values. Environment
variables conventionally record information such as your user name, your home directory,
your terminal type, and your search path for programs to run. Usually you set up
environment variables with the shell and they are inherited by all the other programs you
run. When debugging, it can be useful to try running your program with a modified
environment without having to start GDB over again.
show envvar List all the environment variables used by GDB.
show paths Display the list of search paths for executables
(the PATH environment variable).
show environment [varname] Print the value of environment variable varname
to be given to your program when it starts. If you
do not supply varname, print the names and
values of all environment 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
4.4 Program Environment 37