In This Book

Creating Alias and Define Macros

You can use the alias and define commands to create two types of macros:

An alias macro serves as a synonym for one or more debugger commands. The debugger expands alias macros only when the macro is at the beginning of a command line, or when the macro follows a semicolon in a line of commands.

A de￿ne macro serves as a synonym for any string of text, including debugger commands. The debugger always expands a de￿ne macro no matter what position the macro occupies in a command line.

For example, consider the following series of commands:

alias show print

 

alias ali_X total

5

define def_X total

 

show ali_X

 

"ali_X" not found in current environment.

 

show def_X

 

total: 20

 

The alias commands create show as a synonym for the print command, and

 

ali_X as a synonym for the variable total. The define command also creates

 

a synonym for total , but gives it the name def_X.

 

The debugger does not expand ali_X in the command show ali_X since ali_X

 

does not appear at the beginning of the line and it does not follow a semicolon.

 

However, the debugger does expand def_X since de￿ne macros can appear

 

anywhere on the command line. Also, since the alias show appears ￿rst in both

 

of the last two command lines, the debugger expands show in both cases.

 

The debugger expands macros from left to righ t in the command line. Upon

 

￿nding a macro with argumen ts, the debugger inserts the argumen ts into the

 

macro de￿nition. Then the debugger rescans the command line, starting from

 

where it found the macro.

 

You can de￿ne macros in terms of other macros and nest them. Note that

 

macros cannot be recursiv e.

 

Using Debugger Commands 5-9