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

Download:
Devel-Trepan-0.42.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source   Latest Release: Devel-Trepan-0.58

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 array reference to a list of strings. The string in both cases are strings of debugger commands. If the return is a string, 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 instead, a reference to a list of strings is returned, 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 info macro.

syntax highlighting: