Oracle® Solaris Studio 12.4:使用 dbx 调试程序

退出打印视图

更新时间: 2015 年 1 月
 
 

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

使用 whatis 命令可输出标识符的声明:

(dbx) whatis identifier

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

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

对于 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;