HP (Hewlett-Packard) 5992-4701 Computer Hardware User Manual


 
4 Running Programs Under GDB
When you run a program under GDB, you must first generate debugging information
when you compile it using compiler option cc -g -O.
You may start GDB with its arguments, if any, in an environment of your choice. If
you are doing native debugging, you may redirect your program's input and output,
debug an already running process, or kill a child process.
4.1 Compiling for debugging
Following points are noteable while compiling programs for debugging:
Compile your program with the -g-O option to generate debugging information.
The -g-O option is supported by HP ANSI C and HP aC++ compilers and GNU
gcc compiler.
Some compilers do not support the -g-O options together.
The -g-O options do not work on machines with instruction scheduling.
NOTE: Older versions of the GNU C compiler permitted a variant option '-gg' for
debugging information. GDB no longer supports this format; if your GNU C compiler
has this option, do not use it.
4.2 Starting your program
run,
r
Use the run command to start your program under GDB. You must first specify
the program name (except on VxWorks) with an argument to GDB (see Chapter 2
(page 25)), or by using the file or exec-file command (see “Commands
to specify files” (page 125)).
NOTE: If you are running your program in an execution environment that supports
processes, run creates an inferior process and makes that process run your program.
(In environments without processes, run jumps to the start of your program.)
The execution of a program is affected by the information it receives from the parent
process. You must provide GDB the information before starting the program. (You can
change the information after starting your program, but such changes only affect your
program the next time you start it.) The information that must be passed to GDB can
be categorized into four categories:
arguments.
Specify the arguments to give your program as
the arguments of the run command. If a shell 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
4.1 Compiling for debugging 39