-g

Category

Error checking and debugging

@PROCESS

DBG

Purpose

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.

When the -O2 optimization level is in effect, the debug capability is completely supported.
Note: When an optimization level higher than -O2 is in effect, the debug capability is limited.

-g is the short form of -qdbg.

Syntax

Read syntax diagramSkip visual syntax diagram
        .-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.

When you specify -g5, -g6, or -g7 with -O2, the debugging information is available for the following language constructs:

Examples

Use the following command to compile myprogram.f and generate an executable program called testing for debugging:
xlf myprogram.f -o testing -g 
The following command uses a specific -g level with -O2 to compile myprogram.f and generate debugging information:
xlf myprogram.f -O2 -g8 

Related information