Debug compiler options

Compiler options that are relevant to debugging COBOL for AIX and PL/I for AIX programs include:

Table 1. COBOL for AIX and PL/I for AIX debug compiler options
Compiler option Definition
-g Prompts the compiler to generate debug information for the source code. You must specify this option if you intend to debug your code.
-qtest Prompts the compiler to generate debug symbol information for the source code. You must specify this option if you intend to display and alter variables in your code.

Specifying -qtest also implies -g, which generates symbol information in addition to line information.

Note: The -qtest compiler option is relevant to debugging PL/I for AIX programs only.

These compiler options are relevant to debugging IBM XL C/C++ for AIX and IBM XL C/C++ for Linux programs. They are not relevant to debugging COBOL for AIX and PL/I for AIX programs.

Table 2. IBM XL C/C++ for AIX and IBM XL C/C++ for Linux debug compiler options
Compiler option Definition
-g

-g prompts the compiler to generate debug information for the source code. You must specify this option if you intend to debug your code.

The compiler may also support these extended -g levels to reduce executable size or to improve application performance (especially when combined with the -O2 option) while maintaining some level of debuggability:

-g9 provides -g functionality. Modifications to variable values through the debugger will be written to memory and all executable lines will be steppable by the debugger.

-g8 reduces the amount of debug information for variables. Modifications made to variable values through the debugger may not be written back into memory. All executable lines will be steppable by the debugger.

-g5 reduces the amount of debug information for variables. Modifications made to variable values through the debugger may not be written back into application memory. The -g5 option also reduces the amount of debug information saved for executable lines. Only the first executable line of each function and selected control flow statements will be steppable by the debugger. Other lines will appear as non-executable and the debugger will not be able to step through them.

-qfullpath Causes the full name of all source files to be added to the debug information. This can make it easier for the debugger to find source files.
-qheapdebug Forces the resulting program to use the debug heap. If heap corruption occurs, the debugger can detect it and stop at the point where it was detected.
Note: This option is only supported on AIX.
-qlinedebug Suppresses the generation of the debug information that allows you to see variables in your code. This can significantly reduce the size of the resulting executable, particularly for C++ programs. This option is recommended if you have optimized your code, as optimization makes it impossible for the debugger to show variable values reliably.
-qtbtable Controls the generation of a traceback table at the end of all functions. Specifying -qtbtable=none is not recommended if the code is to be debugged.
-qdbxextra Forces the compiler to include debug information for unreferenced types. This is normally not recommended, as it causes the size of the resulting executable to be very large.
Note: This option is only supported on AIX.
-qsmp=noopt By default, the -qsmp option will apply optimizations to the outlined functions (the code in the parallel regions). These optimizations produce a mismatch between the program and the debug information, and cause the debugger to display incorrect values for both private and shared local variables when executing the outlined code. Using -qsmp=noopt, instead of -qsmp, will disable those optimizations and make it easier to debug the parallel regions.

Feedback