gdb reports wrong values in simple program. Why?
#include <iostream>开发者_JAVA百科;
int main ()
{
int* a = new int[15];
a[0] = 42;
a[1] = 43;
std::cerr << a[0];
return 0;
}
gdb says a = 0xffffffff and 'print a[0]' gives 'cannot access memory address' but why? If run outside of gdb, the program prints out '42' as expected. What is going on here? Compiled with 'g++ test2.cpp -gstabs+ -O0 -o test2'.
Which platform are you are on? The gstabs+ debugger format is not universally supported, if you want to use it you must acquaint yourself with the fascinating differences between COFF, DWARF 2 and probably some other exe/debug formats I've never heard of. Bottom line - read the gdb manual. But your code will almost certainly work correctly if you simply use the -g flag.
Yep I can reproduce that, but only with -gstabs+
So: why are you using -gstabs+
?
It doesn't sound fair, but it is an honest question, what advantage does stabs+ bring over 'normal' debug info?
精彩评论