public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: dwz@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] Add DIE offsets in error messages to make it easier to find what is wrong.
Date: Tue, 26 Jan 2021 21:45:09 +0100	[thread overview]
Message-ID: <20210126204509.24710-1-mark@klomp.org> (raw)

With the following patch dwz will give a message like:

libmozjs-78.so: Couldn't find DIE at [bd6b507] referenced by
  DW_AT_abstract_origin from DIE at [bd5bb9b]

Which makes it a easier to figure out what is going on.

In the above case it is easy to find the producer of the CU of those
two DIEs. Which turned out the be is clang LLVM (rustc version 1.49.0)
which seems to have gotten the abstract origin reference wrong.
---
 dwz.c | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/dwz.c b/dwz.c
index 28f0c4d..1db93dd 100644
--- a/dwz.c
+++ b/dwz.c
@@ -2414,8 +2414,10 @@ read_exprloc (DSO *dso, dw_die_ref die, unsigned char *ptr, size_t len,
 	  ref = off_htab_lookup (cu, cu->cu_offset + addr);
 	  if (ref == NULL)
 	    {
-	      error (0, 0, "%s: Couldn't find DIE referenced by %s",
-		     dso->filename, get_DW_OP_str (op));
+	      error (0, 0, "%s: Couldn't find DIE at [%" PRIx64 "] "
+		     "referenced by %s from DIE at [%x]",
+		     dso->filename, cu->cu_offset + addr,
+		     get_DW_OP_str (op), die->die_offset);
 	      return 1;
 	    }
 	  if (op == DW_OP_call2)
@@ -2465,8 +2467,9 @@ read_exprloc (DSO *dso, dw_die_ref die, unsigned char *ptr, size_t len,
 	  ref = off_htab_lookup (NULL, addr);
 	  if (ref == NULL || (unlikely (low_mem) && ref->die_tag == 0))
 	    {
-	      error (0, 0, "%s: Couldn't find DIE referenced by %s",
-		     dso->filename, get_DW_OP_str (op));
+	      error (0, 0, "%s: Couldn't find DIE at [%" PRIx64 "] "
+		     "referenced by %s from DIE at [%x]",
+		     dso->filename, addr, get_DW_OP_str (op), die->die_offset);
 	      return 1;
 	    }
 	  ref->die_no_multifile = 1;
@@ -2551,8 +2554,10 @@ read_exprloc (DSO *dso, dw_die_ref die, unsigned char *ptr, size_t len,
 	  ref = off_htab_lookup (cu, cu->cu_offset + addr);
 	  if (ref == NULL)
 	    {
-	      error (0, 0, "%s: Couldn't find DIE referenced by %s",
-		     dso->filename, get_DW_OP_str (op));
+	      error (0, 0, "%s: Couldn't find DIE at [%" PRIx64 "] "
+			   "referenced by %s from DIE at [%x]",
+		     dso->filename, cu->cu_offset + addr,
+		     get_DW_OP_str (op), die->die_offset);
 	      return 1;
 	    }
 	  if (unlikely (low_mem))
@@ -3537,8 +3542,10 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die)
 	      ref = off_htab_lookup (cu, value);
 	      if (ref == NULL)
 		{
-		  error (0, 0, "%s: Couldn't find DIE referenced by %s",
-			 dso->filename, get_DW_AT_str (t->attr[i].attr));
+		  error (0, 0, "%s: Couldn't find DIE at [%" PRIx64 "] "
+			       "referenced by %s from DIE at [%x]",
+			 dso->filename, value,
+			 get_DW_AT_str (t->attr[i].attr), die->die_offset);
 		  return 1;
 		}
 	      if (unlikely (op_multifile) && ref->die_collapsed_child)
@@ -3635,8 +3642,10 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die)
 		= off_htab_lookup (cu, cu->cu_offset + value);
 	      if (ref == NULL)
 		{
-		  error (0, 0, "%s: Couldn't find DIE referenced by %s",
-			 dso->filename, get_DW_AT_str (t->attr[i].attr));
+		  error (0, 0, "%s: Couldn't find DIE at [%" PRIx64 "] "
+			 "referenced by %s from DIE at [%x]",
+			 dso->filename, cu->cu_offset + value,
+			 get_DW_AT_str (t->attr[i].attr), die->die_offset);
 		  return 1;
 		}
 	      if (die->die_ck_state != CK_BAD)
@@ -7146,8 +7155,10 @@ read_debug_info (DSO *dso, int kind, unsigned int *die_count)
 	  dw_die_ref ref = off_htab_lookup (cu, cu->cu_offset + type_offset);
 	  if (ref == NULL)
 	    {
-	      error (0, 0, "%s: Couldn't find DIE referenced by type_offset",
-		     dso->filename);
+	      error (0, 0, "%s: Couldn't find DIE at [%x] "
+		     "referenced by type_offset from cu DIE at [%x]",
+		     dso->filename, cu->cu_offset + type_offset,
+		     cu->cu_die->die_offset);
 	      goto fail;
 	    }
 	  if (unlikely (low_mem))
-- 
2.18.4


             reply	other threads:[~2021-01-26 20:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26 20:45 Mark Wielaard [this message]
2021-01-26 20:49 ` Jakub Jelinek

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=20210126204509.24710-1-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=dwz@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).