whatis 命令可输出标识符、结构、类型和 C++ 类的声明或定义,或者表达式类型。您可以查找的标识符包括变量、函数、字段、数组和枚举常量。
有关更多信息,请参见whatis 命令。
要输出输出标识符的声明,请键入:
(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; |
(dbx) whatis the_table class table *the_table; . |
(dbx) whatis the_table->draw void table::draw(unsigned long pw); |
(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; |
whatis 命令的 -t 选项可显示类型的定义。对于 C++,whatis -t 显示的列表包括模板定义和类模板实例化。
(dbx) whatis -t type_or_class_name |
要查看继承成员,可以在 whatis 命令中使用 -r 选项(表示“递归”),该选项显示指定类的声明以及它从基类继承的成员。
(dbx) whatis -t -r class_name |
whatis -r 查询的输出可能会很长,具体取决于类分层结构以及类的大小。输出以从最原始的类继承的成员列表开头。插入的注释行将成员列表分到其各自的父类中。
以下是两个示例,它们使用了类 table,它是父类 load_bearing_block 的子类,而该父类又是 block 的子类。
如果不使用 -r,whatis 会报告在类 table 中声明的成员:
(dbx) whatis -t class table class table : public load_bearing_block { public: table::table(char *name, int w, int h, const class point &pos); virtual char *table::type(); virtual void table::draw(unsigned long pw); }; |
以下是对子类使用 whatis -r 以查看它继承的成员时的结果:
(dbx) whatis -t -r class table class table : public load_bearing_block { public: /* from base class table::load_bearing_block::block */ 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 */ public: load_bearing_block::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); protected: class list *support_for; /* from class table */ public: table::table(char *name, int w, int h, const class point &pos); virtual char *table::type(); virtual void table::draw(unsigned long pw); }; |