Bugzilla – Bug 157037
gdb fails to retrieve "optarg" correctly
Last modified: 2006-03-14 13:59:37 UTC
gdb cannot show the content if "optarg", a global glibc variable, correctly. The following sample program shows this behaviour: (gdb) break main Breakpoint 1 at 0x4004ec: file xx.c, line 4. (gdb) r Starting program: /suse/meissner/xx Breakpoint 1, main () at xx.c:4 4 return optarg; (gdb) disp /i $eip Disabling display 1 to avoid infinite recursion. 1: x/i $eip Value can't be converted to integer. (gdb) disp /i $rip 2: x/i $rip 0x4004ec <main+4>: mov 1049517(%rip),%rax # 0x5008a0 <optarg@@GLIBC_2.2.5> (gdb) si 5 } 2: x/i $rip 0x4004f3 <main+11>: leaveq (gdb) print optarg $1 = 0x0 (gdb) print &optarg $2 = (char **) 0x2ae8237f9cc0 (gdb) print &optarg should have shown 0x5008a0.
Created attachment 72258 [details] xx.c
gdb is just reporting what the debug info delivers. The symbol you want is called 'optarg@@GLIBC_2.2.5'.
What i want is that gdb shows me the right content of my variables. Do i understand that correctly that i had to type 'print optarg@@GLIBC_2.2.5' to see the value of what is called 'optarg' in my sources? Where in the docs can i read about that?