eclipse CDT中如何手动输入gdb命令
hc000 2009-07-26 10:57:58 在eclipse CDT中调试很不方便,主要是无法查看STL容器变量的值。查了下资料,发现可以通过如下方式查看vector(其它容器类似):
第一步: 定义打印输出每个元素的方法(甚至可以写成脚本放到特定的文件中,如.gdbinit):
void dump(const vector<string> & vec)
{
int i = 0;
for( vector<string>::const_iterator iter = vec.begin(); iter != vec.end(); ++ iter )
cerr << '[' << (i ++) << ']' << " = \"" << *iter << "\"" << endl;
}
第二步:在breakpoints处调用dump打印感兴趣的vector变量:
Breakpoint 1, MatchString::placeWords (this=0xbfe49633, matchString=@0xbfe495f0,
matchWords=@0xbfe495e4) at MatchString.cpp:120
120 int m = 51;
(gdb) call dump(matchWords)
[0] = "dog"
[1] = "cat"
[2] = "rat"
(gdb)
我的问题是:在eclipse CDT中如何输入gdb命令呢?请大家指教。