Rocky Bernstein > Devel-Trepan > Devel::Trepan::CmdProcessor::Command::Macro

Download:
Devel-Trepan-0.58.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

Synopsis:

macro macro-name sub { ... }

Define macro-name as a debugger macro. Debugger macros get a list of arguments which you supply without parenthesis or commas. See below for an example.

The macro (really a Perl anonymous subroutine) should return either a string or an list reference to a list of strings. Each string is a debugger command.

If a single string is returned, that gets tokenized by a simple split(/ /, $string). Note that macro processing is done right after splitting on ;; so if the macro returns a string containing ;; this will not be handled on the string returned.

If a reference to a list of strings is returned instead, then the first string is shifted from the array and executed. The remaining strings are pushed onto the command queue. In contrast to the first string, subsequent strings can contain other macros. Any ;; in those strings will be split into separate commands.

Examples:

The below creates a macro called fin+ which issues two commands finish followed by step:

 macro fin+ sub{ ['finish', 'step']}

If you wanted to parameterize the argument of the finish command you could do it this way:

  macro fin+ sub{ \
                  ['finish', 'step ' . (shift)] \
                }

Invoking with:

  fin+ 3

would expand to ["finish", "step 3"]

If you were to add another parameter, note that the invocation is like you use for other debugger commands, no commas or parenthesis. That is:

 fin+ 3 2

rather than fin+(3,2) or fin+ 3, 2.

See also:

alias, and info macro.

syntax highlighting: