| |||
| Home > DS-5 Debugger Commands > General syntax and usage of DS-5 Debugger commands > 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.
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
$nprint result assigned with number n
$$second to last print result.
You can also use the following debugger variables:
$threadcurrent thread number for a multi-threaded application
$cwdcurrent working directory
$cdircurrent compilation directory
$entrypointentry point of the current image
$idircurrent image directory
$sdircurrent script directory.
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:
<0Indicates that the second argument string value
comes after the first argument string value in the machine collating
sequences, str1 < str2.
0Indicates that the two strings are identical in content.
>0Indicates
that the first argument string value comes after the second argument
string value in the machine collating sequences, str2 < str1.