16.2.1. Creating a macro with the RealView Debugger GUI

To create a macro for use with a debug target:

  1. Connect to your target.

  2. Select Tools → Add/Edit Debugger Macros... from the Code window main menu to open the Add/Edit Macros dialog box.

    When you open this dialog box, the Existing Macros display list is empty, unless you have previously loaded macros into RealView Debugger.

    The Macro Entry Area gives advice on how to use the buttons, New, Show, and Copy.

    This area shows the definition of the macro when it has been created.

  3. Click New to create the macro.

    This inserts the default name int Macro() in the Name data entry field and inserts {} in the Macro Entry Area ready for editing.

  4. Edit the default macro name so that it shows int tutorial(var1).


    A user-defined macro must not have the same name as a predefined RealView Debugger macro.

  5. Edit the macro contents to show:

    int var1;
        $printf "value=%d",var1$;
        return var1;

    When creating a macro, variables must be declared at the start of the macro definition. This also applies to macros that you create using a text editor.


    You must not include a period (.) to terminate the macro definition when using the Add/Edit Macros dialog box.

    The Add/Edit Macros dialog box looks like the example shown in Figure 16.1.

    Figure 16.1. Creating a macro

    Creating a macro

    The macro uses the PRINTF command and so the command must be enclosed by dollar signs ($), shown in the Macro Entry Area.

  6. Click Update to save the macro definition in the symbol table.

    This adds the new macro to the Existing Macros display list. If there are any errors in the macro text, you are notified when the macro is saved.

  7. Click Save... to open the Save Macro dialog box.

  8. Locate the directory where you want to save the macro definition, and either:

    • select an existing file

    • enter the required filename.

  9. Click Save to save the new macro, and close the Save Macro dialog box.

    If the specified file already exists, RealView Debugger displays a prompt that gives you the option to append the macro to the existing file or to overwrite the existing contents:

    • click Yes to append the macro to the existing file

    • click No to overwrite the existing contents.

  10. Click Close to close the Add/Edit Macros dialog box and return to the Code window.

See also

Copyright © 2002-2011 ARM. All rights reserved.ARM DUI 0153N