Using expressions

Some commands accept expressions. There are many types of expressions accepted by the debugger that enable you to extend the operation of a command. For example, binary mathematical expressions, references to module names, or calls to functions.

Show/hideUsing the $ character to access the content of registers and debugger variables

In an expression you can access the content of registers by using the $ character and the register name, for example:

print 4+$R0      # add 4 to the content of R0 register and print result

Results from the print commands are recorded in debugger variables and can be used successively in expressions by using the $ character. Each print result is assigned a number.

You can access print results with any of the following:

$

last print result

$n

print result assigned with number n

$$

second to last print result.

You can also use the following debugger variables:

$cwd

current working directory

$cdir

current compilation directory

$entrypoint

entry point of the current image

$idir

current image directory

$sdir

current script directory

$datetime

current date and time in string format

$timems

number of milliseconds since 1st Jan 1970.

$pid

current operating system process ID.

$thread

current thread ID for a multi-threaded application

$core

current processor ID for a Symmetric MultiProcessing (SMP) systems.

Show/hideUsing built-in functions within expressions

In an expression you can use built-in functions to provide more functionality. The debugger supports the following:

int strcmp(const char *str1, const char *str2);

Compares two strings and returns an integer.

Return values are:

<0

Indicates that the second argument string value comes after the first argument string value in the machine collating sequences, str1 < str2.

0

Indicates that the two strings are identical in content.

>0

Indicates that the first argument string value comes after the second argument string value in the machine collating sequences, str2 < str1.

int strncmp(const char *str1, const char *str2, size_t n);

Compares at most n characters of two strings and returns an integer.

Return values are:

<0

Indicates that the second argument string value comes after the first argument string value in the machine collating sequences, str1 < str2.

0

Indicates that the two strings are identical in content.

>0

Indicates that the first argument string value comes after the second argument string value in the machine collating sequences, str2 < str1.

char *strcpy(char *str1, const char *str2);

Copies str2 to str1 including "\0" and returns str1.

char *strncpy(char *str1, const char *str2, size_t n);

Copies at most n characters of str2 to str1 including "\0" and returns str1. If str2 has fewer than n characters then fill with "\0".

void *memcpy(void *s, const void *cs, size_t n);

Copies at most n characters from cs to s and returns s.

Example 1. Using a built-in strcmp() function with the break command

break main.c:45 if strcmp(myVar, "10") == 0     # Set conditional breakpoint that stops
                                                # when strings are identical

Show/hideSee also

Copyright © 2010, 2011 ARM. All rights reserved.ARM DUI 0452G
Non-ConfidentialID092311