From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id bjULFskIV2GCfgAAWB0awg (envelope-from ) for ; Fri, 01 Oct 2021 09:10:33 -0400 Received: by simark.ca (Postfix, from userid 112) id 458D71EDF0; Fri, 1 Oct 2021 09:10:33 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 79F181E79C for ; Fri, 1 Oct 2021 09:10:32 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E2F533858034 for ; Fri, 1 Oct 2021 13:10:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2F533858034 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1633093831; bh=IaLLY1z6lWPewIrbEq4jwpGEywPnbRtxocBsAbj6tjw=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vNqKztwphx43i+YDzM5sBhsIvX9KVD+BFVg7OFMgrHWTmhmQ1onwhjOHZkmSMykIw W6uRIb+epZ87Zu1OYQ9huZjqWcoc5SzmGSqlWArXoCCmjXPuaSbJ+bhIn/2tPJC4ey lst+ZbzBnHNL1sRXkRUO+HzmY88uDn4YFbNjIIIw= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 3E26F3858422 for ; Fri, 1 Oct 2021 13:10:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3E26F3858422 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 191D9xon009539 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 1 Oct 2021 09:10:04 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 191D9xon009539 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 645F81E79C; Fri, 1 Oct 2021 09:09:59 -0400 (EDT) Message-ID: <113a7cab-f06b-32ad-caa1-b0c87e67335b@polymtl.ca> Date: Fri, 1 Oct 2021 09:09:59 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 Subject: Re: [PATCH 1/4] [gdb/symtab] Fix htab_find_slot call in read_call_site_scope Content-Language: en-US To: Tom de Vries , gdb-patches@sourceware.org References: <20211001123328.22314-1-tdevries@suse.de> In-Reply-To: <20211001123328.22314-1-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 1 Oct 2021 13:09:59 +0000 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2021-10-01 08:33, Tom de Vries via Gdb-patches wrote: > 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. */ Ah, I had not seen this comment. So it was on purpose. Still, I think that it makes it more confusing than anything. The patch LGTM. Simon