-g
Category
Pragma equivalent
None.
Purpose
Generates debugging information for use by a symbolic debugger, and makes the program state available to the debugging session at selected source locations.
Program state refers to the values of user variables at certain points during the execution of a program.
You can use different -g levels to balance between debug capability and compiler optimization.
Defaults
If -g is not specified, -g0 takes effect.
If -g is specified, the default value is -g2.
Parameters
- -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 or higher optimization level is in effect, no program state is preserved.
Usage
When you specify -g with -fstandalone-debug, the compiler generates the debugging information for all symbols whether or not these symbols are referenced by the program. When you specify -g with -fno-standalone-debug, the compiler generates debugging information only for symbols that are referenced by the program.
Examples
xlc myprogram.c -o testing -g



