From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 559293857C7B for ; Mon, 15 Feb 2021 21:02:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 559293857C7B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 71708AD29; Mon, 15 Feb 2021 21:02:00 +0000 (UTC) Date: Mon, 15 Feb 2021 22:01:58 +0100 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org Subject: [PATCH] Add --devel-dump-checksum Message-ID: <20210215210157.GA5772@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Feb 2021 21:02:03 -0000 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 * 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"