Evaluating expressions
It is often useful to calculate the value of an expression while debugging. To evaluate an expression, simply enter it into the debugger's command pane. The debugger will print the calculated value of the expression in the command pane. If you want to watch the value of an expression, and have it reevaluated as you step through your program, you should use a data explorer instead. See also
Chapter 14, "The data explorer".
When you construct your expressions, beware that:
- If the expression begins the same way as a debugger command, put the expression in parentheses ( ) or explicitly use the print command to distinguish it from that command. For example, to look at the value of the variable c, enter (c) or print c. (See
print.) If you just entered c, the debugger would execute the c command.
Expression
|
Effect
|
(c)
|
displays value of variable c
|
print c
|
displays value of variable c
|
c
|
executes the c command
|
- Do not press Enter in the middle of an expression. An expression is only one line with an Enter at the end.
- Comments begin with /* (forward slash + asterisk) and end with either a new line or */ (asterisk + forward slash).
- If the program has not been started, then the expression may only contain constants. After the program has started, the expression may contain variables and procedure calls.
- If the program is running, then the expression may only contain constants and, if the system allows, global variables.
- If the program has not been started and was linked against shared objects, then expressions referring to procedures and variables located within these shared objects may not be allowed.
- In C++, the ".*" and "->*" operators are not supported.
- In C++, casts to reference types are not supported.
- In C++, the debugger never calls destructors.
- In C++, there are restrictions on procedure calls and overloaded operator calls. See
"Procedure calls" for more information.
- In Pascal, enclose set constructors in parentheses.
If you are debugging multi-language (e.g. mixed Ada and C++) applications, use the syntax appropriate to the language of the source file that the debugger is currently displaying.
Be careful when using expressions in the debugger that may be evaluated across multiple languages (such as in button definitions). Language changes can cause confusion with the operators. For example, in C, the assignment operator is one equal sign (=), and the equality comparison is two equal signs (==). In Ada and Pascal, colon equal (:=) is the assignment operator, and one equal sign (=) is the equality comparison.
The debugger always follows the operator definitions for the current language. This can make definition of language-independent expressions difficult. In order to overcome this problem, the debugger always recognizes the "colon equal" (:=) as the assignment operator (in addition to the correct operator in the current language), and two equal signs (==) as the comparison operator. To ensure that expressions are language-independent, these operators should be used to implement features or capabilities (such as button definitions) that may remain in operation over several source languages.
Language keywords
When the debugger evaluates expressions, it understands the following keywords for the current source language:
Language
|
Keywords
|
---|
C
|
char const double enum float int long short signed sizeof struct union unsigned void volatile
(The `sizeof' operator behaves the same way as in the C language.)
|
C++
|
As above, plus:
class namespace
|
Ada
|
abs and boolean character false float in int integer mod not null or xor package real rem true
|
Fortran
|
.AND. .EQ. .FALSE. .GE. .GT. .LE. .LT. .NE. .NOT. .OR. .TRUE. character complex int integer logical real
|
Pascal
|
and boolean char chr false fiv in int integer mod nil not or ord real true
|
Jovial
|
A B C F P S U V abs and bit boolean character eqv false int integer mod not null or pointer real true xor
|
SL1
|
address bitoffset bitwidth byteoffset comment convert_to_int convert_to_pptr convert_to_uptr int integer maxint nil no_op offset ppoi ppointer pstructure size struct structure upoi upointer ustructure wordoffset
|
Related topic:
Copyright © 1999, Green Hills Software. All rights
reserved.