Your Program's Arguments - Red Hat ENTERPRISE LINUX 4 - DEBUGGING WITH GDB Manual

Debugging with gdb
Hide thumbs Also See for ENTERPRISE LINUX 4 - DEBUGGING WITH GDB:
Table of Contents

Advertisement

26
If you are running your program in an execution environment that supports processes,
inferior process and makes that process run your program. (In environments without processes,
jumps to the start of your program.)
The execution of a program is affected by certain information it receives from its superior. gdb pro-
vides ways to specify this information, which you must do before starting your program. (You can
change it after starting your program, but such changes only affect your program the next time you
start it.) This information may be divided into four categories:
The arguments.
Specify the arguments to give your program as the arguments of the
is available on your target, the shell is used to pass the arguments, so that you may use normal
conventions (such as wildcard expansion or variable substitution) in describing the arguments. In
Unix systems, you can control which shell is used with the
to Section 6.3 Your program's arguments.
The environment.
Your program normally inherits its environment from gdb, but you can use the gdb commands
set environment
your program. Refer to Section 6.4 Your program's environment.
The working directory.
Your program inherits its working directory from gdb. You can set the gdb working directory
with the
command in gdb. Refer to Section 6.5 Your program's working directory.
cd
The standard input and output.
Your program normally uses the same device for standard input and standard output as gdb is
using. You can redirect input and output in the
command to set a different device for your program. Refer to Section 6.6 Your program's input
and output.
Warning: While input and output redirection work, 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.
When you issue the
7 Stopping and Continuing 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
Refer to Chapter 10 Examining Data.
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.

6.3. Your program's arguments

The arguments to your program can be specified by the arguments of the
passed to a shell, which expands wildcard characters and performs redirection of I/O, and thence to
your program. Your
SHELL
not define
, gdb uses the default shell (
SHELL
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.
and
unset environment
command, your program begins to execute immediately. Refer to Chapter
run
environment variable (if it exists) specifies what shell gdb uses. If you do
Chapter 6. Running Programs Under gdb
SHELL
to change parts of the environment that affect
command line, or you can use the
run
on Unix).
/bin/sh
creates an
run
command. If a shell
run
environment variable. Refer
or
commands.
print
call
command. They are
run
run
tty

Advertisement

Table of Contents
loading

Table of Contents