public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "mjw at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug translator/14434] dwflpp sometimes caches incomplete class_type
Date: Sun, 05 Aug 2012 18:56:00 -0000	[thread overview]
Message-ID: <bug-14434-6586-AdKaNftKxd@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-14434-6586@http.sourceware.org/bugzilla/>

http://sourceware.org/bugzilla/show_bug.cgi?id=14434

--- Comment #2 from Mark Wielaard <mjw at redhat dot com> 2012-08-05 18:55:45 UTC ---
Proposed patch/workaround:

diff --git a/dwflpp.cxx b/dwflpp.cxx
index 3fb50b2..ea93469 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -791,6 +791,32 @@ cache_type_prefix(Dwarf_Die* type)
   return "";
 }

+/* GCC might generate a struct/class without DW_AT_declaration,
+   but that only contains members which have DW_AT_declaration
+   set.  We aren't interested in those.  PR14434 (GCC bug #54181).  */
+static bool
+has_only_decl_members (Dwarf_Die *die)
+{
+  Dwarf_Die child;
+  if (dwarf_child(die, &child) != 0)
+    return false; /* no members */
+
+  do
+    {
+      if (! dwarf_hasattr(&child, DW_AT_declaration))
+    return false; /* real member found.  */
+      int tag = dwarf_tag(&child);
+      if ((tag == DW_TAG_namespace
+           || tag == DW_TAG_structure_type
+           || tag == DW_TAG_class_type)
+          && ! has_only_decl_members (&child))
+    return false; /* real grand child member found.  */
+    }
+  while (dwarf_siblingof(&child, &child) == 0);
+
+  return true; /* Tried all children and grandchildren. */
+}
+
 int
 dwflpp::global_alias_caching_callback(Dwarf_Die *die, bool has_inner_types,
                                       const string& prefix, void *arg)
@@ -798,7 +824,8 @@ dwflpp::global_alias_caching_callback(Dwarf_Die *die, bool
has_inner_types,
   cu_type_cache_t *cache = static_cast<cu_type_cache_t*>(arg);
   const char *name = dwarf_diename(die);

-  if (!name || dwarf_hasattr(die, DW_AT_declaration))
+  if (!name || dwarf_hasattr(die, DW_AT_declaration)
+      || has_only_decl_members(die))
     return DWARF_CB_OK;

   int tag = dwarf_tag(die);

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

  parent reply	other threads:[~2012-08-05 18:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-05 18:25 [Bug translator/14434] New: " mjw at redhat dot com
2012-08-05 18:51 ` [Bug translator/14434] " mjw at redhat dot com
2012-08-05 18:56 ` mjw at redhat dot com [this message]
2012-08-06 22:39 ` mjw at redhat dot com

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=bug-14434-6586-AdKaNftKxd@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).