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 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:


Previous

Next



Copyright © 1999, Green Hills Software. All rights reserved.