![]() Chapter Contents |
![]() Previous |
![]() Next |
SAS/C C++ Development System User's Guide, Release 6.50 |
The debugger supports
the use of operators, types, and casts that are specific to C++. This section
delineates these items and explains how expressions are evaluated for C++
programs in the debugger. Note that only standard C++ operators are supported
in expressions. That is, user-defined overloaded operators cannot be used.
This includes the use of complex and I/O stream
operators. For example, you cannot specify
print (a+b)
where
a
and
b
are complex.
The following operators are supported in debugger expressions:
::
(unary scope)::
(binary scope)->*
.*
::
is supported after
a
.
or
->
operator. For example, the following is not valid
syntax in a debugger command:
p->A::BB::c |
In addition to the syntax for casts
supported for C in the debugger, the keyword
class
is supported as in
(class TAG*)ADD |
All debugger commands that support expressions support the following C++ data types:
assign
,
copy
,
dump
,
monitor
,
print
,
return
, or
watch
commands that deal with objects of type
class
. For example, because all classes share the same
static
data, if you copy a class with the
copy
command, you do not modify static members.
A member-pointer is not considered a pointer in the C or C++ sense.
Therefore, it is invalid to specify an expression of type member-pointer in
a command (such as
dump
) that takes an address for an operand.
The
assign
command can be used to assign a pointer to an object of a derived
class to a pointer to the base class. When multiple inheritance is used, this
can cause the values of the derived pointer and the base pointer as printed
by the
print
command to
differ. This can also occur for assignments
involving member-pointers.
An assignment to a reference assigns to the referenced object.
An assignment to a class object is permitted using an initializer list
or a class object only if the class does not have base classes and if no user-defined
constructors need be invoked to initialize the class object.
The
dump
command and the Dump window support all the data types listed
earlier in this section. The
dump
command takes an address as an argument and, by default, dumps memory
corresponding to
the size of the object. A member pointer can be one of two sizes, depending
on whether it is a data pointer or a function pointer:
data pointers | are 4 bytes long. |
function pointers | are 12 bytes long. |
dump member-pointer |
The following command dumps the referenced object, as explained in Expression Evaluation :
dump reference-object |
You cannot monitor an object through a reference variable. You can only monitor the reference variable itself. If you set a monitor on a class object that con- tains a reference, the storage allocated for the class object (which includes the storage allocated to the reference variable) is monitored. That is, the referenced object is not monitored.
For objects of derived classes, the base objects are also monitored.
Because the entire storage of an object is monitored, it is possible for the
monitor to be triggered without any change in the printed value. That is,
for some data types (such as function member-pointers), some parts of the
value may not be reflected in the value produced by the
print
command. The debugger attempts to detect
corruption of control data and hidden pointers to virtual base
classes (that is, members of a class that are in addition to those members
you have explicitly created). If your program is erroneously overwriting memory,
it could overwrite some of these control data or hidden pointers. Even though
this corruption does not affect the value that is printed, the monitor is
triggered.
For a function that
returns a reference, the
return
command returns a reference.
A function may return a class using an initializer list or a class object
only if the class does not have base classes and if no constructors are needed
to initialize the class.
For a reference
type object, use
the C++ notation for references (such as
class myobject&
) in
the
typeof
keyword of the
transfer
command.
The
whatis
command uses the C++ notation for references (such as
myobject&
) in its output.
For classes,
whatis
displays the following information, in addition to the usual C information:
enums
,
typedefs
, and functions, including function prototypes).
Normal C++ rules are followed in expression evaluation, with the following
exception. If a
static
member is dereferenced using the
->
or
.
operator, the expression to the left of the
->
or
.
operator is evaluated
by the debugger.
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © Tue Feb 10 12:11:23 EST 1998 by SAS Institute Inc., Cary, NC, USA. All rights reserved.