From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 957A53858C2C for ; Fri, 1 Oct 2021 12:33:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 957A53858C2C Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A28852267B for ; Fri, 1 Oct 2021 12:33:28 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8F4C913C59 for ; Fri, 1 Oct 2021 12:33:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 5H33IRgAV2ENXwAAMHmgww (envelope-from ) for ; Fri, 01 Oct 2021 12:33:28 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 1/4] [gdb/symtab] Fix htab_find_slot call in read_call_site_scope Date: Fri, 1 Oct 2021 14:33:25 +0200 Message-Id: <20211001123328.22314-1-tdevries@suse.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Oct 2021 12:33:31 -0000 From: Simon Marchi In read_call_site_scope we have: ... call_site_local.pc = pc; slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT); ... The call passes a call_site pointer as element. OTOH, the hashtab is created using hash_f == core_addr_hash and eq_f == core_addr_eq, so the element will be accessed through a CORE_ADDR pointer. This is not wrong (at least in C), given that pc is the first field in call_site. Nevertheless, as in call_site_for_pc, make the htab_find_slot call match the used hash_f and eq_f by using &pc instead: ... slot = htab_find_slot (cu->call_site_htab, &pc, INSERT); ... Tested on x86_64-linux. Co-Authored-By: Tom de Vries --- gdb/dwarf2/read.c | 5 ++--- gdb/gdbtypes.h | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 00aa64dd0ab..23870c04e74 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13341,7 +13341,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) struct gdbarch *gdbarch = objfile->arch (); CORE_ADDR pc, baseaddr; struct attribute *attr; - struct call_site *call_site, call_site_local; + struct call_site *call_site; void **slot; int nparams; struct die_info *child_die; @@ -13369,8 +13369,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) cu->call_site_htab = htab_create_alloc_ex (16, core_addr_hash, core_addr_eq, NULL, &objfile->objfile_obstack, hashtab_obstack_allocate, NULL); - call_site_local.pc = pc; - slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT); + slot = htab_find_slot (cu->call_site_htab, &pc, INSERT); if (*slot != NULL) { complaint (_("Duplicate PC %s for DW_TAG_call_site " diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 2a641122aec..84b751e82e3 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1783,9 +1783,7 @@ struct call_site_parameter struct call_site { - /* * Address of the first instruction after this call. It must be - the first field as we overload core_addr_hash and core_addr_eq - for it. */ + /* Address of the first instruction after this call. */ CORE_ADDR pc; base-commit: e4860c08f990675c9b3535ab18cc7ff21e2a5639 -- 2.26.2