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]

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


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


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