whatis コマンドは、識別子、構造体、型、C++ のクラス、式の型の宣言または定義を出力します。検査できる識別子には、変数、関数、フィールド、配列、列挙定数が含まれます。
詳細については、whatis コマンドを参照してください。
識別子の宣言を出力するには、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;
whatis コマンドの -t オプションは、型の定義を表示します。 C++ については、whatis -t で表示されるリストは、テンプレート定義およびクラステンプレート例示を含みます。
型または C++ クラスの宣言を出力するには、次のように入力します。
(dbx) whatis -t class-name
データメンバーのみを表示するには、–a オプションとともに whatis コマンドを使用します。このオプションは、特定のクラスのデータメンバーの一覧のみを出力します (そのメンバーの関数は出力しません)。これは、この情報を、–r オプションと同じ順序で基底クラスから表示します。
(dbx) whatis -t -a class-name
基底クラス内のメンバーを表示するために、whatis コマンドは -r オプション (再帰的) を取ります。これによって、指定されたクラスの宣言と、このクラスが基底クラスから継承するメンバーが表示されます。
(dbx) whatis -t -r class-name
whatis -r の問い合わせからの出力は、クラス階層やクラスサイズによっては長くなることがあります。出力には、継承されたデータメンバーのリストが階層のもっとも上にあるクラスから表示されます。メンバーのリストは、コメント行によって親クラスごとに分けられます。
クラスの継承されたメンバーのルートを表示するために、whatis コマンドは、型定義のルートを表示する -u オプションを受け取ります。-u オプションを指定しないと、whatis コマンドは、値の履歴にある最後の値を表示します。これは、gdb で使用される ptype コマンドと同様です。
次の 2 つの例では、親クラス load-bearing-block の子クラスであるクラス table を使用しています。この親クラスはさらに、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); };