public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add DIE offsets in error messages to make it easier to find what is wrong.
@ 2021-01-26 20:45 Mark Wielaard
  2021-01-26 20:49 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2021-01-26 20:45 UTC (permalink / raw)
  To: dwz; +Cc: Mark Wielaard

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Add DIE offsets in error messages to make it easier to find what is wrong.
  2021-01-26 20:45 [PATCH] Add DIE offsets in error messages to make it easier to find what is wrong Mark Wielaard
@ 2021-01-26 20:49 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2021-01-26 20:49 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: dwz

On Tue, Jan 26, 2021 at 09:45:09PM +0100, Mark Wielaard wrote:
> 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.

LGTM, thanks.

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-26 20:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26 20:45 [PATCH] Add DIE offsets in error messages to make it easier to find what is wrong Mark Wielaard
2021-01-26 20:49 ` Jakub Jelinek

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).