10.5. Predefined macros

RealView Debugger recognizes several predefined macros containing commonly used functions. Predefined macros can be used in expressions on the command line and can be called from macros that you create yourself.

Table 10.1 contains a summary of the predefined macros.

Table 10.1. Predefined macros

Macro nameDescriptionSyntaxNotes
byte

Returns a byte value from the specified address.

unsigned char byte(addr)
void *addr;
-
callPerforms a target function call. Use this to make an application function call from the debugger.
call(label, arg1,...)
char *label;
int arg1;
-
commandEnables you to construct a command in a string.
command(cmd)
Takes only a single argument.
dword

Returns a long value from the specified address.

unsigned long dword(addr)
void *addr;
-
error

Processes error message returned from macro.

int error(type, message, value)
int type;
char *message;
long value;

error takes a string that can have one “%d” or “%x” in it to show the value (sprintf format).

The type is one of:

1=note popup

2=warning popup

3=error popup

-3=fatal error popup.

fgetc

Returns a byte from file or window.

These must be previously opened using FOPEN, VOPEN, or the predefined macro fopen.

int fgetc(window_ID)
int window_ID;
-
fopen

Opens a file for reading, writing, or both.

int fopen(char *mode, int window_ID, char *file_name)
-
fread

Reads a file into a buffer.

unsigned long fread(void *buffer, unsigned count, unsigned size, int window_ID)
Acts on a window in addition to a file.
fwrite

Writes a buffer to a file.

unsigned long fwrite(void *buffer, unsigned count, unsigned size, int window_ID)
Acts on a window in addition to a file.
getsymTakes an address and returns a local string.
char *getsym(long addr)
void *addr;

Example:

add char x[20]
strcpy(x,getsym(@pc))
pr x
“Start”

The PC is at the label “Start”. You can use any expression.

isalive

Verifies that a symbol is currently active.

int isalive(symbol_name)
void symbol_name;

This returns:

0=not available

1=available

2=up the stack

-1=does not exist.

memchr

Searches for a character in memory.

char *memchr(str1, count)
char *str1;
int count;
-
memclr

Clears memory values.

char *memclr(str1, count)
char *str1;
int count;
-
memcpy

Copies characters from memory.

char *memcpy(dest, src, count)
char *dest, *src;
int count;
-
memset

Sets the value of characters in memory.

char *memset(dest, byte_value, count)
char *dest;
char byte_value;
int count;
-
prompt_file

Displays a file containing message text.

The user choice is entered into the buffer (local or target).

int prompt_file(message, buff)
char *message
char *buff
-
prompt_list

Displays a dialog box containing message text and a choice list.

This returns:

0=Cancel

1=first list index

2=second list index

int prompt_text(message, buff)
char *message
char *buff

Initially, the buffer consists of lines to show in the list (separated by \n).

Example:

strcpy(buff, “one\ntwo\nthree”)
ce prompt_list(“Choose one:”, buff)
Result is: 3 0x03
prompt_text

Displays a dialog box containing message text.

The user choice is entered into the buffer (local or target).

int prompt_text(message, buff)
char *message
char *buff

Example:

add char buff[32] = “initial”, 0
pr buff
“initial”
ce prompt_text(“Enter a string”, buff)
Result is: 0 0x00
pr buff
“new value”
prompt_yesno()

Displays a dialog box containing question text and buttons (Yes and No).

This returns:

0=Yes

2=No.

int prompt_yesno(message)
char *message

Example:

ce prompt_yesno(“Is everything OK?”)
Result is: 0 0x00
prompt_yesno_cancel()

Displays a dialog box containing question text and buttons (Yes, No and Cancel).

This returns:

0=Yes

1=Cancel

2=No.

int prompt_yesno_cancel(message)
char *message

Example:

ce prompt_yesno_cancel(“Is everything OK?”)
Result is: 1 0x01
reg_str

Takes a register name from a string and returns the value.

unsigned long reg_str(char *name)
-
strcat

Concatenates two strings.

char *strcat(dest, src)
char *dest, *src;
-
strchr

Locates the first occurrence of a character in a string.

char *strchr(str1, byte_value)
char *str1;
char byte_value;
-
strcmp

Compares two strings.

unsigned long strcmp(str1, str2)
char *str1, *str2;
-
strcpy

Copies a string.

char *strcpy(dest, src)
char *dest, *src;
-
stricmp

Performs string comparison without case distinction.

char *stricmp(str1, str2)
char *str1;
char *str2;
-
strlen

Returns string length.

unsigned long strlen(str1)
char *str1;
-
strncmp

Performs limited comparison of two strings.

char *strncmp(str1, str2, count)
char *str1;
char *str2;
int count;
-
until

Breaks when an expression evaluates to True.

char until(expression)
int expression;
-
when

Breaks when an expression evaluates to True.

char when(expression)
int expression;
-
word

Returns a word value at the specified address.

unsigned short int word(addr)
void *addr;
-
Copyright © 2003, 2004 ARM Limited. All rights reserved.ARM DUI 0234B
Non-Confidential