DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
dbXtra and dbxtra

dbXtra and dbxtra expressions and conditions

Variables and constants can be combined with operators to form expressions and conditions. Expressions have a value that can be printed or assigned to a variable. Conditions have a Boolean value that can be used to issue dbXtra and dbxtra commands selectively.

``Operators in expressions'' contains a list of operators that can form expressions for various debugging commands. If a C++ program being debugged has overloaded any of them, the overloaded operators are not used. Note that the semantics of the casting operator are slightly different from those of the C/C++ casting operator.

Identifier resolution

A variable in an expression must be one of the identifiers in the program being debugged, and dbXtra first checks to ensure that this is true before resolving it. Variable names are resolved by first using the static scope of the current function. By default, this function is the one in which control has stopped in (for example, due to a breakpoint). It can redefined to another function by using the up/down or func commands. If the name is not defined in the static scope, then the dynamic scope is used. If static and dynamic searches do not yield a result, another variable with the same name is used and a message is printed showing the fully qualified name. The name resolution procedure may be overridden by qualifying an identifier with the scopes containing it, for example, sfile.variable, where sfile is the name of the source file (without the .c) that contains the global variable.

dbXtra and dbxtra recognize class scope within C++ member functions. See also ``C++ specific debugging features''.

Operators in expressions

Operator Description
. or -> structure or union member
[] array indexing
sizeof(type) size in bytes of type
~ one's complement
! logical not
&identifier address of identifier
*identifier dereference of identifier
(type) type cast
* multiplication
/ floating point division
div integer division
% or mod modulo (or remainder)
+ arithmetic addition
- arithmetic subtraction
<< bitwise left shift
>> bitwise right shift
< less than
<= less than or equal to
> greater than
>= greater than or equal to
== equal to
!= not equal to
& bitwise and
| bitwise or
&& or and logical and
|| or or logical or

Types and casting

The types of expressions are checked before being processed by dbXtra. They can be overridden by using the syntax type(expression). As a special case, expression can be cast to a pointer to a named type by using ``&'', as in &type(expression).

You can also use the casting format typical in C, (type)expression, to a limited extent. In such cases, the type specifier cannot be the name of a derived type but it can be a structure or union tag. For example, in the following program segment:

   struct foo { int i; };
   typedef struct foo bar;
   

main() { bar x;

... }

The debugger recognizes the following casts:
   (struct foo) x
   foo(x)
But it does not recognize:
   (bar) x
Although the debugging and C/C++ casting operators have the same usage, they have different semantics. In particular, if a value is cast by dbXtra or dbxtra to be of another type, then the bits representing that value are treated by the debugger as being of the new type. Thus, for example, (int) x, where x is of type float, is not converted to an integer by discarding its fractional part. Instead, the bits representing its value are treated as an integer.

Next topic: C++ specific debugging features
Previous topic: Default command aliases

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003