c++ - g++4.8 hides variables from gdb -


after upgrading g++ 4.8.1 i've found debugging impossible in gdb. g++ seems hide variables gdb, regardless of optimization options. in following session, runner.cpp follows:

#include <vector> using namespace std;  int main(void) {     vector<int> arr;      int = 3;     int b = 2;     b = + 3;      arr.push_back(1);     arr.push_back(2);     arr.push_back(3);     arr.push_back(4);      return 0; } 

this result:

script started on tue 14 jul 2015 01:11:14 pm pdt me@ministation:~/development/clib$ g++ -g -o0 runner.cpp  me@ministation:~/development/clib$ gdb -q ./a.out reading symbols /home/me/development/clib/a.out...done. (gdb) break 11 breakpoint 1 @ 0x40095c: file runner.cpp, line 11. (gdb) run starting program: /home/me/development/clib/a.out  warning: no loadable sections found in added symbol-file system-supplied dso @ 0x7ffff7ffa000  breakpoint 1, main () @ runner.cpp:11 11      arr.push_back(1); (gdb) print $1 = {i = {0, 1045149306}, d = 1.2904777690891933e-08} ## have no idea means (gdb) print b $2 = {i = {0, 1068498944}, d = 0.0625} (gdb) print arr no symbol "arr" in current context. (gdb) info locals no locals. (gdb) next 12      arr.push_back(2); (gdb)  13      arr.push_back(3); (gdb) print arr no symbol "arr" in current context. (gdb) next 14      arr.push_back(4); (gdb)  16      return 0; (gdb) print arr no symbol "arr" in current context. (gdb) q debugging session active.      inferior 1 [process 6392] killed.  quit anyway? (y or n) y me@ministation:~/development/clib$  script done on tue 14 jul 2015 01:12:05 pm pdt 

i've seen similar posts -o0 flag recommended, doesn't seem work here. exact same session after compiling g++4.6 produces expected results. ideas on what's causing g++4.8?

gdb , gcc need compatible versions when comes debug format (and quite compatible on many versions, compatibility broken 1 version of compiler another).

i have had same problem. solution either throw flag @ gcc compile "older style debug format", or upgrade version of gdb 1 "works" debug format given newer version of gcc.

it nice if gdb said "your debug format x, need debug format y or z gdb work correctly", i'm not 100% sure can reliably determined (for example when bug found in generation fixed, , need corresponding fix in debugger, because same bug appears in both "produce" , "consume" parts of debug-symbol handler - older, buggy version can't read newer unbuggy format , vice versa)


Comments