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

Table Of Contents
variable substitution) in describing the arguments.
On Unix systems, you can control which shell is
used with the SHELL environment variable. GDB
uses the C shell (/usr/bin/csh). See
Arguments To Your Program” (page 36).
environment. Your program inherits its environment from GDB.
However, you can use the GDB commands set
environment and unset environment to
change parts of the environment that affect your
program. See“Program Environment” (page 37).
working directory. Your program inherits its working directory from
GDB. You can set the GDB working directory with
the cd command in GDB. See“Working directory”
(page 38).
standard input and output. Your program as default uses the same device for
standard input and standard output as GDB is
using. You can redirect input and output in the
run command line, or you can use the tty
command to set a different device for your
program. See “Program Input and Output”
(page 38).
WARNING! You can redirect input and output,
but you cannot use pipes to pass the output of the
program you are debugging to another program;
if you attempt this, GDB is likely to wind up
debugging the wrong program.
NOTE:
When you issue the run command, your program begins to execute immediately.
See Chapter 5 (page 46), for discussion of how to arrange for your program to
stop. Once your program has stopped, you may call functions in your program,
using the print or call commands. See Chapter 8 (page 76).
If the modification time of your symbol file has changed since the last time GDB
read its symbols, GDB discards its symbol table, and reads it again. When it does
this, GDB tries to retain your current breakpoints.
4.3 Arguments To Your Program
The arguments to your program can be specified by the arguments of the run command.
On HP-UX, they are passed to the C shell (/usr/bin/csh), which expands wildcard
characters and performs redirection of I/O, and then to your program.
36 Running Programs Under GDB