Sun Studio 12:使用 dbx 调试程序

查找变量、成员和函数的定义

要打印输出标识符的声明,请键入:


(dbx) whatis identifier

根据需要使用文件和函数信息来限定标识符名。

对于 C++ 程序,whatis identifier 会列出函数模板实例化。可使用 whatis -t identifier 显示模板定义。请参见查找类型和类的定义

对于 Java 程序,whatis identifier 会列出类的声明、当前类中的方法、当前帧中的局部变量或当前类中的字段。

要打印成员函数,请键入:


(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();
:

要打印数据成员,请键入:


(dbx) whatis block::movable
int movable;

对于变量,whatis 会输出变量的类型。


(dbx) whatis the_table
class table *the_table;
.

对于字段,whatis 会给出字段的类型。


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

当程序在成员函数中停止时,可以查找 this 指针。


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