Bug 15111 - GDB will not print the value of a variable if there exists a type of the same name
Summary: GDB will not print the value of a variable if there exists a type of the same...
Status: RESOLVED DUPLICATE of bug 7737
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-06 21:06 UTC by Matthew Gretton-Dann
Modified: 2013-07-30 06:34 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Source for test case (209 bytes, text/x-c++src)
2013-02-06 21:06 UTC, Matthew Gretton-Dann
Details
DWARF .debug_info section produced by GCC for the test case. (6.25 KB, text/plain)
2013-02-06 21:08 UTC, Matthew Gretton-Dann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Gretton-Dann 2013-02-06 21:06:27 UTC
Created attachment 6850 [details]
Source for test case

Given the attached gdb-test.cpp file compiled as follows:
 $ g++ -O2 -g gdb-test.cpp -o gdb-test

This program has a structure named fibs and a global variable also named fibs.  When you use gdb (as follows) you cannot get to the value of the global variable because GDB seems to only see the typename:

 $ gdb ./gdb-test

 (gdb) start
 ...
 (gdb) print fibs
 Attempt to use a typename as an expression

(This is the instance of that error from gdb/expr.c)

The .debug_info section seems to be correct (objdump --dwarf=info output also attached).
Comment 1 Matthew Gretton-Dann 2013-02-06 21:08:16 UTC
Created attachment 6851 [details]
DWARF .debug_info section produced by GCC for the test case.
Comment 2 Ben Longbons 2013-07-30 06:34:21 UTC
bugzilla requires a message when marking a duplicate

*** This bug has been marked as a duplicate of bug 7737 ***