| |||
| Home > RealView Debugger Commands > Alphabetical command reference > DEFINE | |||
The DEFINE command creates a macro for use by other RealView Debugger components.
Because a macro definition requires multiple lines, you cannot use the DEFINE command from the RealView Debugger command prompt. Instead, you must either:
Use the macro command GUI. See the macros chapter in the RealView Developer Kit v2.2 Debugger User Guide for more information.
Write your macro definition in a text file and load it into RealView Debugger using the INCLUDE command (see Macro language).
DEFINE [/R] [ return_type] macro_name ([parameters])[parameter_definitions]
{ macro_body} .
where:
/RThe new macro can replace an existing symbol with the same name.
return_typeSpecifies the return type of the macro. If a type
is not specified, defaults
to typereturn_type int.
macro_nameSpecifies the name of the macro.
parametersLists parameters (comma-separated list within parentheses). These parameters can be used throughout the macro definition and are later replaced with the values of the actual parameters in the macro call.
param_definitionsDefines the types of the variables in .
If types are not specified, the default type parameter_listint is
assumed.
macro_bodyRepresents the contents of the macro, and is split
over many lines. The syntax for is:macro_body
[local_definitions]macro_statement;[macro_statement;] ...
are
the variables used within the local_definitionsmacro_body.
A is
any legal C statement except switch and goto statements, or a debugger
command. If macro_statement is
a debugger command, it must start with a dollar sign (macro_statement$)
and end with a dollar sign and a semicolon ($;).
All statements are terminated by a semicolon.
The macro_body ends with a line containing
only a period (full stop).
The definition contains a macro name, the parameters passed to the macro, the source lines of the macro, and a terminating period as the first and only character on the last line.
After a macro has been loaded into RealView Debugger, the definition is stored in the symbol table. If the symbol table is recreated, for example when an image is loaded with symbols, any macros are automatically deleted. The number of macros that can be defined is limited only by the available memory on your workstation.
Macros can be invoked by name on the command line where the name does not conflict with other commands or aliases and the return value is not required. You can also invoke a macro on the command line using the MACRO command, and in expressions, for example using the CEXPRESSION command.
Macros can also be invoked as actions associated with:
a window, for example VMACRO
a breakpoint, for example BREAKEXECUTION
deferred commands, for example BGLOBAL.
Macros invoked as associated actions cannot execute GO, or GOSTEP, or any of the stepping commands, for example STEPINSTR.
If you require a breakpoint that, when the condition is met,
does something and then continues program execution, you must use
the breakpoint continue qualifier, or return 1 from
the macro call, instead of the GO command. See
the breakpoint command descriptions for more details.
The following examples show how to use DEFINE:
define float square(f)
float f;
{
return (f*f);
}
.
define show_i()
{
int i;
i = 10;
$printf "value of i = %d\n", i$;
return (1);
}
.
define /R int userPrompt()
{
char userPromptBuffer[100];
int retval;
retval = prompt_text( "Please enter text", userPromptBuffer );
if (retval == 0) {
$printf "Clicked OK\n"$;
$printf "%s\n", userPromptBuffer$;
} else
$printf "Clicked Cancel\n"$;
return 1;
}
.
The following commands provide similar or related functionality: