- publishing free software manuals
An Introduction to GCC - for the GNU compilers gcc and g++
by Brian J. Gough, foreword by Richard M. Stallman
Paperback (6"x9"), 144 pages
ISBN 0954161793
RRP £12.95 ($19.95)

"A wonderfully thorough guide... well-written, seriously usable information" --- Linux User and Developer Magazine (Issue 40, June 2004) Get a printed copy>>>

5 Compiling for debugging

Normally, an executable file does not contain any references to the original program source code, such as variable names or line-numbers--the executable file is simply the sequence of machine code instructions produced by the compiler. This is insufficient for debugging, since there is no easy way to find the cause of an error if the program crashes.

GCC provides the -g debug option to store additional debugging information in object files and executables. This debugging information allows errors to be traced back from a specific machine instruction to the corresponding line in the original source file. The execution of a program compiled with -g can also be followed in a debugger, such as the GNU Debugger gdb (for more information, see "Debugging with GDB: The GNU Source-Level Debugger", section Further reading). Using a debugger allows the values of variables to be examined while the program is running.

The debug compilation option works by storing the names and source code line-numbers of functions and variables in a symbol table in the object file or executable.

ISBN 0954161793An Introduction to GCC - for the GNU compilers gcc and g++See the print edition