-g
Category
@PROCESS
DBGPurpose
Generates debugging information for use by a symbolic debugger, and makes the program state available to the debugging session at selected source locations.
You can use different -g levels to balance between debug capability and compiler optimization. Higher -g levels provide a more complete debug support, at the cost of runtime or possible compile-time performance, while lower -g levels provide higher runtime performance, at the cost of some capability in the debugging session.
-g is the short form of -qdbg.
Syntax
.-0-. >>- -g--+---+-------------------------------------------------->< +-1-+ +-2-+ +-3-+ +-4-+ +-5-+ +-6-+ +-7-+ +-8-+ '-9-'
@PROCESS:
@PROCESS DBG | NODBG
Defaults
-g0, equivalent to -qnodbg
Parameters
- -g
- When no optimization is enabled (-qnoopt), -g is equivalent to -g9 or -qdbg=level=9.
- When the -O2 optimization level is in effect, -g is equivalent to -g2 or -qdbg=level=2.
- -g0
- Generates no debugging information. No program state is preserved.
- -g1
- Generates minimal read-only debugging information about line numbers and source file names. No program state is preserved. This option is equivalent to -qlinedebug.
- -g2
- Generates read-only debugging information about line numbers,
source file names, and variables.
When the -O2 optimization level is in effect, no program state is preserved.
- -g3, -g4
- Generates read-only debugging information about line numbers,
source file names, and variables. When the -O2 optimization level is in effect:
- No program state is preserved.
- Procedure parameter values are available to the debugger at the beginning of each procedure.
- -g5, -g6, -g7
- Generates read-only debugging information about line numbers,
source file names, and variables. When the -O2 optimization level is in effect:
- Program state is available to the debugger at IF constructs, loop constructs, procedure definitions, and procedure calls. For details, see Usage.
- Procedure parameter values are available to the debugger at the beginning of each procedure.
- -g8
- Generates read-only debugging information about line numbers,
source file names, and variables. When the -O2 optimization level is in effect:
- Program state is available to the debugger at the beginning of every executable statement.
- Procedure parameter values are available to the debugger at the beginning of each procedure.
- -g9
- Generates debugging information about line numbers, source file
names, and variables. You can modify the value of the variables in
the debugger. When the -O2 optimization level is in effect:
- Program state is available to the debugger at the beginning of every executable statement.
- Procedure parameter values are available to the debugger at the beginning of each procedure.
Usage
When no optimization is enabled, the debugging information is always available if you specify -g2 or a higher level. When the -O2 optimization level is in effect, the debugging information is available at selected source locations if you specify -g5 or a higher level.
When you specify -g8 or -g9 with -O2, the debugging information is available at every source line with an executable statement.
- IF constructs
The debugging information is available at the beginning of every IF statement, namely at the line where the IF keyword is specified. It is also available at the beginning of the next executable statement right after the IF construct.
- Loop constructs
The debugging information is available at the beginning of every DO statement, namely at the line where the DO keyword is specified. It is also available at the beginning of the next executable statement right after the DO construct.
- Procedure definitions
The debugging information is available at the first executable statement in the body of the procedure.
- Procedure calls
The debugging information is available at the beginning of every statement where a user-defined procedure is called. It is also available at the beginning of the next executable statement right after the statement that contains the procedure call.
Examples
xlf myprogram.f -o testing -g
xlf myprogram.f -O2 -g8