In This Book

Preparing the Target Program

To prepare a target program for debugging, compile the program using the compiler's option for debugging, usually -g. A compiler's debugging option causes it to add information needed by the debugger to the program's object ￿le. For example:

$cc -g average.c

You can ￿nd average.c , a sample program that you can practice on, in the directory /opt/langtools/dde/examples . In that directory, you can also ￿nd sources for average in FORTRAN, C++, and Pascal.

If you attempt to debug a program that was compiled without the debugging option, the debugger displays a message similar to the following:

(Warning) Object file has no debug information. Limited debugging will be available.

Some of the limitations on debugging code compiled without the -goption are: You can access the values of global variables but not their descriptions.

Line numbers are not available in the Assembly Instructions dialog box.

You can set breakp oints on entry points using procedure names, entry point names, and virtual addresses. However, if some modules were compiled with -gand some were compiled without -g, you must use the initialize -altdbinfocommand to set breakpoints on those modules compiled without -g. (Use of the initialize -altdbinfocommand is not necessary on Solaris systems.)

The debugger will not automatically display source code. You can use the use source command to display source code. However, you cannot follow program execution or invoke debugger commands in the source ￿le display area.

Shared libraries, whic h are often compiled without -g, are a special case. See \Debugging Shared Libraries" in Chapter 8 for more information.

2-2 Compiling, Loading, and Executing the Target Program