| |||
| 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:
$cwdcurrent working directory
$cdircurrent compilation directory
$entrypointentry point of the current image
$idircurrent image directory
$sdircurrent script directory
$datetimecurrent date and time in string format
$timemsnumber of milliseconds since 1st Jan 1970.
$pidcurrent operating system process ID.
$threadcurrent thread ID for a multi-threaded application
$corecurrent processor ID for a Symmetric MultiProcessing (SMP) systems.
$vmidcurrent Virtual Machine ID (VMID) for systems that support hypervisor / virtual machine debugging.
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:
<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.
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:
<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.
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