This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [1/4] RFC: skip DIEs which only declare an enum


>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> I am going withdraw this patch and look at other ways to fix this
Tom> problem.

Here is what I came up with.

It seems to me that the bad case is exactly when we are reading a
.debug_types CU and the enum type we are reading is not the signatured
type.  In this case, the enum type is needed for other types in the CU,
but doesn't need a symbol, as presumably there is some other
.debug_types CU that has the true definition.

So, this patch implements just this exception.  I rebased on it on patch
#2, so the series ordering is different now.

Built and regtested by the buildbot.

In the absence of comments I plan to commit this in a couple of days.

Tom


2011-07-18  Tom Tromey  <tromey@redhat.com>

	* dwarf2read.c (process_enumeration_scope): Do not call new_symbol
	in some declaration-only cases.

>From 79fc44c91390d14bcf0f98f7e19d9b8888952595 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Mon, 18 Jul 2011 11:54:45 -0600
Subject: [PATCH 2/2] fix enum declaration regression

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

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 4c8a732..e6cc94a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1204,6 +1204,11 @@ static struct die_info *follow_die_sig (struct die_info *,
 					struct attribute *,
 					struct dwarf2_cu **);
 
+static struct signatured_type *lookup_signatured_type_at_offset
+    (struct objfile *objfile,
+     struct dwarf2_section_info *section,
+     unsigned int offset);
+
 static void read_signatured_type_at_offset (struct objfile *objfile,
 					    struct dwarf2_section_info *sect,
 					    unsigned int offset);
@@ -7714,6 +7719,27 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
 	TYPE_UNSIGNED (this_type) = 1;
     }
 
+  /* If we are reading an enum from a .debug_types unit, and the enum
+     is a declaration, and the enum is not the signatured type in the
+     unit, then we do not want to add a symbol for it.  Adding a
+     symbol would in some cases obscure the true definition of the
+     enum, giving users an incomplete type when the definition is
+     actually available.  Note that we do not want to do this for all
+     enums which are just declarations, because C++0x allows forward
+     enum declarations.  */
+  if (cu->per_cu->debug_type_section
+      && die_is_declaration (die, cu))
+    {
+      struct signatured_type *type_sig;
+
+      type_sig
+	= lookup_signatured_type_at_offset (dwarf2_per_objfile->objfile,
+					    cu->per_cu->debug_type_section,
+					    cu->per_cu->offset);
+      if (type_sig->type_offset != die->offset)
+	return;
+    }
+
   new_symbol (die, this_type, cu);
 }
 
-- 
1.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]