Oracle® Solaris Studio 12.4: dbx コマンドによるデバッグ

印刷ビューの終了

更新: 2015 年 1 月
 
 

C++ テンプレートのコマンド

次に示すコマンドは、テンプレートおよびインスタンス化されたテンプレートに使用します。クラスまたは型定義がわかったら、値の出力、ソースリストの表示、またはブレークポイントの設定を行うことができます。

whereis コマンド

whereis コマンドは、 関数またはクラステンプレートの関数またはクラスのインスタンス化のすべての発生のリストを出力するために使用します。

クラステンプレートの場合は、次のように入力します。

(dbx) whereis Array
member function: `Array<int>::Array(int)
member function: `Array<double>::Array(int)
class template instance: `Array<int>
class template instance: `Array<double>
class template: `a.out`template_doc_2.cc`Array

関数テンプレートの場合は、次のように入力します。

(dbx) whereis square
function template instance: `square<int>(__type_0,__type_0*)
function template instance: `square<double>(__type_0,__type_0*)

__type_0 パラメータは、0 番目のパラメータを表します。__type_1 パラメータは、次のパラメータを表します。

詳細については、whereis コマンドを参照してください。

whatis コマンド

whatis コマンドは、 関数およびクラステンプレートと、インスタンス化された関数およびクラスの定義を出力するために使用します。

クラステンプレートの場合は、次のように入力します。

(dbx) whatis -t Array
template<class T> class Array
To get the full template declaration, try `whatis -t Array<int>’;

クラステンプレートの構造については次のように実行します。

(dbx) whatis Array
More than one identifier ’Array’.
Select one of the following:
 0) Cancel
 1) Array<int>::Array(int)
 2) Array<double>::Array(int>
> 1
Array<int>::Array(int 1);

関数テンプレートの場合は、次のように入力します。

(dbx) whatis square
More than one identifier ’square’.
Select one of the following:
 0) Cancel
 1) square<int(__type_0,__type_0*)
 2) square<double>(__type_0,__type_0*)
> 2
void square<double>(double num, double *result);

クラステンプレートのインスタンス化の場合は、次のように入力します。

(dbx) whatis -t Array<double>
class Array<double>; {
public:
    int Array<double>::getlength()
    double &Array<double>::operator [](int i);
    Array<double>::Array<double>(int l);
    Array<double>::~Array<double>();
private:
    int length;
    double *array;
};

関数テンプレートのインスタンス化の場合は、次のように入力します。

(dbx) whatis square(int, int*)
void square(int num, int *result);

詳細については、whatis コマンドを参照してください。

stop inclass コマンド

テンプレートクラスのすべてのメンバー関数内で 停止するには、次のように入力します。

(dbx)stop inclass Array
(2) stop inclass Array

stop inclass コマンドは、特定のテンプレートクラスのすべてのメンバー関数にブレークポイントを設定するために使用します。

(dbx) stop inclass Array<int>
(2) stop inclass Array<int>

詳細については、stop コマンドおよびinclass イベント指定を参照してください。

stop infunction コマンド

stop infunction コマンドは、 指定した関数テンプレートのすべてのインスタンスにブレークポイントを設定するために使用します。

(dbx) stop infunction square
(9) stop infunction square

詳細については、stop コマンドおよびinfunction イベント指定を参照してください。

stop in コマンド

stop in コマンドは、 テンプレートクラスのメンバー関数、またはテンプレート関数にブレークポイントを設定するために使用します。

クラスインスタンス化のメンバーの場合は、次のとおりです。

(dbx) stop in Array<int>::Array(int l)
(2) stop in Array<int>::Array(int)

関数インスタンス化の場合は、次のように入力します。

(dbx) stop in square(double, double*)
(6) stop in square(double, double*)

詳細については、stop コマンドおよびin イベント指定を参照してください。

call コマンド

call コマンドは、 スコープ内で停止した場合に、関数のインスタンス化またはクラステンプレートのメンバー関数を明示的に呼び出すために使用します。dbx が正しいインスタンスを判断できない場合、ユーザーが選択できる番号付きのインスタンスのリストが表示されます。

(dbx) call square(j,&i)

詳細については、call コマンドを参照してください。

print

print コマンドは、 関数のインスタンス化またはクラステンプレートのメンバー関数を評価するために使用します。

(dbx) print iarray.getlength()
iarray.getlength() = 5

print を使用して this ポインタを評価します。

(dbx) whatis this
class Array<int> *this;
(dbx) print *this
*this = {
    length = 5
    array   = 0x21608
}

詳細については、print コマンドを参照してください。

list

list コマンドは、 指定した関数のインスタンス化のソースリストを出力するために使用します。

(dbx) list square(int, int*)

詳細については、list コマンドを参照してください。