HPlogo System Debug Reference Manual > Chapter 6 System Debug Command Specifications M-X

MACTRACE

MPE documents

Complete PDF
Table of Contents
Index

E0201 Edition 4 ♥
E0300 Edition 3
E0692 Edition 3

Controls the "tracing" of macro execution.

Syntax



   MACTRACE pattern [level]

It is possible to enable/disable the observation of entry/exit of macros, along with input parameter values and functional return values.

Parameters


pattern

The name(s) of the macro(s) that are to be traced.

This parameter can be specified with wildcards or with a full regular expression. Refer to appendix A for additional information about pattern matching and regular expressions.

The following wildcards are supported:

@

Matches any character(s).

?

Matches any alphabetic character.

#

Matches any numeric character.

The following are valid name pattern specifications:
@

Matches everything; all names.

pib@

Matches all names that start with "pib".

log2##4

Matches "log2004", "log2754", and so on.

The following regular expressions are equivalent to the patterns with wildcards that are listed above:

   `.*`
   `pib.*`
   `log2[0-9][0-9]4`

level

The level of macro "tracing" detail.

Four increasing levels are supported:

1

All tracing is disabled. (Default)

2

Macro entry is displayed.

3

Macro entry and exit are displayed.

4

Macro entry, input parameter values, macro exit, and functional return values are displayed.

Examples



   $nmdat > macl @ all
   macro driver
      machelp = 'This macro calls macros "triple", "min",  and ' +
                ' "inc" in order to demonstrate the MACECHO,' +
                ' MACREF, and MACTRACE commands'
   { loc one 1;
     loc two 2;
     wl min ( triple(two) inc(one) )
   }
   macro inc
    ( num : ANY  )
      machelp = 'returns the increment of "num"'
   { loc temp num;
     loc temp temp + 1;
     return temp
   }
   macro min
    ( parm1 : ANY  ,
      parm2 : ANY  )
      machelp = 'returns the min of "parm1" or "parm2"'
   { if parm1 < parm2
     then return parm1
     else return parm2
   }
   macro triple
    ( input : ANY  )
      machelp = 'triples the parameter "input"'
   { return input *3
   }

Assume that the macros listed above have been defined. A few of the macros use local variables inefficiently, for the purpose of demonstration.

   $nmdat > driver
   $2

Macros normally execute silently, as they invoke commands, and often other macros. In this example, macro driver is invoked, and this macro calls several other macros. Since macro tracing is not enabled for any of these macros, execution proceeds silently.

   $nmdat > mactrace inc 3
   $nmdat > driver
   --> enter macro: inc
   --> parms macro: inc
    ( num : ANY = $1  )
   <-- exit  macro: inc  : U16 = $2
   $2

The MACTRACE command is used to enable macro tracing for macro inc at trace level 3. Now, every time macro inc is invoked, trace information is displayed. Since the trace level for this macro is set to level 3, entry into the macro is displayed, along with the parameter value(s) at entry, and exit from the macro is displayed, along with the function return value.

   $nmdat > macl @ trace
   macro inc  trace = 3

The MACLIST command is used to display all macros that have tracing enabled (level >= 1). Macro inc is shown to have tracing enabled at level 3.

   $nmdat > mactrace @ 3
   $nmdat > driver
   --> enter macro: driver
   --> enter macro: min
   --> enter macro: triple
   --> parms macro: triple
    ( input : ANY = $2  )
   <-- exit  macro: triple  : U16 = $6
   --> enter macro: inc
   --> parms macro: inc
    ( num : ANY = $1  )
   <-- exit  macro: inc  : U16 = $2
   --> parms macro: min
    ( parm1 : ANY = $6  ,
      parm2 : ANY = $2  )
   <-- exit  macro: min  : U16 = $2
   $2
   <-- exit  macro: driver

In this example, macro tracing is set to level 3 for all macros.

   $nmdat > mactrace @

Tracing is disabled for all macros.

Limitations, Restrictions


none




MACREF


MAP