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:

$thread

current thread ID for a multi-threaded application

$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.

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 *string1, const char *string2);

Compares two strings and returns an integer. You might want to use it in a conditional breakpoint if you want to stop only when a specific char* variable equals a given string. For example:

break main.c:45 if strcmp(myVar, "10") == 0

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.

Show/hideSee also

Copyright © 2010, 2011 ARM. All rights reserved.ARM DUI 0452D
Non-ConfidentialID011411