Using Macros
A macro is a C-like function consisting of debugger commands and C
statements and expressions.
Macros are most often used to:
•
Patch C source code.
Often, bugs found with the debugger can be temporarily patched with C
source statements in macros. You do not have to exit the debugger, edit
the source code, recompile and link, and then reenter the debugger.
Instead, you can make a temporary patch by using breakpoint macros.
•
Return values to expressions.
•
Create conditional breakpoints.
•
Execute commands after each program step command.
•
Execute a set of commands.
Macros can:
•
Have input parameters (macro arguments).
•
Define macro local variables.
•
Contain C statements and expressions.
•
Refer to target variables and registers.
•
Refer to user-defined variables.
•
Have return values.
•
Call other macros.
•
Can be used in expressions (if they return values).
•
Execute most debugger commands.
Macros cannot:
•
Define global variables.
•
Define static variables.
•
Be recursive.
•
Define other macros.
•
Contain the conditional operator (expression ? expression : expression).
Macros can be called:
•
By specifying the macro name in an expression.
•
By calling the macro from within another macro.
•
With the Debugger Macro Call command.
•
With the Breakpt command.
•
With the Program Step With_Macro command.
Chapter 6: Using Macros and Command Files
Using Macros
187