Setting up Debugging Support
All CAPS universe components can deal with three level of debug configuration:
- no debug related configure option
- --disable-debug configure option
- --enable-debug configure option
No Debug related Option
This configuration is called 'passive' here. It is basically the disabled debugging configuration with some exceptions:
- symbol DEBUG is defined, symbol NDEBUG isn't defined
- all caps_print_debug() messages are still included in the binaries
- stack traces are still enabled but mostly useless or empty (my experience)
- Attention
- If debugging in libcapsbase is disabled, all other components are affected as well and vice versa. It is important to build all components with the same settings.
Disable Debug entirely
When configuring with --disable-debug the following settings are active
- code optimization is enabled (autotools default: -O2)
- in libraries all internal symbols are hidden
- compiler built-ins are enabled
- stack traces are disabled
- stack protection is enabled
- inlining code is enabled
- the
FORTIFY_SOURCE feature is enabled
- all caps_print_debug() messages are removed from the binaries
- debug symbols are still kept in the binaries
- symbol NDEBUG is defined, symbol DEBUG isn't defined
With this configuration you still can use gdb to trace your program. But my experience is, its hard to do so.
Enable full Debug
- code optimization is disabled (-O0 or if supported by the compiler: -Og)
- in libraries all internal symbols are externally visible
- compiler built-ins are disabled
- stack traces are enabled
- stack protection is disabled
- inlining code is disabled
- unwind tables are enabled to have meaningful stack traces
- the
FORTIFY_SOURCE feature is disabled
- all caps_print_debug() messages are included in the binaries
- debug symbols are available in the binaries
- symbol DEBUG is defined, symbol NDEBUG isn't defined
With this configuration you can use gdb to trace your program in a useful manner. Stack traces are meaningful and thus, helpful as well.
Refer CAPS universe early verbosity setup as well
Overwriting settings
As intended by the autotools, you can add your own flags be defining the environment variables CPPFLAGS, CFLAGS, LDFLAGS and LIBS when configuring the package.
The variables content is always appended to the settings. With this feature you can still overwrite these settings as needed.
There is one exception: The -O2 optimization gets always removed if debugging is enabled.