我试图找出我的 c++ 代码中的一个问题,并让 DDD 在 Sun 机器上进行调试。我需要按照我们拥有的某些标准使用字符串。但是每当 DDD 遇到一个字符串变量时,它总是显示为空。我想记得以前在 SGI 上使用 CVD 时遇到过同样的麻烦。
除了重写我的代码来删除字符串还有什么我可以尝试/使用的吗?
3 回答
1
Have a look here
They solve it by implementing a helper function that can be used by gdb (should also work for DDD as it uses gdb)
于 2010-02-03T17:06:46.037 回答
1
p variablename.c_str()
或者
display variablename.c_str()
于 2010-02-03T17:11:28.343 回答
0
基本上,您需要创建一个包装函数,通过传递一个内存地址来打印出您的字符串:
void gs(string &s) { cout << s << endl; }
然后在 gdb 中:
call gs(somevariable)
于 2010-02-03T17:12:12.110 回答