Stepping through C code in gdb using Eclipse, I noticed that for a variable char* sval
gdb prints (in Expressions tab):
通过使用Eclipse在gdb中执行C代码,我注意到对于一个变量char* sval gdb打印(在表达式选项卡中):
- Expression: sval
- 表情:sval
- Type: char*
- 类型:char *
- Value: 0x7fffd9d79840 "BIDPRICE"
- 值:0 x7fffd9d79840“BIDPRICE”
However I know that the value should be something different (say, "BIDZSPD") because it was assigned a few lines above. Indeed, the value of sval[3]
is 'Z', as expected.
但是我知道值应该是不同的(比如“BIDZSPD”),因为它在上面被分配了几行。确实,sval[3]的值是“Z”,如预期。
Then I noticed the following in the expressions view, same as in mouse-over on a variable:
然后,我注意到表达式视图中的以下内容,与mouse-over中的变量相同:
Name : sval
Details:0x7fffd9d79840 "BIDZSPD"
Default:0x7fffd9d79840 "BIDPRICE"
Decimal:140736848173120
Hex:0x7fffd9d79840
Binary:11111111111111111011001110101111001100001000000
Octal:03777773165714100
Looks like different representations of char pointer, but why Details is different from Default? Should I interpret "Default" as previous value? Why Default is shown as expression value, and not current value?
看起来不同于char指针的表示,但是为什么细节不同于默认?我应该将“默认”解释为先前的值吗?为什么默认值显示为表达式值,而不是当前值?
1 个解决方案
#1
0
Full build fixed it. This is one of the things one needs to keep in mind when working with C++: if things look really screwy (like gdb reporting different values by the same address), you have to bite the bullet and do a full build.
全面构建固定它。在使用c++时,需要记住这一点:如果事情看起来非常糟糕(比如gdb通过相同的地址报告不同的值),那么您必须咬紧牙关,进行完整的构建。
#1
0
Full build fixed it. This is one of the things one needs to keep in mind when working with C++: if things look really screwy (like gdb reporting different values by the same address), you have to bite the bullet and do a full build.
全面构建固定它。在使用c++时,需要记住这一点:如果事情看起来非常糟糕(比如gdb通过相同的地址报告不同的值),那么您必须咬紧牙关,进行完整的构建。