Go to main content
Oracle® Developer Studio 12.5: Debugging a Program with dbx

Exit Print View

Updated: June 2016
 
 

Macros

By default, selected expressions are macro expanded before being evaluated, including expressions you specify with the print, display, and watch commands; the –if option of the stop, trace, and when commands; and the $[] construct. Macro expansion is also applied to balloon evaluation and watches in the IDE or dbxtool.

Additional Uses of Macro Expansion

Macro expansion is applied to both the variable and the expression in an assign command.

In the call command, macro expansion is applied to the name of the function being called as well as to the parameters being passed.

The macro command takes any expression and macro and expands the macro. For example:

(dbx) macro D(1, 2)
    Expansion of: D(1, 2)
              is: d(1,2)

If you give the whatis command a macro, it shows the macro's definition. For example:

(dbx) whatis B
    #define B(x) b(x)

If you give the which command a macro, it shows where the macro that is currently active in the scope is defined. For example:

(dbx) which B2
    `a.out`macro_wh.c`B2    # defined at defs2.h:3
            # included from defs1.h:3
            # included from macro_wh.c:23

If you give the whereis command a macro, it shows all of the places where the macro has been defined. The list is limited to modules for which dbx has already read debugging information. For example:

(dbx) whereis U
    macro:          U       # defined at macro_wh.c:21
    macro:          U       # undefined at defs1.h:5

The dbxenv variable macro_expand controls whether these commands expand macros. It is set to on by default.

In general, the +m option in dbx commands causes the commands to bypass macro expansion. The –m option forces macro expansion even if the dbxenv variable macro_expand is set to off. An exception is the –m option within the $[] construct, where –m only causes macros to be expanded, with no evaluation taking place. This exception facilitates macro expansion in shell scripts.