1.5.2. Macro body

The macro body consists of the source lines of the macro and optional formal arguments. You can have multiple statements on a single line, but a single statement must not be split across multiple lines.

The syntax of a macro body is as follows:

[local_definitions]
macro_statement;[macro_statement;]...

where:

local_definitions

defines variables used locally in the macro body.

Formal arguments can be used throughout the macro body. These arguments are later replaced by the values of the actual arguments in the macro call.

Using CLI commands in a macro

You can use debugger commands in the macro body. If used, you must enclose the command with dollar signs ($) and end in a semi-colon (;), and the command must not be split across multiple lines, for example:

last_time = @cycle;
value = base[offset];
base[offset] = 0;
$printf "base offset value=%d\n",value$;

You can substitute the value of an integer variable in a CLI command before the command is executed. A format specifier can also be included:

d

decimal format

h or x

hexadecimal format (this is the default).

The syntax for variable substitution is ${variable[:format]}.

For example:

define /R int tstMacro()
{
    int num;
    num = 1;
    $FOPEN 150, "C:\\myfiles\\myfile${num:d}.txt"$; // substitution
    $FPRINTF 150, "Test value: %d", num$;
    $VCLOSE 150$;
}
.

The filename in this example is myfile1.txt. The text written to the file is "Test value: 1".

You can also use macro arguments and local variables in RealView Debugger commands.

Commands prohibited inside a macro

RealView Debugger prohibits the use of the following commands inside a macro:

  • BOARD

  • CONNECT

  • DEFINE (unless it is the macro definition itself)

  • DELFILE

  • DISCONNECT

  • GOSTEP

  • HELP

  • HOST

  • INCLUDE

  • LOAD

  • QUIT

  • UNLOAD.

Also you cannot use execution-type commands (for example, STEP) in a macro if you attach the macro to another entity, such as a breakpoint.

See also

Copyright © 2002-2011 ARM. All rights reserved.ARM DUI 0175N
Non-ConfidentialID052111