From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 5neiOav+VWF1YAAAWB0awg (envelope-from ) for ; Thu, 30 Sep 2021 14:15:07 -0400 Received: by simark.ca (Postfix, from userid 112) id DA8141EE28; Thu, 30 Sep 2021 14:15:07 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.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 E661A1EE1F for ; Thu, 30 Sep 2021 14:15:06 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E2E8385842D for ; Thu, 30 Sep 2021 18:15:06 +0000 (GMT) Received: from gateway24.websitewelcome.com (gateway24.websitewelcome.com [192.185.50.45]) by sourceware.org (Postfix) with ESMTPS id D0EDA3858C2C for ; Thu, 30 Sep 2021 18:14:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D0EDA3858C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tromey.com Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 3F4AA98CC for ; Thu, 30 Sep 2021 13:14:54 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id W0a6m7dDTOnCIW0a6mhZ0c; Thu, 30 Sep 2021 13:14:54 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=7n1JEQNDCmtSudkKKjXmSU4fF5mmGUHRP3VWIhcXqJE=; b=Wh6Q6WSEyJcKEqBM5UsF9NOMkp WbMmaGTxcWYoK9BMjAWkApvbK+iHFyac7N90L85ZBcujA9bUz6iRVnVi+8XTD9hUGWo70vc2CbIgp xluZYLg/w6EsjdTJa6t5RWCyK; Received: from 174-16-0-219.hlrn.qwest.net ([174.16.0.219]:53940 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mW0a5-001Gqh-U3; Thu, 30 Sep 2021 12:14:53 -0600 From: Tom Tromey To: Simon Marchi Subject: Re: [PATCH][gdb/symtab] Relocate call_site_htab References: <20210930095608.GA11467@delia> <5940137d-6a6f-2309-673f-d9491ed654b5@polymtl.ca> X-Attribution: Tom Date: Thu, 30 Sep 2021 12:14:53 -0600 In-Reply-To: <5940137d-6a6f-2309-673f-d9491ed654b5@polymtl.ca> (Simon Marchi's message of "Thu, 30 Sep 2021 10:26:58 -0400") Message-ID: <874ka20w2q.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.16.0.219 X-Source-L: No X-Exim-ID: 1mW0a5-001Gqh-U3 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-0-219.hlrn.qwest.net (murgatroyd) [174.16.0.219]:53940 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: , Cc: Tom Tromey , gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" >> I've submitted an attempt at fixing this before, trying to handle this at all >> points where the information is used ( >> https://sourceware.org/pipermail/gdb-patches/2019-August/159631.html ). Simon> Instead of relocating the data structure, isn't the tendency now (to Simon> make sharing between objfiles easier) to keep the data structure Simon> unrelocated, and relocate things when looking things up? Yeah. That's what the earlier patch did but I guess I never re-reviewed it. Here's the final one https://sourceware.org/pipermail/gdb-patches/2019-August/159822.html That patch looks pretty reasonable to me. - { - lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr); - SET_FIELD_PHYSADDR (call_site->target, lowpc); - } + SET_FIELD_PHYSADDR (call_site->target, lowpc); Normally I think the DWARF reader applies the offset, calls the gdbarch method, then subtracts the offset. It's unclear to me if this is truly needed, it's maybe done just so I didn't need to audit all the gdbarch implementations for some earlier patch. Simon> I could imagine a compunit_symtab method called "find_call_site", Simon> where you pass a relocated PC. The method internally unrelocates the PC Simon> to do the lookup in the htab. call_site would store an unrelocated pc, Simon> and a call_site::pc method would return the (computed) relocated pc. Simon> Simiarly, the call_site's target would keep holding an unrelocated pc, Simon> and it would be computed on the fly. Simon> See crude patch implementing this at the bottom of this message. This seemed pretty reasonable to me as well. Simon> - In call_site_to_target_addr, when the target is defined using a DWARF Simon> expression (FIELD_LOC_KIND_DWARF_BLOCK), is the result of computing Simon> that expression relocated or not? I would presume that it's not Simon> relocated. Do we need to relocate it at that point? That looks like Simon> a bug to me, it would probably be caught by an appropriate test. I don't know the answer here. Simon> - In read_call_site_scope, we do an htab lookup to look for Simon> duplicates. We do: Simon> slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT); Simon> where call_site_local is a call_site object. However, the htab works Simon> using the address as index, it passes core_addr_hash and core_addr_eq Simon> as hash/eq functions. And in call_site_for_pc, the lookup is done Simon> by passing a pointer to a CORE_ADDR. Therefore, the lookup in Simon> read_call_site_scope looks wrong to me. It just works because Simon> call_site::pc happens to be the first field of call_site. IIUC, this is valid in C at least -- you can cast pointer-to-struct to pointer-to-first-element. However, it seems better for the code to be less tricky. Tom