Debugging with GDB Manual (5900-1473; WDB 6.2; January 2011)

Table Of Contents
14.9.1 Viewing and Evaluating Macro Definitions
HP WDB 5.7 and later versions of the debugger provide the following support for de-
bugging macros:
Displaying Macro Definitions
Displaying Macro Definitions HP WDB provides the following commands to display
macro definitions:
- macro show [macro-name] or info macro [macro-name]
Displays the macro definition, source file name, and the line number. For example:
(gdb) info macro VAR2
Defined at scope.c:21
#define VAR2 201
- macro expand [macro-name]
Expands the macro and the parameters in the macro. If there are any parameters
in the macro, they are substituted in the macro definition when the definition is
displayed.
For example:
#define YY 6
#define MAC (67 + YY)
...
$ gdb
...
(gdb) macro expand MAC
expands to: (67 + 6)
Evaluating Macros
HP WDB enables you to evaluate a macro and display the output. You can evaluate
the macro by using the commonly used gdb commands for evaluating and displaying
expressions, such as print. HP WDB supports the evaluation of macros with
variables, constants, complex algebraic expressions involving variables, nested
macros, and function calls. HP WDB does not support the evaluation of macros with
multiple statements in the macro definitions, or the evaluation of macros with
stringifying and pasting tokens in the macro definitions.
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:
14.9 Debugging Macros 147