Debugging a Program With dbx

Debugging Optimized Code

dbx provides partial debugging support for optimized code. The extent of the support depends largely upon how you compiled the program.

When analyzing optimized code, you can:

However, with optimized code, dbx cannot:

Compiling with the -g Option

To use dbx effectively, a program must have been compiled with the -g or -g0 option. The -g option instructs the compiler to generate debugging information during compilation.

For example, to compile using C++:


% CC -g example_source.cc

To compile optimized code for use with dbx, compile the source code with both the -O (uppercase letter O) and the -g options.

C++ Support and the -g0 Option

In C++, -g turns on debugging and turns off inlining of functions. The -g0 (zero) option turns on debugging and does not affect inlining of functions. You cannot debug inline functions with the -g0 option. The -g0 option can significantly decrease link time and dbx start-up time (depending on the use of inlined functions by the program).

Code Compiled Without the -g Option

While most debugging support requires that a program be compiled with -g, dbx still provides the following level of support for code compiled without -g:

Note, however, that dbx cannot display source code unless the code was compiled with the -g option. This also applies to code that has had strip -x applied to it.

Shared Libraries Need -g for Full dbx Support

For full support, a shared library must also be compiled with the -g option. If you build a program with some shared library modules that were not compiled with -g, you can still debug the program. However, full dbx support is not possible because the information was not generated for those library modules.

Completely Stripped Programs

dbx can debug programs that have been completely stripped. These programs contain some information that can be used to debug your program, but only externally visible functions are available. Runtime Checking cannot work on stripped programs or load objects.