Debugging with GDB Manual HP WDB v6.3 (5900-2180, August 2012)
14.9.1.1 Compiler Options to Enable Macro Debugging
To enable macro debugging, the program must be compiled with the
+macro_debug=[all|none|ref] compiler option.
Additionally, the program must be compiled with one of the -g options (-g, -g0, or -g1) to enable
macro debugging. For example:
cc -g +macro_debug=all -o sample sample.c
The following options are available for the +macro_debug compiler option:
all To view and evaluate all the macro expressions in the program, you must compile the
program with +macro_debug=all. This option can cause a significant increase in object
file size.
ref To view and evaluate only the reference macros in the program, you must compile the
program with +macro_debug=ref. This is the default for -g, -g0, or -g1.
none To disable macro debugging, you must compile the program with +macro_ debug=none
The macro debugging features are supported for +objdebug and +noobjdebug compiler options.
14.9.2 Examples for Macro Debugging
The following example illustrates the use of the macro debugging:
Sample Program:
$ cat scope.c
1
2 #include <stdio.h>
3
4 #define USED1 100
5 #define USED2 200
6 #define UNUSED1 0
7 #define UNUSED2 0
8 #define DUMMY1
9 #define DUMMY2
10
11 int
12 main ()
13 {
14
15 int val = USED1;
16
17 #undef UNUSED1
18 #undef USED2
19 #undef USED1
20 #define USED1 101
21 #define USED2 201
22
23 val = USED1 + USED2;
24
25 #undef USED1
26 #undef UNUSED2
27 #undef USED2
28 #define USED1 102
29
30 val = USED1;
31
32 return 0;
33 }
Sample Debugging Session
• The following debugging session illustrates macro debugging when the program is com- piled
with +macro_debug=all option:
118 HP-UX Configuration-Specific Information