在模板和模板实例中使用这些命令。知道类或类型定义后,便可以输出值、显示源码列表或设置断点。
使用 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 命令可输出函数模板和类模板的定义以及实例化的函数和类。
对于类模板:
(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 命令。
(dbx)stop inclass Array (2) stop inclass Array |
可使用 stop inclass 命令在特定模板类的所有成员函数中设置断点:
(dbx) stop inclass Array<int> (2) stop inclass Array<int> |
有关更多信息,请参见stop 命令和inclass classname [-recurse | -norecurse]。
可使用 stop infunction 命令在指定函数模板的所有实例中设置断点
(dbx) stop infunction square (9) stop infunction square |
有关更多信息,请参见stop 命令和infunction function。
可使用 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 function。
可使用 call 命令在作用域中停止时显式调用函数实例或类模板的成员函数。如果 dbx 无法确定正确的实例,它会显示一个带编号的实例列表,您可以从列表中进行选择。
(dbx) call square(j,&i) |
有关更多信息,请参见call 命令。
(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 命令。
(dbx) list square(int, int*) |
有关更多信息,请参见list 命令。