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:
Stop execution at the start of any function (stop in function command)
Evaluate, display, or modify arguments
Evaluate, display, or modify global or static variables
However, with optimized code, dbx cannot:
Single-step from one line to another (next or step command)
Evaluate, display, or modify local variables
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.
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).
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:
Backtrace (dbx where command)
Calling a function (but without parameter checking)
Checking global variables
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.
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.
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.