Go to main content
Oracle® Developer Studio 12.5: Debugging a Program with dbx

Exit Print View

Updated: June 2016

Viewing Variables, Members, Types, and Classes

The whatis command prints the declarations or definitions of identifiers, structs, types and C++ classes, or the type of an expression. The identifiers you can look up include variables, functions, fields, arrays, and enumeration constants.

For more information, see whatis Command.

Looking Up Definitions of Variables, Members, and Functions

Use the whatis command to print out the declaration of an identifier:

(dbx) whatis identifier

Qualify the identifier name with file and function information as needed.

For C++ programs, whatis lists function template instantiations. Template definitions are displayed with whatis -t See Looking Up Definitions of Types and Classes.

For Java programs, whatis identifier, lists the declaration of a class, a method in the current class, a local variable in the current frame, or a field in the current class.

To print out the member function, you would type the following commands:

(dbx) whatis block::draw
void block::draw(unsigned long pw);
(dbx) whatis table::draw
void table::draw(unsigned long pw);
(dbx) whatis block::pos
class point *block::pos();
(dbx) whatis table::pos
class point *block::pos();

To print out the data member

(dbx) whatis block::movable
int movable;

On a variable, the whatis command tells you the variable's type.

(dbx) whatis the-table
class table *the-table;

On a field, the whatis command gives the field's type.

(dbx) whatis the-table->draw
void table::draw(unsigned long pw);

When you are stopped in a member function, you can look up the this pointer.

(dbx) stop in brick::draw
(dbx) cont
(dbx) where 1
brick::draw(this = 0x48870, pw = 374752), line 124 in
(dbx) whatis this
class brick *this;

Looking Up Definitions of Types and Classes

The -t option of the whatis command displays the definition of a type. For C++, the list displayed by whatis -t includes template definitions and class template instantiations.

To print the declaration of a type or C++ class:

(dbx) whatis -t class-name

To view data members only, use the whatis command along with the –a option. This option only prints the list of data members for a specific class (and not its members' functions). It displays this information in the same order as the –r option, starting from the base class first.

(dbx) whatis -t -a class-name

To view members in base classes, the whatis command takes an -r option (for recursive). This displays the declaration of a specified class, as well as the members it inherits from the base classes.

(dbx) whatis -t -r  class-name

The output from a whatis -r query might be long, depending on the class hierarchy and class size. The output displays the list of inherited data members, starting from the most ancestral class. The inserted comment lines separate the list of members into their respective parent classes.

To see the root of a class' inherited members, the whatis command takes a -u option that displays the root of the type definition. Without the -u option, the whatis command will display the last value in the value history. This is similar to the ptype command used in gdb.

The following two examples us the class table, a child class of the parent class load-bearing-block, which is, in turn, a child class of block.

Without -r, whatis reports the members declared in class table.

(dbx) whatis -t class table
class table : public load-bearing-block {
    table::table(char *name, int w, int h, const class point &pos);
    virtual char *table::type();
    virtual void table::draw(unsigned long pw);

The following examples show the results when whatis -r is used on a child class to see members it inherits.

(dbx) whatis -t -r class table
class table : public load-bearing-block {
  /* from base class table::load-bearing-block::block */
  block::block(char *name, int w, int h, const class point &pos, class load-bearing-block *blk);
    virtual char *block::type();
    char *block::name();
    int block::is-movable();
//  deleted several members from example protected:
    char *nm;
    int movable;
    int width;
    int height;
    class point  position;
    class load-bearing-block *supported-by;
    Panel-item panel-item;
    /* from base class table::load-bearing-block */
    load-bearing-block::load-bearing-block(char *name, int w, int h,
        const class point &pos, class load-bearing-block *blk);
    virtual int load-bearing-block::is-load-bearing();
    virtual class list *load-bearing-block::supported-blocks();
    void load-bearing-block::add-supported-block(class block &b);
    void load-bearing-block::remove-supported-block(class block &b);
    virtual void load-bearing-block::print-supported-blocks();
    virtual void load-bearing-block::clear-top();
    virtual void load-bearing-block::put-on(class block &object);
    class point load-bearing-block::get-space(class block &object);
    class point load-bearing-block::find-space(class block &object);
    class point load-bearing-block::make-space(class block &object);
    class list *support-for;
    /* from class table */
    table::table(char *name, int w, int h, const class point &pos);
    virtual char *table::type();
    virtual void table::draw(unsigned long pw);