Debugging a Program With dbx

Looking Up Definitions of Variables, Members, and Functions

To print out the declaration of an identifier:


(dbx) whatis identifier

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

To print out the member function


(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();
Notice that table::pos is inherited from block:
(dbx) whatis table::pos
class point *block::pos();

:

To print out the data member:


(dbx) whatis block::movable
int movable;

On a variable, whatis tells you the variable`s type:


(dbx) whatis the_table
class table *the_table;

On a field, whatis tells you 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 lookup the this pointer. In this example, the output from the whatis shows that the compiler automatically allocated this variable to a register.


(dbx) stop in brick::draw
(dbx) cont
// expose the blocks window (if exposed, hide then expose) to force program to hit the breakpoint.
(dbx) where 1
brick::draw(this = 0x48870, pw = 374752), line 124 in
     "block_draw.cc"
(dbx) whatis this
class brick *this;