public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com
Subject: [committed] Use off_hash (die) instead of die->die_offset
Date: Tue, 01 Jan 2019 00:00:00 -0000	[thread overview]
Message-ID: <20191120064351.GA19811@delia> (raw)

Hi,

When using htab_find_slot_with_hash for off_htab (or any other htab using
off_hash), a manually inlined version of off_htab is used:
...
  slot = htab_find_slot_with_hash (off_htab, die, die->die_offset, INSERT);
...

Instead, make all occurrences use off_hash:
...
  slot = htab_find_slot_with_hash (off_htab, die, off_hash (die), INSERT);
...
allowing modification of the implementation of off_hash in a single location.

Committed to trunk.

Thanks,
- Tom

Use off_hash (die) instead of die->die_offset

2019-11-19  Tom de Vries  <tdevries@suse.de>

	* dwz.c (off_htab_add_die, off_htab_lookup, add_dummy_die)
	(expand_child, remove_dies, collapse_child, read_debug_info): Use
	off_hash.

---
 dwz.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/dwz.c b/dwz.c
index 500ac1a..44e745a 100644
--- a/dwz.c
+++ b/dwz.c
@@ -1244,7 +1244,7 @@ off_htab_add_die (dw_cu_ref cu, dw_die_ref die)
 	alt_off_htab = off_htab;
     }
 
-  slot = htab_find_slot_with_hash (off_htab, die, die->die_offset, INSERT);
+  slot = htab_find_slot_with_hash (off_htab, die, off_hash (die), INSERT);
   if (slot == NULL)
     dwz_oom ();
   assert (*slot == NULL);
@@ -1260,12 +1260,14 @@ off_htab_lookup (dw_cu_ref cu, unsigned int die_offset)
   struct dw_die die;
   die.die_offset = die_offset;
   if (cu == NULL)
-    return (dw_die_ref) htab_find_with_hash (off_htab, &die, die_offset);
+    return (dw_die_ref) htab_find_with_hash (off_htab, &die, off_hash (&die));
   if (unlikely (cu->cu_kind == CU_ALT))
-    return (dw_die_ref) htab_find_with_hash (alt_off_htab, &die, die_offset);
+    return (dw_die_ref) htab_find_with_hash (alt_off_htab, &die,
+					     off_hash (&die));
   if (unlikely (cu->cu_kind == CU_TYPES))
-    return (dw_die_ref) htab_find_with_hash (types_off_htab, &die, die_offset);
-  return (dw_die_ref) htab_find_with_hash (off_htab, &die, die_offset);
+    return (dw_die_ref) htab_find_with_hash (types_off_htab, &die,
+					     off_hash (&die));
+  return (dw_die_ref) htab_find_with_hash (off_htab, &die, off_hash (&die));
 }
 
 /* For a die attribute with form FORM starting at PTR, with the die in CU,
@@ -1733,7 +1735,8 @@ add_dummy_die (dw_cu_ref cu, unsigned int offset)
     }
 
   slot
-    = htab_find_slot_with_hash (off_htab, &ref_buf, ref_buf.die_offset, INSERT);
+    = htab_find_slot_with_hash (off_htab, &ref_buf, off_hash (&ref_buf),
+				INSERT);
   if (slot == NULL)
     dwz_oom ();
   if (*slot != NULL)
@@ -3176,7 +3179,7 @@ expand_child (dw_die_ref top_die, bool checksum)
       diebuf.die_offset = die_offset;
       slot = htab_find_slot_with_hash (cu->cu_kind == CU_TYPES
 				       ? types_off_htab : off_htab,
-				       &diebuf, die_offset, NO_INSERT);
+				       &diebuf, off_hash (&diebuf), NO_INSERT);
       if (slot == NULL)
 	die = NULL;
       else
@@ -4633,7 +4636,7 @@ remove_dies (dw_cu_ref cu, dw_die_ref die, bool remove)
   if (die->die_referenced == 0)
     {
       htab_t h = cu->cu_kind == CU_TYPES ? types_off_htab : off_htab;
-      void **slot = htab_find_slot_with_hash (h, die, die->die_offset,
+      void **slot = htab_find_slot_with_hash (h, die, off_hash (die),
 					      NO_INSERT);
       if (slot != NULL)
 	htab_clear_slot (h, slot);
@@ -4769,7 +4772,7 @@ collapse_child (dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die,
 	  ref->die_tag = tick_diff;
 	  slot = htab_find_slot_with_hash (cu->cu_kind == CU_TYPES
 					   ? types_off_htab : off_htab,
-					   ref, ref->die_offset, NO_INSERT);
+					   ref, off_hash (ref), NO_INSERT);
 	  assert (slot != NULL);
 	  *slot = (void *) ref;
 	  memset (die, '\0', offsetof (struct dw_die, die_dup));
@@ -5292,7 +5295,7 @@ read_debug_info (DSO *dso, int kind)
 	      if (off_htab != NULL && kind == DEBUG_INFO)
 		{
 		  void **slot
-		    = htab_find_slot_with_hash (off_htab, die, die->die_offset,
+		    = htab_find_slot_with_hash (off_htab, die, off_hash (die),
 						INSERT);
 		  if (slot == NULL)
 		    dwz_oom ();

                 reply	other threads:[~2019-11-20  6:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20191120064351.GA19811@delia \
    --to=tdevries@suse.de \
    --cc=dwz@sourceware.org \
    --cc=jakub@redhat.com \
    /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).