public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/45088]  New: pointer type information lost in debuginfo
@ 2010-07-26 19:25 tromey at gcc dot gnu dot org
  2010-07-27  8:29 ` [Bug debug/45088] " jakub at gcc dot gnu dot org
  0 siblings, 1 reply; 12+ messages in thread
From: tromey at gcc dot gnu dot org @ 2010-07-26 19:25 UTC (permalink / raw)
  To: gcc-bugs

I'm using r162345 on x86 Fedora 13.

This test case comes from the gdb test suite.

struct A
{
  virtual ~A ();
  int a1;
};

A::~A()
{
  a1 = 800;
}

struct B : public A
{
  virtual ~B ();
  int b1;
  int b2;
};

B::~B()
{
  a1 = 900;
  b1 = 901;
  b2 = 902;
}

struct C : public B
{
  A *c1;
  A *c2;
};

// Stop the compiler from optimizing away data.
void refer (A *)
{
  ;
}

struct empty {};

// Stop the compiler from optimizing away data.
void refer (empty *)
{
  ;
}

int main (void)
{
  A alpha, *aap, *abp, *acp;
  B beta, *bbp;
  C gamma;
  empty e;

  alpha.a1 = 100;
  beta.a1 = 200; beta.b1 = 201; beta.b2 = 202;
  gamma.c1 = 0; gamma.c2 = (A *) ~0UL;

  aap = α refer (aap);
  abp = β  refer (abp);
  bbp = β  refer (bbp);
  acp = γ refer (acp);
  refer (&e);

  return 0;  // marker return 0
} // marker close brace


When I compile this I see that the type of the "c1" field is bad:

 <2><48>: Abbrev Number: 5 (DW_TAG_member)
    <49>   DW_AT_name        : c1       
    <4c>   DW_AT_decl_file   : 1        
    <4d>   DW_AT_decl_line   : 46       
    <4e>   DW_AT_type        : <0x116>  
    <52>   DW_AT_data_member_location: 2 byte block: 23 10     
(DW_OP_plus_uconst: 16)
[...]
 <1><116>: Abbrev Number: 11 (DW_TAG_pointer_type)
    <117>   DW_AT_byte_size   : 4       

That is, gcc claims that this field is a "void *", which is not the case.


-- 
           Summary: pointer type information lost in debuginfo
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tromey at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug debug/45088] pointer type information lost in debuginfo
  2010-07-26 19:25 [Bug debug/45088] New: pointer type information lost in debuginfo tromey at gcc dot gnu dot org
@ 2010-07-27  8:29 ` jakub at gcc dot gnu dot org
  0 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-27  8:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jakub at gcc dot gnu dot org  2010-07-27 08:29 -------
So, to add c1's type, we call gen_typedef_with_usage with A typedef variant.
19880  /* If TYPE is a typedef type variant, let's generate debug info
19881     for the parent typedef which TYPE is a type of.  */
19882  if (typedef_variant_p (type))
19883    {
19884      if (TREE_ASM_WRITTEN (type))
19885        return;
19886
19887      /* Prevent broken recursion; we can't hand off to the same type.  */
19888      gcc_assert (DECL_ORIGINAL_TYPE (TYPE_NAME (type)) != type); 
19889
19890      /* Use the DIE of the containing namespace as the parent DIE of
19891         the type description DIE we want to generate.  */
19892      if (DECL_CONTEXT (TYPE_NAME (type))
19893          && TREE_CODE (DECL_CONTEXT (TYPE_NAME (type))) ==
NAMESPACE_DECL)
19894        context_die = get_context_die (DECL_CONTEXT (TYPE_NAME (type)));
19895
19896      TREE_ASM_WRITTEN (type) = 1;
19897
19898      gen_decl_die (TYPE_NAME (type), NULL, context_die); 
19899      return;

TREE_ASM_WRITTEN is not set on type originally, we compute context_die.  Then
set TREE_ASM_WRITTEN and call gen_decl_die.  TYPE_NAME (type) is a redundant
typedef though, so in gen_decl_die:
20544      if (is_redundant_typedef (decl))
20545        gen_type_die (TREE_TYPE (decl), context_die);
and TREE_TYPE (decl) here is the type on which we've just set TREE_ASM_WRITTEN,
so gen_type_die_with_usage is recursed with the same type and as
TREE_ASM_WRITTEN is now already set, it returns immediately, without creating
any type.  So, I think we need to special case is_redundant_typedef (TYPE_NAME
(type))) in gen_type_die_with_usage in the typedef_variant_p (type) handling
and ensure we actually create the DECL_ORIGINAL_TYPE in that case and equate
that also to the underlying type.  Or this could be a bug in the FE.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot
                   |                            |org, dodji at gcc dot gnu
                   |                            |dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug debug/45088] pointer type information lost in debuginfo
       [not found] <bug-45088-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2012-04-19  8:11 ` pluto at agmk dot net
@ 2012-04-19 19:09 ` jason at gcc dot gnu.org
  9 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2012-04-19 19:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088

--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> 2012-04-19 19:09:14 UTC ---
(In reply to comment #10)
> what about 4.7 branch?

The fix was on the trunk before 4.7 branched, so yes.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug debug/45088] pointer type information lost in debuginfo
       [not found] <bug-45088-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2011-03-15 10:21 ` dodji at gcc dot gnu.org
@ 2012-04-19  8:11 ` pluto at agmk dot net
  2012-04-19 19:09 ` jason at gcc dot gnu.org
  9 siblings, 0 replies; 12+ messages in thread
From: pluto at agmk dot net @ 2012-04-19  8:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088

Pawel Sikora <pluto at agmk dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pluto at agmk dot net

--- Comment #10 from Pawel Sikora <pluto at agmk dot net> 2012-04-19 08:07:28 UTC ---
what about 4.7 branch?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug debug/45088] pointer type information lost in debuginfo
       [not found] <bug-45088-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2010-12-17 10:39 ` dodji at gcc dot gnu.org
@ 2011-03-15 10:21 ` dodji at gcc dot gnu.org
  2012-04-19  8:11 ` pluto at agmk dot net
  2012-04-19 19:09 ` jason at gcc dot gnu.org
  9 siblings, 0 replies; 12+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-03-15 10:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088

Dodji Seketeli <dodji at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #9 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-03-15 10:12:06 UTC ---
Fixed in 4.6


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug debug/45088] pointer type information lost in debuginfo
       [not found] <bug-45088-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2010-11-12 12:19 ` dodji at gcc dot gnu.org
@ 2010-12-17 10:39 ` dodji at gcc dot gnu.org
  2011-03-15 10:21 ` dodji at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: dodji at gcc dot gnu.org @ 2010-12-17 10:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088

--- Comment #8 from Dodji Seketeli <dodji at gcc dot gnu.org> 2010-12-17 10:39:23 UTC ---
Author: dodji
Date: Fri Dec 17 10:39:21 2010
New Revision: 167976

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167976
Log:
Fix for PR debug/45088

gcc/

    * dwarf2out.c (gen_type_die_with_usage): Do not try to emit debug
    info for a redundant typedef that has DECL_ORIGINAL_TYPE set. Use
    that underlying type instead.

gcc/testsuite/

    * g++.dg/debug/dwarf2/self-ref-1.C: New test.
    * g++.dg/debug/dwarf2/self-ref-2.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug debug/45088] pointer type information lost in debuginfo
       [not found] <bug-45088-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2010-11-11 15:43 ` dodji at gcc dot gnu.org
@ 2010-11-12 12:19 ` dodji at gcc dot gnu.org
  2010-12-17 10:39 ` dodji at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: dodji at gcc dot gnu.org @ 2010-11-12 12:19 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088

--- Comment #7 from Dodji Seketeli <dodji at gcc dot gnu.org> 2010-11-12 12:05:55 UTC ---
Finally the patch I pasted earlier wasn't good enough. I modified it
and proposed it to
http://gcc.gnu.org/ml/gcc-patches/2010-11/msg01277.html


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug debug/45088] pointer type information lost in debuginfo
       [not found] <bug-45088-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2010-11-11 15:37 ` dodji at gcc dot gnu.org
@ 2010-11-11 15:43 ` dodji at gcc dot gnu.org
  2010-11-12 12:19 ` dodji at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: dodji at gcc dot gnu.org @ 2010-11-11 15:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088

--- Comment #6 from Dodji Seketeli <dodji at gcc dot gnu.org> 2010-11-11 15:43:17 UTC ---
I believe this is a smaller reproducer (the type of *a1 is not present
in debug info):

struct A
{
    virtual ~A();
};

struct B : public A
{
    virtual ~B(){}
};

struct C : public B
{
    A* a1;
};

int
main()
{
    C c;
    c.a1 = 0;
    return 0;
}


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug debug/45088] pointer type information lost in debuginfo
       [not found] <bug-45088-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2010-09-27 18:34 ` redi at gcc dot gnu.org
@ 2010-11-11 15:37 ` dodji at gcc dot gnu.org
  2010-11-11 15:43 ` dodji at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: dodji at gcc dot gnu.org @ 2010-11-11 15:37 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088

Dodji Seketeli <dodji at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2010.11.11 15:37:04
                 CC|dodji at gcc dot gnu.org    |
         AssignedTo|unassigned at gcc dot       |dodji at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #5 from Dodji Seketeli <dodji at gcc dot gnu.org> 2010-11-11 15:37:04 UTC ---
Following the (IMHO correect) analysis of Jakub, an interesting
question would be:

  Why is the type of *c1 a typedef variant of "A" instead
  of being just "A"?

It's actually the "self reference type" of A. In struct A, the
standard asks to inject the name A into the struct A itself, so that
looking up A::A or C::A succeeds. G++ creates a special typedef of A
(named self reference type in G++ speak) and injects that typedef into
A.

So from inside struct C, when considering "A *c1", the lookup of A
returns the self reference type of A. I think after the lookup
succeeds, G++ should retain A as the type of *c1; not the self
reference. Otherwise that confuses the debug info emitter as this bug
suggests.

I am about to test the patch below that hopefully does what I would
want. It's actually the second hunk that fixes this case because it
does what I am saying for the simple-type-specifier production.

The first hunk is something I noticed while looking at this issue. The
initial code in check_elaborated_type_specifier actually tries to do
what I am saying (for the elaborated-type-specifier production) but I
believe it fails in doing so, probably because the way self references
are represented has changed since the code was written.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index fb5ca7f..feba130 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10902,7 +10902,7 @@ check_elaborated_type_specifier (enum tag_types
tag_code,
      name lookup will find the TYPE_DECL for the implicit "S::S"
      typedef.  Adjust for that here.  */
   if (DECL_SELF_REFERENCE_P (decl))
-    decl = TYPE_NAME (TREE_TYPE (decl));
+    decl = TYPE_NAME (DECL_ORIGINAL_TYPE (decl));

   type = TREE_TYPE (decl);

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 6a9e4d7..d70c621 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -12791,6 +12791,11 @@ cp_parser_simple_type_specifier (cp_parser* parser,
       /* Otherwise, look for a type-name.  */
       else
     type = cp_parser_type_name (parser);
+
+      if (type && TREE_CODE (type) == TYPE_DECL
+      && DECL_SELF_REFERENCE_P (type))
+    type = TYPE_NAME (DECL_ORIGINAL_TYPE (type));
+
       /* Keep track of all name-lookups performed in class scopes.  */
       if (type
       && !global_p


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug debug/45088] pointer type information lost in debuginfo
       [not found] <bug-45088-4@http.gcc.gnu.org/bugzilla/>
  2010-09-27 18:21 ` uweigand at gcc dot gnu.org
  2010-09-27 18:34 ` uweigand at gcc dot gnu.org
@ 2010-09-27 18:34 ` redi at gcc dot gnu.org
  2010-11-11 15:37 ` dodji at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2010-09-27 18:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-09-27 16:22:18 UTC ---
is this another dup of PR 43628?  should be fixed if it is


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug debug/45088] pointer type information lost in debuginfo
       [not found] <bug-45088-4@http.gcc.gnu.org/bugzilla/>
  2010-09-27 18:21 ` uweigand at gcc dot gnu.org
@ 2010-09-27 18:34 ` uweigand at gcc dot gnu.org
  2010-09-27 18:34 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: uweigand at gcc dot gnu.org @ 2010-09-27 18:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088

--- Comment #4 from Ulrich Weigand <uweigand at gcc dot gnu.org> 2010-09-27 16:25:01 UTC ---
(In reply to comment #3)
> is this another dup of PR 43628?  should be fixed if it is

No, unfortunately it's not.  In mainline and 4.5 (which have the 43628) fix,
all other GDB C++ test suite regressions over 4.4 are fixed, *except* for the
one described in this bug report.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug debug/45088] pointer type information lost in debuginfo
       [not found] <bug-45088-4@http.gcc.gnu.org/bugzilla/>
@ 2010-09-27 18:21 ` uweigand at gcc dot gnu.org
  2010-09-27 18:34 ` uweigand at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: uweigand at gcc dot gnu.org @ 2010-09-27 18:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45088

Ulrich Weigand <uweigand at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |uweigand at gcc dot gnu.org

--- Comment #2 from Ulrich Weigand <uweigand at gcc dot gnu.org> 2010-09-27 16:19:31 UTC ---
Any update on this bug?  I'm seeing this in 4.5 as well ...


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-04-19 19:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-26 19:25 [Bug debug/45088] New: pointer type information lost in debuginfo tromey at gcc dot gnu dot org
2010-07-27  8:29 ` [Bug debug/45088] " jakub at gcc dot gnu dot org
     [not found] <bug-45088-4@http.gcc.gnu.org/bugzilla/>
2010-09-27 18:21 ` uweigand at gcc dot gnu.org
2010-09-27 18:34 ` uweigand at gcc dot gnu.org
2010-09-27 18:34 ` redi at gcc dot gnu.org
2010-11-11 15:37 ` dodji at gcc dot gnu.org
2010-11-11 15:43 ` dodji at gcc dot gnu.org
2010-11-12 12:19 ` dodji at gcc dot gnu.org
2010-12-17 10:39 ` dodji at gcc dot gnu.org
2011-03-15 10:21 ` dodji at gcc dot gnu.org
2012-04-19  8:11 ` pluto at agmk dot net
2012-04-19 19:09 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).