public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add --devel-dump-checksum
@ 2021-02-15 21:01 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2021-02-15 21:01 UTC (permalink / raw)
  To: dwz, jakub, mark

Hi,

Add an option --devel-dump-checksum that dumps how the checksum is
calculated in checksum_die.

F.i., for these DIEs:
...
<1><2e5>: Abbrev Number: 8 (DW_TAG_structure_type)
    <2e6>   DW_AT_name        : _IO_marker
    <2ea>   DW_AT_byte_size   : 24
    <2eb>   DW_AT_decl_file   : 4
    <2ec>   DW_AT_decl_line   : 156
    <2ed>   DW_AT_sibling     : <0x316>
 <2><2f1>: Abbrev Number: 9 (DW_TAG_member)
    <2f2>   DW_AT_name        : _next
    <2f6>   DW_AT_decl_file   : 4
    <2f7>   DW_AT_decl_line   : 157
    <2f8>   DW_AT_type        : <0x316>
    <2fc>   DW_AT_data_member_location: 0
 <2><2fd>: Abbrev Number: 9 (DW_TAG_member)
    <2fe>   DW_AT_name        : _sbuf
    <302>   DW_AT_decl_file   : 4
    <303>   DW_AT_decl_line   : 158
    <304>   DW_AT_type        : <0x31c>
    <308>   DW_AT_data_member_location: 8
 <2><309>: Abbrev Number: 9 (DW_TAG_member)
    <30a>   DW_AT_name        : _pos
    <30e>   DW_AT_decl_file   : 4
    <30f>   DW_AT_decl_line   : 162
    <310>   DW_AT_type        : <0x129>
    <314>   DW_AT_data_member_location: 16
 <2><315>: Abbrev Number: 0
...
we get:
...
$ dwz --devel-dump-checksum hello
  ...
DIE 2e5, hash: 6a638d48, tag
DIE 2e5, hash: f9c5744d, attr (0)
DIE 2e5, hash: e83375f6, attr (1)
DIE 2e5, hash: f6c73f89, attr (2)
DIE 2e5, hash: 1cd5a043, attr (3)
DIE 2e5, hash: 1cd5a043, attr (4)
DIE 2f1, hash: 3a09c42b, tag
DIE 2f1, hash: 815dd613, attr (0)
DIE 2f1, hash: 7b47bca, attr (1)
DIE 2f1, hash: 5a509026, attr (2)
DIE 2f1, hash: be759bbc, attr (3)
DIE 2f1, hash: 1684f315, attr (4)
DIE 2f1, hash: 1684f315, final
DIE 2e5, hash: 9178023b, child (0)
DIE 2fd, hash: 3a09c42b, tag
DIE 2fd, hash: 9a2aa48d, attr (0)
DIE 2fd, hash: fc2833ec, attr (1)
DIE 2fd, hash: 41974b9c, attr (2)
DIE 2fd, hash: 36e76cd8, attr (3)
DIE 2fd, hash: ac3098c6, attr (4)
DIE 2fd, hash: ac3098c6, final
DIE 2e5, hash: c4a190a3, child (1)
DIE 309, hash: 3a09c42b, tag
DIE 309, hash: 5ea756dc, attr (0)
DIE 309, hash: 6486eafd, attr (1)
DIE 309, hash: bdc3b14f, attr (2)
DIE 309, hash: 5da7f906, attr (3)
DIE 309, hash: a9c74436, attr (4)
DIE 309, hash: a9c74436, final
DIE 2e5, hash: 40b05772, child (2)
DIE 2e5, hash: 40b05772, final
...

Any comments?

Thanks,
- Tom

Add --devel-dump-checksum

2021-02-15  Tom de Vries  <tdevries@suse.de>

	* dwz.c (dump_checksum_p): New var.
	(checksum_die): Print progression of checksum calculation if
	dump_checksum_p.
	(dwz_options, usage): Add --devel-dump-checksump entries.

---
 dwz.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/dwz.c b/dwz.c
index 80bc1e7..d037e1e 100644
--- a/dwz.c
+++ b/dwz.c
@@ -188,6 +188,7 @@ static struct obstack alt_ob, alt_ob2;
 static int tracing;
 static int ignore_size;
 static int ignore_locus;
+static int dump_checksum_p;
 static int dump_dies_p;
 static int dump_dups_p;
 static int dump_pus_p;
@@ -198,6 +199,7 @@ static int stats_p;
 #define tracing 0
 #define ignore_size 0
 #define ignore_locus 0
+#define dump_checksum_p 0
 #define dump_dies_p 0
 #define dump_dups_p 0
 #define dump_pus_p 0
@@ -3360,8 +3362,17 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die)
   skip_leb128 (ptr);
   s = die->die_tag;
   die->u.p1.die_hash = iterative_hash_object (s, die->u.p1.die_hash);
+  if (dump_checksum_p)
+    fprintf (stderr, "DIE %x, hash: %x, tag\n", die->die_offset,
+	     die->u.p1.die_hash);
   if (uni_lang_p && die == top_die)
-    die->u.p1.die_hash = iterative_hash_object (cu->lang, die->u.p1.die_hash);
+    {
+      die->u.p1.die_hash
+	= iterative_hash_object (cu->lang, die->u.p1.die_hash);
+      if (dump_checksum_p)
+	fprintf (stderr, "DIE %x, hash: %x, lang\n", die->die_offset,
+		 die->u.p1.die_hash);
+    }
   only_hash_name_p = odr && die_odr_state (die_cu (die), die) != ODR_NONE;
   die_hash2 = 0;
   if (only_hash_name_p)
@@ -3836,9 +3847,13 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die)
 	  die->u.p1.die_hash
 	    = iterative_hash (old_ptr, ptr - old_ptr, die->u.p1.die_hash);
 	}
+
+      if (dump_checksum_p)
+	fprintf (stderr, "DIE %x, hash: %x, attr (%d)\n", die->die_offset,
+		 die->u.p1.die_hash, i);
     }
 
-  for (child = die->die_child; child; child = child->die_sib)
+  for (child = die->die_child, i = 0; child; child = child->die_sib, ++i)
     if (checksum_die (dso, cu,
 		      top_die ? top_die
 			      : child->die_named_namespace
@@ -3851,6 +3866,9 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die)
 	    die->u.p1.die_hash
 	      = iterative_hash_object (child->u.p1.die_hash,
 				       die->u.p1.die_hash);
+	    if (dump_checksum_p)
+	      fprintf (stderr, "DIE %x, hash: %x, child (%i)\n",
+		       die->die_offset, die->u.p1.die_hash, i);
 	    die->die_no_multifile
 	      |= child->die_no_multifile;
 	  }
@@ -3860,6 +3878,10 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die)
   if (die->die_ck_state == CK_BEING_COMPUTED)
     die->die_ck_state = CK_KNOWN;
 
+  if (dump_checksum_p)
+    fprintf (stderr, "DIE %x, hash: %x, final\n", die->die_offset,
+	     die->u.p1.die_hash);
+
   if (only_hash_name_p)
     {
       unsigned int tmp = die->u.p1.die_hash;
@@ -15986,6 +16008,8 @@ static struct option dwz_options[] =
   { "devel-ignore-locus",no_argument,	    &ignore_locus, 1 },
   { "devel-force",	 no_argument,	    &force_p, 1 },
   { "devel-save-temps",  no_argument,	    &save_temps, 1 },
+  { "devel-dump-checksum",
+			 no_argument,	    &dump_checksum_p, 1 },
   { "devel-dump-dies",  no_argument,	    &dump_dies_p, 1 },
   { "devel-dump-dups",  no_argument,	    &dump_dups_p, 1 },
   { "devel-dump-pus",  no_argument,	    &dump_pus_p, 1 },
@@ -16249,6 +16273,7 @@ usage (void)
        "  --devel-ignore-locus\n"
        "  --devel-force\n"
        "  --devel-save-temps\n"
+       "  --devel-dump-checksum\n"
        "  --devel-dump-dies\n"
        "  --devel-dump-dups\n"
        "  --devel-dump-pus\n"

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-15 21:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15 21:01 [PATCH] Add --devel-dump-checksum Tom de Vries

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