OpenVMS Debugger Manual


Previous Contents Index

C.7.2 Constructs in Language and Address Expressions

Supported constructs in language and address expressions for C++ follow:
Symbol Construct
[ ] Subscripting
. (period) Structure component selection
-> Pointer dereferencing
:: Scope resolution

C.7.3 Data Types

Supported C++ data types follow:
C++ Data Type Operating System Data Type Name
__int64 (Alpha and Integrity servers) Quadword Integer (Q)
unsigned __int64 (Alpha and Integrity servers) Quadword Unsigned (QU)
__int32 (Alpha and Integrity servers) Longword Integer (L)
unsigned __int32 (Alpha and Integrity servers) Longword Unsigned (LU)
int Longword Integer (L)
unsigned int Longword Unsigned (LU)
__int16 (Alpha and Integrity servers) Word Integer (W)
unsigned __int16 (Alpha and Integrity servers) Word Unsigned (WU)
short int Word Integer (W)
unsigned short int Word Unsigned (WU)
char Byte Integer (B)
unsigned char Byte Unsigned (BU)
float F_Floating (F)
__f_float (Alpha and Integrity servers) F_Floating (F)
double D_Floating (D)
double G_Floating (G)
__g_float (Alpha and Integrity servers) G_Floating (G)
float (Alpha and Integrity servers) IEEE S_Floating (FS)
__s_float (Alpha and Integrity servers) IEEE S_Floating (FS)
double (Alpha and Integrity servers) IEEE T_Floating (FT)
__t_float (Alpha and Integrity servers) IEEE T_Floating (FT)
enum (None)
struct (None)
class (None)
union (None)
Pointer Type (None)
Array Type (None)

Floating-point numbers of type float may be represented by F_Floating or IEEE S_Floating, depending on compiler switches.

Floating-point numbers of type double may be represented by IEEE T_Floating, D_Floating, or G_Floating, depending on compiler switches.

C.7.4 Case Sensitivity

Symbol names are case sensitive in C++. This means that uppercase and lowercase letters are treated as different characters.

C.7.5 Displaying Information About a Class

Use the command SHOW SYMBOL to display static information about a class declaration. Use the command EXAMINE to view dynamic information about class objects (see Section C.7.6).

The command SHOW SYMBOL/FULL displays the class type declaration, including:

Data members (including static data members)
Member functions (including static member functions)
Constructors and destructors
Base classes and derived classes

For example:


dbg> SHOW SYMBOL /TYPE C 
type C 
    struct (C, 13 components), size: 40 bytes 
overloaded name C 
       instance C::C(void) 
       instance C::C(const C &) 
dbg> SHOW SYMBOL /FULL C 
type C 
    struct (C, 13 components), size: 40 bytes 
      inherits: B1, size: 24 bytes, offset: 0 bytes 
                B2, size: 24 bytes, offset: 12 bytes 
      contains the following members: 
        overloaded name C::g 
               instance C::g(int) 
               instance C::g(long) 
               instance C::g(char) 
        j : longword integer, size: 4 bytes, offset: 24 bytes 
        s : longword integer, size: 4 bytes, address: #  [static] 
        overloaded name C 
        int ==(C &) 
        C & =(const C &) 
        void h(void)   [virtual] 
        ~C(void) 
        __vptr : typed pointer type, size: 4 bytes, offset: 4 bytes 
        __bptr : typed pointer type, size: 4 bytes, offset: 8 bytes 
        structure has been padded, size: 4 bytes, offset: 36 bytes 
overloaded name C 
       instance C::C(void) 
       instance C::C(const C &) 
DBG> 

Note that SHOW SYMBOL/FULL does not display members of base classes or derived classes. Use the commands SHOW SYMBOL/FULL base_class_name and SHOW SYMBOL/FULL derived_class_name to display information about members of those classes. For example:


DBG> SHOW SYMBOL /FULL B1 
type B1 
    struct (B1, 8 components), size: 24 bytes 
      inherits: virtual A 
      is inherited by: C 
      contains the following members: 
        i : longword integer, size: 4 bytes, offset: 0 bytes 
        overloaded name B1 
        void f(void) 
        B1 & =(const B1 &) 
        void h(void)   [virtual] 
        __vptr : typed pointer type, size: 4 bytes, offset: 4 bytes 
        __bptr : typed pointer type, size: 4 bytes, offset: 8 bytes 
        structure has been padded, size: 12 bytes, offset: 12 bytes 
overloaded name B1 
       instance B1::B1(void) 
       instance B1::B1(const B1 &) 
DBG> 
 

Use the command SHOW SYMBOL/FULL class_member_name to display information about class members. For example:


DBG> SHOW SYMBOL /FULL j 
record component C::j 
    address: offset 24 bytes from beginning of record 
    atomic type, longword integer, size: 4 bytes 
record component A::j 
    address: offset 4 bytes from beginning of record 
    atomic type, longword integer, size: 4 bytes 
DBG> 
 

Use the SHOW SYMBOL/FULL command to display detailed information about an object.

Note that SHOW SYMBOL does not currently support qualified names. For example, the following commands are not currently supported:


 
SHOW SYMBOL    object_name.function_name 
 
SHOW SYMBOL    class_name::member_name 
 

C.7.6 Displaying Information About an Object

The debugger uses C++ symbol lookup rules to display information about objects. Use the command EXAMINE to display the current value of an object. For example:


DBG> EXAMINE a 
CXXDOCEXAMPLE\main\a: struct A 
    i:  0 
    j:  1 
    __vptr:     131168 
DBG> 

You can also display individual object members using the member access operators, period (.) and right arrow (->), with the EXAMINE command. For example:


DBG> EXAMINE ptr 
CXXDOCEXAMPLE\main\ptr:         40 
DBG> EXAMINE *ptr 
*CXXDOCEXAMPLE\main\ptr: struct A 
    i:  0 
    j:  1 
    __vptr:     131168 
DBG> EXAMINE a.i 
CXXDOCEXAMPLE\main\a.i: 0 
DBG> EXAMINE ptr->i 
CXXDOCEXAMPLE\main\ptr->i:      0 
DBG> 

The debugger correctly interprets virtual inheritance. For example:


DBG> EXAMINE c 
CXXDOCEXAMPLE\main\c: struct C 
    inherit B1 
        inherit virtual A 
            i:  8 
            j:  9 
            __vptr:     131200 
        i:      10 
        __vptr: 131232 
        __bptr: 131104 
    inherit B2 
        inherit virtual A  (already printed, see above) 
        i:      11 
        __vptr: 131280 
        __bptr: 131152 
    j:  12 
    __vptr:     131232 
    __bptr:     131104 
DBG> 

Use the scope resolution operator (::) to reference global variables, to reference hidden members in base classes, to explicitly reference a member that is inherited, or otherwise to name a member hidden by the current context. For example:


DBG> EXAMINE c.j 
CXXDOCEXAMPLE\main\c.j: 12 
DBG> EXAMINE c.A::j 
CXXDOCEXAMPLE\main\c.A::j:      9 
DBG> EXAMINE x 
CXXDOCEXAMPLE\main\x:   101 
DBG> EXAMINE ::x 
CXXDOCEXAMPLE\x:        13 
DBG> 

To resolve ambiguous member references, the debugger lists the members that satisfy the reference and requests an unambiguous reference to the member. For example:


DBG> EXAMINE c.i 
%DEBUG-I-AMBIGUOUS, 'i' is ambiguous, matching the following 
    CXXDOCEXAMPLE\main\c.B1::i 
    CXXDOCEXAMPLE\main\c.B2::i 
%DEBUG-E-REENTER, reenter the command using a more precise pathname 
DBG> EXAMINE c.B1::i 
CXXDOCEXAMPLE\main\c.B1::i:     10 
DBG> 
 

Use the scope resolution operator (::) to refer to static data members. For example:


DBG> EXAMINE c.s 
CXXDOCEXAMPLE\main\c.s: 42 
DBG> EXAMINE C::s 
C::s:   42 
DBG> 

Use the SHOW SYMBOL/FULL to display the class type of an object (see Section C.7.5).

C.7.7 Setting Watchpoints

You can set watchpoints on objects. All nonstatic data members are watched (including those in base classes). Static data members are not watched when you set a watchpoint on the object. However, you can explicitly set watchpoints on static data members. For example:


DBG> SET WATCH c 
%DEBUG-I-WPTTRACE, non-static watchpoint, tracing every instruction 
DBG> GO 
watch of CXXDOCEXAMPLE\main\c.i at CXXDOCEXAMPLE\main\%LINE 50+8 
    50:     c.B2::i++; 
   old value: 11 
   new value: 12 
break at CXXDOCEXAMPLE\main\%LINE 51 
    51:     c.s++; 
DBG> SET WATCH c.s 
DBG> GO 
watch of CXXDOCEXAMPLE\main\c.s at CXXDOCEXAMPLE\main\%LINE 51+16 
    51:     c.s++; 
   old value: 43 
   new value: 44 
break at CXXDOCEXAMPLE\main\%LINE 53 
    53:     b1.f(); 
DBG> 
 

C.7.8 Debugging Functions

The debugger uses C++ symbol lookup rules to display information on member functions. For example:


DBG> EXAMINE /SOURCE b1.f 
module CXXDOCEXAMPLE 
    14:     void f() {} 
DBG> SET BREAK B1::f 
DBG> GO 
break at routine B1::f 
    14:     void f() {} 
DBG> 
 
 
 

The debugger correctly interprets references to the this pointer. For example:


DBG> EXAMINE this 
B1::f::this:            16 
DBG> EXAMINE *this 
*B1::f::this: struct B1 
    inherit virtual A 
        i:      2 
        j:      3 
        __vptr: 131184 
    i:  4 
    __vptr:     131248 
    __bptr:     131120 
DBG> EXAMINE this->i 
B1::f::this->i: 4 
DBG> EXAMINE this->j 
B1::f::this->A::j:      3 
DBG>EXAMINE i 
B1::f::this->i: 4 
DBG> EXAMINE j 
B1::f::this->A::j:      3 
DBG> 
 
 
 

The debugger correctly references virtual member functions. For example:


DBG> EXAMINE /SOURCE %LINE 53 
module CXXDOCEXAMPLE 
    53:     b1.f(); 
DBG> SET BREAK this->h 
DBG> SHOW BREAK 
breakpoint at routine B1::f 
breakpoint at routine B1::h 
!! 
!! We are at the call to B1::f made at 'c.B1::f()'. 
!! Here this->h matches C::h. 
!! 
DBG> GO 
break at routine B1::f 
    14:     void f() {} 
DBG> EXAMINE /SOURCE %LINE 54 
module CXXDOCEXAMPLE 
    54:     c.B1::f(); 
DBG> SET BREAK this->h 
DBG> SHOW BREAK 
breakpoint at routine B1::f 
breakpoint at routine B1::h 
breakpoint at routine C::h 
!! 
!! Handling overloaded functions 
!! 
 
DBG> show symbol/full g 
overloaded name C::g 
routine C::g(char) 
type signature: void g(char) 
address: 132224, size: 128 bytes 
routine C::g(long) 
type signature: void g(long) 
address: 132480, size: 96 bytes 
 
DBG> SET BREAK g 
%DEBUG-I-NOTUNQOVR, symbol 'g' is overloaded 
overloaded name C::g 
       instance C::g(int) 
       instance C::g(long) 
       instance C::g(char) 
%DEBUG-E-REENTER, reenter the command using a more precise pathname 
DBG> SET BREAK g(int) 
 
DBG> CANCEL BREAK/ALL 
DBG> 
 
 
 

If you try to set a break on an overloaded function, the debugger lists the instances of the function and requests that you specify the correct instance. For example, with Debugger Version 7.2:


DBG> SET BREAK g 
%DEBUG-I-NOTUNQOVR, symbol 'g' is overloaded 
overloaded name C::g 
       instance void g(int) 
       instance void g(long) 
       instance void g(char *) 
%DEBUG-E-REENTER, reenter the command using a more precise pathname 
DBG> SET BREAK g(int) 
DBG> 

Note

The means of displaying and specifying overloaded functions is different than in the OpenVMS Debugger Version 7.1C.

The debugger provides support for debugging constructors, destructors, and operators. For example:


DBG> SET BREAK C 
%DEBUG-I-NOTUNQOVR, symbol 'C' is overloaded 
overloaded name C 
       instance C::C(void) 
       instance C::C(const C &) 
%DEBUG-E-REENTER, reenter the command using a more precise pathname 
DBG> SHOW SYMBOL /FULL ~C 
routine C::~C 
   type signature: ~C(void) 
    code address: #, size: 152 bytes 
    procedure descriptor address: #    
DBG> SET BREAK ~C 
DBG> SET BREAK %NAME'==' 
%DEBUG-W-UNALLOCATED, '==' is not allocated in memory (optimized away) 
%DEBUG-E-CMDFAILED, the SET BREAK command has failed 
 
 
DBG> SHOW SYMBOL /FULL ==,  
routine c::operator==, type 
signature: bool operator==© 
code address: 198716, size: 
40 bytes, procedure descriptor 
address: 65752 
DBG> SET BREAK operator== 
 
DBG> SHOW SYMBOL /FULL == 
routine C::== 
    type signature: int ==(C &) 
    address: unallocated 
DBG> SHOW BREAK 
breakpoint at routine C::~C 
DBG> 
 
 
DBG> examine C::~C 
C::~C: alloc r35 = ar.pfs, 3F, 01, 00 
DBG> 
DBG> ex/source ~C 
module CXXDOCEXAMPLE 
37: ~C() {} 
 

C.7.9 Limitations on Debugger Support for C++

The following limitations apply when you debug a C++ program:

Example C-1 contains CXXDOCEXAMPLE.C, a C++ example program.

Example C-1 C++ Example Program CXXDOCEXAMPLE.C

int x = 0; 
 
struct A 
    { 
    int i,j; 
    void f() {} 
    virtual void h() {}; 
    A() { i=x++; j=x++; }    
    }; 
 
struct B1 : virtual A 
    { 
    int i; 
    void f() {} 
    virtual void h() {} 
    B1() { i=x++; } 
    }; 
 
struct B2 : virtual A 
    { 
    int i; 
    void f() {} 
    virtual void h() {} 
    B2() { i=x++; } 
    }; 
 
struct C : B1, B2 
    { 
    int j; 
    static int s; 
    void g( int ) {} 
    void g( long ) {} 
    void g( char ) {} 
    void h() {} 
    operator ==( C& ) { return 0; } 
    C() { j=x++; } 
    ~C() {} 
    }; 
 
int C::s = 42; 
 
main() 
    { 
    A a; B1 b1; B2 b2; C c; 
    A *ptr = &a; 
    int x = 101; 
    x++; 
 
    c.s++; 
    c.B2::i++; 
    c.s++; 
 
    b1.f(); 
    c.B1::f(); 
    c.g(1); 
    c.g( (long) 1 ); 
    c.g( 'a' ); 
    } 

Example C-2 contains a sample debugging session of the program contained in Example C-1.

Example C-2 C++ Debugging Example

DBG> GO 
break at routine CXXDOCEXAMPLE\main 
    44:     A a; B1 b1; B2 b2; C c; 
DBG> STEP 
stepped to CXXDOCEXAMPLE\main\%LINE 45 
    45:     A *ptr = &a; 
DBG> STEP 
stepped to CXXDOCEXAMPLE\main\%LINE 46 
    46:     int x = 101; 
DBG> STEP 
stepped to CXXDOCEXAMPLE\main\%LINE 47 
    47:     x++; 
!! 
!! Displaying class information 
!! 
DBG> SHOW SYMBOL /TYPE C 
type C 
    struct (C, 13 components), size: 40 bytes 
overloaded name C 
       instance C::C(void) 
       instance C::C(const C &) 
DBG> SHOW SYMBOL /FULL C 
type C 
    struct (C, 13 components), size: 40 bytes 
      inherits: B1, size: 24 bytes, offset: 0 bytes 
                B2, size: 24 bytes, offset: 12 bytes 
      contains the following members: 
        overloaded name C::g 
               instance C::g(int) 
               instance C::g(long) 
               instance C::g(char) 
        j : longword integer, size: 4 bytes, offset: 24 bytes 
        s : longword integer, size: 4 bytes, address: #  [static] 
        overloaded name C 
        int ==(C &) 
        C & =(const C &) 
        void h(void)   [virtual] 
        ~C(void) 
        __vptr : typed pointer type, size: 4 bytes, offset: 4 bytes 
        __bptr : typed pointer type, size: 4 bytes, offset: 8 bytes 
        structure has been padded, size: 4 bytes, offset: 36 bytes 
overloaded name C 
       instance C::C(void) 
       instance C::C(const C &) 
!! 
!! Displaying information about base classes 
!! 
DBG> SHOW SYMBOL /FULL B1 
type B1 
    struct (B1, 8 components), size: 24 bytes 
      inherits: virtual A 
      is inherited by: C 
      contains the following members: 
        i : longword integer, size: 4 bytes, offset: 0 bytes 
        overloaded name B1 
        void f(void) 
        B1 & =(const B1 &) 
        void h(void)   [virtual] 
        __vptr : typed pointer type, size: 4 bytes, offset: 4 bytes 
        __bptr : typed pointer type, size: 4 bytes, offset: 8 bytes 
        structure has been padded, size: 12 bytes, offset: 12 bytes 
overloaded name B1 
       instance B1::B1(void) 
       instance B1::B1(const B1 &) 
!! 
!! Displaying class member information 
!! 
DBG> SHOW SYMBOL /FULL j 
record component C::j 
    address: offset 24 bytes from beginning of record 
    atomic type, longword integer, size: 4 bytes 
record component A::j 
    address: offset 4 bytes from beginning of record 
    atomic type, longword integer, size: 4 bytes 
!! 
!! Simple object display 
!! 
DBG> EXAMINE a 
CXXDOCEXAMPLE\main\a: struct A 
    i:  0 
    j:  1 
    __vptr:     131168 
!! 
!! Using *, -> and . to access objects and members 
!! 
DBG> EXAMINE ptr 
CXXDOCEXAMPLE\main\ptr:         40 
DBG> EXAMINE *ptr 
*CXXDOCEXAMPLE\main\ptr: struct A 
    i:  0 
    j:  1 
    __vptr:     131168 
DBG> EXAMINE a.i 
CXXDOCEXAMPLE\main\a.i: 0 
DBG> EXAMINE ptr->i 
CXXDOCEXAMPLE\main\ptr->i:      0 
!! 
!! Complicated object example 
!! 
DBG> EXAMINE c 
CXXDOCEXAMPLE\main\c: struct C 
    inherit B1 
        inherit virtual A 
            i:  8 
            j:  9 
            __vptr:     131200 
        i:      10 
        __vptr: 131232 
        __bptr: 131104 
    inherit B2 
        inherit virtual A  (already printed, see above) 
        i:      11 
        __vptr: 131280 
        __bptr: 131152 
    j:  12 
    __vptr:     131232 
    __bptr:     131104 
!! 
!! The debugger using C++ symbol lookup rules (to match c.j) 
!! and then the use of :: to specify a particular member named j. 
!! 
DBG> EXAMINE c.j 
CXXDOCEXAMPLE\main\c.j: 12 
DBG> EXAMINE c.A::j 
CXXDOCEXAMPLE\main\c.A::j:      9 
!! 
!! Using the global scope resolution operator. 
!! 
DBG> EXAMINE x 
CXXDOCEXAMPLE\main\x:   101 
DBG> EXAMINE ::x 
CXXDOCEXAMPLE\x:        13 
!! 
!! Handling ambiguous member references. 
!! 
DBG> EXAMINE c.i 
%DEBUG-I-AMBIGUOUS, 'i' is ambiguous, matching the following 
    CXXDOCEXAMPLE\main\c.B1::i 
    CXXDOCEXAMPLE\main\c.B2::i 
%DEBUG-E-REENTER, reenter the command using a more precise pathname 
DBG> EXAMINE c.B1::i 
CXXDOCEXAMPLE\main\c.B1::i:     10 
!! 
!! Refering to static data members: with . and with :: 
!! 
DBG> EXAMINE c.s 
CXXDOCEXAMPLE\main\c.s: 42 
DBG> EXAMINE C::s 
C::s:   42 
!! 
!! Setting watchpoints on objects.  All non-static data members 
!! are watched (including those in base classes).  Static data 
!! members are not watched.  Of course watchpoints on static data 
!! members can be set explicitly. 
!! 
DBG> SET WATCH c 
%DEBUG-I-WPTTRACE, non-static watchpoint, tracing every instruction 
DBG> GO 
watch of CXXDOCEXAMPLE\main\c.i at CXXDOCEXAMPLE\main\%LINE 50+8 
    50:     c.B2::i++; 
   old value: 11 
   new value: 12 
break at CXXDOCEXAMPLE\main\%LINE 51 
    51:     c.s++; 
DBG> SET WATCH c.s 
DBG> GO 
watch of CXXDOCEXAMPLE\main\c.s at CXXDOCEXAMPLE\main\%LINE 51+16 
    51:     c.s++; 
   old value: 43 
   new value: 44 
break at CXXDOCEXAMPLE\main\%LINE 53 
    53:     b1.f(); 
!! 
!! Basic member lookup applies to functions. 
!! 
DBG> EXAMINE /SOURCE b1.f 
module CXXDOCEXAMPLE 
    14:     void f() {} 
DBG> SET BREAK B1::f 
DBG> GO 
break at routine B1::f 
    14:     void f() {} 
!! 
!! Support for 'this'. 
!! 
DBG> EXAMINE this 
B1::f::this:            16 
DBG> EXAMINE *this 
*B1::f::this: struct B1 
    inherit virtual A 
        i:      2 
        j:      3 
        __vptr: 131184 
    i:  4 
    __vptr:     131248 
    __bptr:     131120 
DBG> EXAMINE this->i 
B1::f::this->i: 4 
DBG> EXAMINE this->j 
B1::f::this->A::j:      3 
DBG>EXAMINE i 
B1::f::this->i: 4 
DBG> EXAMINE j 
B1::f::this->A::j:      3 
!! 
!! Support for virtual functions. 
!! 
!! We are at the call to B1::f made at 'b1.f()'. 
!! Here this->h matches B1::h. 
!! 
DBG> EXAMINE /SOURCE %LINE 53 
module CXXDOCEXAMPLE 
    53:     b1.f(); 
DBG> SET BREAK this->h 
DBG> SHOW BREAK 
breakpoint at routine B1::f 
breakpoint at routine B1::h 
!! 
!! We are at the call to B1::f made at 'c.B1::f()'. 
!! Here this->h matches C::h. 
!! 
DBG> GO 
break at routine B1::f 
    14:     void f() {} 
DBG> EXAMINE /SOURCE %LINE 54 
module CXXDOCEXAMPLE 
    54:     c.B1::f(); 
DBG> SET BREAK this->h 
DBG> SHOW BREAK 
breakpoint at routine B1::f 
breakpoint at routine B1::h 
breakpoint at routine C::h 
!! 
!! Handling overloaded functions 
!! 
DBG> SET BREAK g 
%DEBUG-I-NOTUNQOVR, symbol 'g' is overloaded 
overloaded name C::g 
       instance C::g(int) 
       instance C::g(long) 
       instance C::g(char) 
%DEBUG-E-REENTER, reenter the command using a more precise pathname 
DBG> SET BREAK g(int) 
 
DBG> CANCEL BREAK/ALL 
!! 
!! Working with constructors, destructors, and operators. 
!! 
DBG> SET BREAK C 
%DEBUG-I-NOTUNQOVR, symbol 'C' is overloaded 
overloaded name C 
       instance C::C(void) 
       instance C::C(const C &) 
%DEBUG-E-REENTER, reenter the command using a more precise pathname 
DBG> SHOW SYMBOL /FULL ~C 
routine C::~C 
   type signature: ~C(void) 
    code address: #, size: 152 bytes 
    procedure descriptor address: #    
DBG> SET BREAK %NAME'~C' 
DBG> SET BREAK %NAME'==' 
%DEBUG-W-UNALLOCATED, '==' is not allocated in memory (optimized away) 
%DEBUG-E-CMDFAILED, the SET BREAK command has failed 
DBG> SHOW SYMBOL /FULL == 
routine C::== 
    type signature: int ==(C &) 
    address: unallocated 
DBG> SHOW BREAK 
breakpoint at routine C::~C 
DBG> EXIT 


Previous Next Contents Index