Bug 44645 - [4.5 Regression] missing debug info for pointer types
Summary: [4.5 Regression] missing debug info for pointer types
Status: RESOLVED DUPLICATE of bug 43628
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.0
: P2 normal
Target Milestone: 4.5.2
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-debug
: 45181 45334 45717 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-06-23 10:53 UTC by Jonathan Wakely
Modified: 2010-09-18 14:13 UTC (History)
10 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.3 4.6.0
Known to fail: 4.5.0 4.5.1
Last reconfirmed: 2010-07-21 15:50:23


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2010-06-23 10:53:33 UTC
this breaks debugging of std::map and other tree-based containers in the library, see http://gcc.gnu.org/ml/libstdc++/2010-06/msg00159.html for more info

$ cat debug2.cc
struct S
{
    typedef S* ptr;
    ptr p;
};

int main()
{
    S s = { };
    return !s.p;
}
$ $GCC45/bin/g++ -g -Wl,-R$GCC45/lib64 debug2.cc -o out2-45
$ gdb --quiet ./out2-45
Reading symbols from /tmp/out2-45...done.
(gdb) ptype S
type = struct S {
    S::ptr p;
}
(gdb) ptype S::p
type = void *

That type is wrong, it should be S* not void*

GCC 4.4 gets it right, by not tracking the typedef at all:

(gdb) ptype S
type = struct S {
    S *p;
}
(gdb) ptype S::p
type = struct S {
    S *p;
} *


GCC 4.6 tracks the typedef and gets its type right:

(gdb) ptype S
type = struct S {
    S::ptr p;
}
(gdb) ptype S::p
type = struct S {
    S::ptr p;
} *
Comment 1 Jonathan Wakely 2010-07-13 11:54:19 UTC
Oops, this should be Component=debug
Comment 2 Jonathan Wakely 2010-07-21 15:50:23 UTC
Am I allowed to confirm my own bugs?  doing so anyway

There's no difference when using -gdwarf-2 -gstrict-dwarf

readelf -wi for the output of g++ 4.5 shows S::ptr as:

<1><4f>: Abbrev Number: 5 (DW_TAG_pointer_type)
     DW_AT_byte_size   : 8

which is missing the type, so S::ptr is void*

The output of g++ 4.4 and 4.6 shows:

<1><4f>: Abbrev Number: 5 (DW_TAG_pointer_type)
     DW_AT_byte_size   : 8
     DW_AT_type        : <2d>

where <2d> is the info for S so S::ptr is S*

Comment 3 Richard Biener 2010-07-31 09:29:56 UTC
GCC 4.5.1 is being released, adjusting target milestone.
Comment 4 Jonathan Wakely 2010-08-19 12:19:58 UTC
*** Bug 45181 has been marked as a duplicate of this bug. ***
Comment 5 Jonathan Wakely 2010-08-19 12:22:02 UTC
*** Bug 45334 has been marked as a duplicate of this bug. ***
Comment 6 Jonathan Wakely 2010-08-19 12:26:11 UTC
(adjusting title to be more general)

testcase from dup Bug 45181

struct S { int f(S*); };

int S::f(S* p)
{
    return 0;
}

int main()
{
    S s;
    return s.f(&s);
}

within S::f p has type void*


Tom, CCing you as you've correctly identified this as a GCC 4.5 bug at http://gcc.gnu.org/ml/libstdc++/2010-06/msg00159.html and http://sourceware.org/bugzilla/show_bug.cgi?id=11639
Comment 7 Jonathan Wakely 2010-08-19 12:32:15 UTC
testcase from Bug 45334 reduced to a single file:

struct Base
{
    virtual ~Base();
};

Base::~Base() {}

struct Derived : Base
{
    virtual ~Derived();
    void foo();
};

Derived::~Derived() {}

void Derived::foo()
{
    Base *b = this;
    Base &br = *b;
}

int main()
{
    Derived d;
    d.foo();
    Base *b = &d;
}

Within Derived::foo b has type void*

Breakpoint 1, Derived::foo (this=0x7fffffffe5f0) at bug.cc:18
18          Base *b = this;
(gdb) ptype b
type = void *
Comment 8 Jonathan Wakely 2010-09-18 13:20:47 UTC
*** Bug 45717 has been marked as a duplicate of this bug. ***
Comment 9 H.J. Lu 2010-09-18 13:26:46 UTC
This is caused by revision 154354:

http://gcc.gnu.org/ml/gcc-cvs/2009-11/msg00575.html
Comment 10 H.J. Lu 2010-09-18 14:13:14 UTC

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