Bug 10499 - Debug information for some C++ headers is missing classes (template specific?)
Summary: Debug information for some C++ headers is missing classes (template specific?)
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-debug
: 51873 (view as bug list)
Depends on: 12385
Blocks:
  Show dependency treegraph
 
Reported: 2003-04-25 14:36 UTC by Daniel Jacobowitz
Modified: 2024-01-23 15:27 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-01-23 00:00:00


Attachments
readelf --debug-dump output (10.13 KB, text/plain)
2003-07-05 14:57 UTC, Andrew Pinski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Jacobowitz 2003-04-25 14:36:00 UTC
Compile this testcase (from Ben Kosnik) with -g:
#include <sstream>

int main()
{
  std::stringstream s;  // (gdb) p s
  return 0;
}

Look in the debug info for information about stringstream.
In DWARF-2 (the problem is also visible in stabs+) this
is all there is:
 <3><ef9>: Abbrev Number: 17 (DW_TAG_typedef)
     DW_AT_name        : (indirect string, offset: 0xddd): stringstream 
     DW_AT_decl_file   : 3      
     DW_AT_decl_line   : 144    
     DW_AT_type        : <f13>  
 <1><f13>: Abbrev Number: 13 (DW_TAG_structure_type)
     DW_AT_name        : (indirect string, offset: 0x7b9): basic_stringstream<char,std::char_traits<char>,std::allocator<char> >
     DW_AT_declaration : 1      

i.e  just a declaration.

Also in 3.4, the typedef is emitted in the
DW_TAG_lexical_block associated with main.
That doesn't make a whole lot of sense and will eventually
confuse GDB.

Release:
3.4 20030308, 3.3 cvs, 3.2.3

Environment:
i686-pc-linux-gnu

How-To-Repeat:
Compile above testcase with -g
Comment 1 Daniel Jacobowitz 2003-04-25 14:36:00 UTC
Fix:
The debug information for the body of basic_stringstream needs
to be emitted.
Comment 2 Andrew Pinski 2003-07-05 14:55:06 UTC
I see the crash with gdb (5.1.90CVS-3) but with gdb 2003-07-04-cvs, I get the output:
{<basic_iostream<char,std::char_traits<char> >> = {<basic_istream<
char,std::char_traits<char> >> = {<basic_ios<char,std::char_traits<char> >> = <invalid 
address>,
      _vptr.basic_istream = 0x10, _M_gcount = 139083320}, <basic_ostream<
char,std::char_traits<char> >> = {_vptr.basic_ostream = 0x813c9c0}, <No data fields>},
  _M_stringbuf = {<basic_streambuf<char,std::char_traits<char> >> = 
{_vptr.basic_streambuf = 0x50, _M_in_beg = 0x11 <Address 0x11 out of bounds>,
      _M_in_cur = 0x851f948 <Address 0x851f948 out of bounds>, _M_in_end = 
0x86dd6f8 <Address 0x86dd6f8 out of bounds>, _M_out_beg = 0x10 <Address 0x10 out 
of bounds>,
      _M_out_cur = 0x10 <Address 0x10 out of bounds>, _M_out_end = 0x4212df00 "", 
_M_buf_locale = {static none = 0, static ctype = 1, static numeric = 2,
        static collate = 4, static time = 8, static monetary = 16, static messages = 32, static all 
= 63, _M_impl = 0x4212dfa8, static _S_classic = 0x400c6b9c,
        static _S_global = 0x400c6b9c, static _S_categories = 0x400b3ab0, static 
_S_categories_size = 6}}, _M_mode = 796225127, _M_string = {static npos = 
4294967295,
      _M_dataplus = {<allocator<char>> = {<No data fields>}, _M_p = 0x11 <Address 0x11 
out of bounds>}}}}

This is with the mainline gcc (20030705).
I will attach the output of readelf.
Can you look at the output and tell me if this bug still exists?
Comment 3 Andrew Pinski 2003-07-05 14:57:54 UTC
Created attachment 4349 [details]
readelf --debug-dump output
Comment 4 Daniel Jacobowitz 2003-07-15 20:50:20 UTC
Subject: Re:  [3.3, 3.4] Debug information for some C++ headers is missing classes (template specific?)

On Sat, Jul 05, 2003 at 02:55:08PM -0000, pinskia at physics dot uc dot edu wrote:
> Can you look at the output and tell me if this bug still exists?

What's the debugging output you put in the bug log from?  There's no
basic_iostream in this testcase at all.  From the readelf output, the
bug is still there.

Comment 5 Andrew Pinski 2003-07-24 19:00:22 UTC
I had forgot to copy and paste the "$1 = " in front of output (see the '{').
I see how you got confused.  
I also see how to detect the problem now in the "readelf --debug-dump" output.
It still exists on the mainline (20030724).
Comment 6 Dara Hazeghi 2003-08-23 01:51:30 UTC
Not a regression.
Comment 7 Andrew Pinski 2004-11-07 16:28:50 UTC
Maybe related to PR 12385.
Comment 8 Andrew Pinski 2012-01-16 18:55:29 UTC
*** Bug 51873 has been marked as a duplicate of this bug. ***
Comment 9 Richard Biener 2024-01-23 15:27:15 UTC
With gcc 7.5 and gcc 13.2 I see

(gdb) p/r s
$3 = <incomplete type>
(gdb) ptype s
type = std::stringstream

and the python pretty-printers "ICE" like

(gdb) p s
Python Exception <class 'IndexError'>: list index out of range

The DW_TAG_typedef is still as reported, to a DW_AT_declaration, and the
variable DIE only refers to the typedef DIE.

So - reconfirmed.  Might be also a C++ frontend representation issue.