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; |
変数を指定すると、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; |
whatis コマンドの -t オプションは、型の定義を表示します。C++ については、whatis -t で表示されるリストは、テンプレート定義およびクラステンプレート例示を含みます。
型または C++ のクラスの宣言を出力するには次のようにします。
(dbx) whatis -t type_or_class_name |
whatis コマンドには、継承されたメンバーを表示するための -r (再帰) オプションが用意されています。このオプションを指定すると、指定したクラスの宣言とともに、そのクラスが基となるクラスから継承したメンバーが表示されます。
(dbx) whatis -t -r class_name |
whatis -r による出力は、クラス階層と各クラスのサイズによって長くなることがあります。出力の先頭には、階層のもっとも上にあるクラスから継承されたメンバーのリストが示されます。メンバーのリストは、コメント行によって親クラスごとに分けられます。
ここに、2 つの例を示します。table クラスは、load_bearing_block クラスの子クラスの 1 つです。また、このクラスは、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); }; |