Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: [1/4] RFC: skip DIEs which only declare an enum
Date: Fri, 15 Jul 2011 18:08:00 -0000	[thread overview]
Message-ID: <m3pqlbbepo.fsf@fleche.redhat.com> (raw)

With -gdwarf-4:

-PASS: gdb.cp/classes.exp: print ('ClassWithEnum::PrivEnum') 42
-PASS: gdb.cp/classes.exp: print (ClassWithEnum::PrivEnum) 42
+FAIL: gdb.cp/classes.exp: print ('ClassWithEnum::PrivEnum') 42
+FAIL: gdb.cp/classes.exp: print (ClassWithEnum::PrivEnum) 42

What happens here is that gcc emits multiple .debug_type CUs.  While
reading one such CU, we see an empty declaration for PrivEnum.  This
gets turned into a symbol, and later we end up with an incomplete type.

This patch fixes the problem by simply skipping declaration-only enums.
This makes it so only the full definition is put into the symbol table,
letting check_typedef work.

This is one of the patches I am less sure about.  Is it really safe?  It
also may change the error a user sees in some obscure case -- but to my
mind there is not much practical difference between "type not found" and
"type found but useless".

Built and regtested by the buildbot.

Tom

b/gdb/ChangeLog:
2011-07-15  Tom Tromey  <tromey@redhat.com>

	* dwarf2read.c (process_enumeration_scope): Do nothing if DIE is a
	declaration.

From 70edf0b3d0c20619964be5692f4782efec033c94 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Thu, 14 Jul 2011 14:48:47 -0600
Subject: [PATCH 1/4] do not process an enum which is just a declaration

---
 gdb/ChangeLog    |    5 +++++
 gdb/dwarf2read.c |    3 +++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index fde5b6a..0fd3845 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7612,6 +7612,9 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
 {
   struct type *this_type;
 
+  if (die_is_declaration (die, cu))
+    return;
+
   this_type = get_die_type (die, cu);
   if (this_type == NULL)
     this_type = read_enumeration_type (die, cu);
-- 
1.7.6


             reply	other threads:[~2011-07-15 18:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-15 18:08 Tom Tromey [this message]
2011-07-15 18:50 ` Daniel Jacobowitz
2011-07-18 18:02   ` Tom Tromey
2011-07-18 20:14     ` Tom Tromey
2011-07-20 15:19       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3pqlbbepo.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox