D-12
Motorola DSP56000 Family Optimizing C Compiler User’s Manual
For More Information On This Product,
Go to: www.freescale.com
Motorola
Compiling Your Program for Debugging
D.4 Compiling Your Program for Debugging
In order to debug a program effectively, you need to ask for debugging information when
you compile it. This information in the object file describes the data type of each variable
or function and the correspondence between source line numbers and addresses in the
executable code.
To request debugging information, specify the ‘-g’ option when you run the compiler.
The Unix C compiler is unable to handle the ‘-g’ and ‘-O’ options together. This means
that you cannot ask for optimization if you ask for debugger information.
The GNU C compiler supports ‘-g’ with or without ‘-O’, making it possible to debug
optimized code. We recommend that you always use ‘-g’ whenever you compile a
program. You may think the program is correct, but there’s no sense in pushing your luck.
GDB no longer supports the debugging information produced by giving the GNU C
compiler the ‘-gg’ option, so do not use this option.
D.5 Running Your Program Under GDB
To start your program under GDB, use the ‘run’ command. The program must already
have been specified using the ‘exec-file’ command or with an argument to GDB (see
section Files); what ‘run’ does is create an inferior process, load the program into it, and
set it in motion.
The execution of a program is affected by certain information it receives from its superior.
GDB provides ways to specify this information, which you must do before starting the
program. (You can change it after starting the program, but such changes do not affect the
program unless you start it over again.) This information may be divided into three
categories:
info files
Print the names of the executable and core dump files currently in use by GDB,
and the file from which symbols were loaded.
While all three file-specifying commands allow both absolute and relative file
names as arguments, GDB always converts the file name to an absolute one
and remembers it that way.
The ‘symbol-file’ command causes GDB to forget the contents of its
convenience variables, the value history, and all breakpoints and auto-display
expressions. This is because they may contain pointers to the internal data
recording symbols and data types, which are part of the old symbol table data
being discarded inside GDB.
Table D-1. GDB File Commands
Command
Description
F
Freescale Semiconductor, Inc.
n
.