Bug 157037

Summary: gdb fails to retrieve "optarg" correctly
Product: [openSUSE] SUSE Linux 10.1 Reporter: Marcus Meissner <meissner>
Component: DevelopmentAssignee: Andreas Schwab <schwab>
Status: RESOLVED INVALID QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: pth
Version: Beta 7   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: xx.c

Description Marcus Meissner 2006-03-10 13:21:46 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.
Comment 1 Marcus Meissner 2006-03-10 13:29:05 UTC
Created attachment 72258 [details]
xx.c
Comment 2 Andreas Schwab 2006-03-13 12:24:21 UTC
gdb is just reporting what the debug info delivers.  The symbol you want is called 'optarg@@GLIBC_2.2.5'.
Comment 3 Christian Zoz 2006-03-14 13:59:37 UTC
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?