Displaying Virtual and Inherited Class Information

When you use the print command to display information on an instance of a derived class, the debugger displays both the new class members as well as the members inherited from a base class. Pointers to members of a class are not supported.

When you use the print command to display the format of C++ classes, the class name (or structure/union name) is displayed at the top of the output. Data members of a class that are inherited from another class are commented using a double slash (//). Only those data members that are inherited within the current class being printed are commented.

The following example shows how the debugger uses C++ style comments to identify inherited class members. In the example, class CompoundNode inherits from class IntNode, which inherits from class Node. When printing a class CompoundNode object, the data member _data is commented with "// class IntNode", signifying that it is inherited from class IntNode. The member _nextNode is commented with "// class IntNode::Node", showing that it is inherited from class IntNode, which inherits it from class Node. This commenting is also provided for C++ structs.

 

(idb) where 3

>0  0x0804d37e in ((IntNode*)0x805fb18)->IntNode::printNodeData() "src/x_list.cxx":93

#1  0x0804d4c6 in ((CompoundNode*)0x805fb18)->CompoundNode::printNodeData() "src/x_list.cxx":112

#2  0x08050c43 in ((List<Node>*)0xbffec758)->List<Node>::print() "src/x_list.cxx":168

(idb) whatis *this

class CompoundNode : IntNode {

  float _fdata;

  CompoundNode(float, int);

  virtual void printNodeData(void);

}

(idb) print *this

class CompoundNode {

  _fdata = 12.3450003;

  _data = 2;                      // class IntNode

  _nextNode = 0x805fb30;          // class IntNode::Node

}

(idb) up 1

>1  0x0804d4c6 in ((CompoundNode*)0x805fb18)->CompoundNode::printNodeData() "src/x_list.cxx":112

    112     IntNode::printNodeData();

(idb) whatis *this

class CompoundNode : IntNode {

  float _fdata;

  CompoundNode(float, int);

  virtual void printNodeData(void);

}

(idb) print *this

class CompoundNode {

  _fdata = 12.3450003;

  _data = 2;                      // class IntNode

  _nextNode = 0x805fb30;          // class IntNode::Node

}

 

If two members in an object have the same name but different base class types (multiple inheritance), you can refer to the members using the following syntax:

 

object.class::member

 

or

 

object->class::member

 

This syntax is more effective than using the object.member and object->member syntaxes, which can be ambiguous. In all cases, the debugger uses the C++ language rules as defined in The Annotated C++ Reference Manual to determine which member you are specifying.

The following example shows a case in which the expanded syntax can be used:

 

(idb) print *jupiter

class Planet {

  _name = 0x805c5b8="Jupiter";    // class HeavenlyBody

  _innerNeighbor = 0x806e3a0;     // class HeavenlyBody

  _outerNeighbor = 0x806e6b8;     // class HeavenlyBody

  _firstSatellite = 0x806e500;    // class HeavenlyBody

  _lastSatellite = 0x806e660;     // class HeavenlyBody

  _primary = 0x806e168;           // class Orbit

  _distance = 778330;             // class Orbit

  _name = 0x806e4d8="Sol 5";      // class Orbit

}

(idb) print jupiter->_name

Overloaded Values

0x806e4d8="Sol 5"

0x805c5b8="Jupiter"

(idb) print jupiter->HeavenlyBody::_name

0x805c5b8="Jupiter"

(idb) print jupiter->Orbit::_name

0x806e4d8="Sol 5"