From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id myK9MQ1THWllAhIAWB0awg (envelope-from ) for ; Wed, 19 Nov 2025 00:18:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1763529485; bh=8tZb5/pusQfoiVoTaIpUpnHPgDxaauqxMz//Z+g6Pmk=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lPD0sIcav+lBIH2Ps5ri2gdIM+PmH5Uyfyew2JXYgkR4eOWMLOtKd4mvIoCZ3W4nS YKOhrGfTCyDS7c740O1e2Bvy5gc0kfsgyi3Sc+r08eH3icrsJ9JTbFgKV46uchoh60 lGIYd5gkLMwHdSdFl62XZP/h8uwg+8a3u0AIpaTk= Received: by simark.ca (Postfix, from userid 112) id BBEE71E0B6; Wed, 19 Nov 2025 00:18:05 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=NyXpLRYY; dkim-atps=neutral Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D5D2A1E08D for ; Wed, 19 Nov 2025 00:18:04 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6BFF5384DB7E for ; Wed, 19 Nov 2025 05:18:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BFF5384DB7E Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=NyXpLRYY Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 94E2B384DEFC for ; Wed, 19 Nov 2025 05:17:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94E2B384DEFC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 94E2B384DEFC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763529426; cv=none; b=GyeeCkRX0L/qK/JwNqxvYv7i24u3x99rNmoPo86fmodNPfxUDcOFMx1ZkdBVDuci1KXHs6tAr6hfw11EF0NY5sfF7Sz5fzDqdLM8dx8JqK+qqJMD5jmQ7167VBLEAxmYXEyBX4/xAXBAMt4Os4l2iRA01Nz9wc/SaYzsyG7qYVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763529426; c=relaxed/simple; bh=8tZb5/pusQfoiVoTaIpUpnHPgDxaauqxMz//Z+g6Pmk=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=DZMNQbFITl8bu9ptupTjsemJr0QzJp0CnO0/fY4i3+QwPpe4+BOHegiy0rJI4HTb3ennhzQm+Eh7J/fkSzzhAs66SACHN7nABLwKzR6kyGqPueaKKeeLMJMS4P2FjVAUXKbssce41DWF2UQ22qqFbYuoGRwkmqtD3E95wLQtUXA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94E2B384DEFC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1763529426; bh=8tZb5/pusQfoiVoTaIpUpnHPgDxaauqxMz//Z+g6Pmk=; h=Date:Subject:To:References:From:In-Reply-To:From; b=NyXpLRYYD8X2FdrjOxCBAStDOxz0Xhw+QpVPLqSriCQojY0uvI/05JFN3O3hxKVtc dqigow9Dj2+SbeQ4VEAdgXjOe31YCHEHy27fyjdfgqBP+X+t0vhJazvBCrMupiWvcf WYrUTlxRlVwV2n5EkQUAGipSZcd0WZ5Cd2p+hCE4= Received: by simark.ca (Postfix) id F24991E08D; Wed, 19 Nov 2025 00:17:05 -0500 (EST) Message-ID: <86f2f3e7-15a5-4752-b2d6-4dc6ff7690a0@simark.ca> Date: Wed, 19 Nov 2025 00:17:05 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Make blockvector a little more self-contained To: Tom Tromey , gdb-patches@sourceware.org References: <20251119033033.3538090-1-tom@tromey.com> Content-Language: en-US From: Simon Marchi In-Reply-To: <20251119033033.3538090-1-tom@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 2025-11-18 22:30, Tom Tromey wrote: > This patch changes blockvector to be a little more self-contained. > > The idea here is that code outside of blockvector shouldn't really > know how it operates. After this patch, this still doesn't fully > happen -- a couple spots check the result of map() and make decisions > based on that -- but this is a step toward making that happen. The > longer term idea here is that this is needed to enable lazier CU > expansion. > > Meanwhile, this patch seems like a simple cleanup. Relocation is now > handled by the blockvector itself and the non-const map() method can > be removed. Overall, LGTM. Approved-By: Simon Marchi See minor comments below. > > There wasn't a great spot to move the section_offsets typedef. I > chose defs.h. I've also updated the comment there as it has been out > of date for a long time. I've also removed an obsolete comment from > the symbol-relocation code. I honestly think that this typedef could be removed, that it would be clearer to see "std::vector" in the code. > diff --git a/gdb/block.c b/gdb/block.c > index 9fb04635975..e959adc968c 100644 > --- a/gdb/block.c > +++ b/gdb/block.c > @@ -366,6 +366,28 @@ block::static_link () const > return (struct dynamic_prop *) objfile_lookup_static_link (objfile, this); > } > > +/* See block.h. */ > + > +void > +block::relocate (struct objfile *objfile, const section_offsets &offsets) > +{ > + int block_line_section = SECT_OFF_TEXT (objfile); > + > + set_start (start () + offsets[block_line_section]); > + set_end (end () + offsets[block_line_section]); > + > + for (blockrange &r : ranges ()) > + { > + r.set_start (r.start () + offsets[block_line_section]); > + r.set_end (r.end () + offsets[block_line_section]); > + } > + > + /* We only want to iterate over the local symbols, not any > + symbols in included symtabs. */ > + for (struct symbol *sym : multidict_symbols ()) > + sym->relocate (objfile, offsets); Do you know what the comment above refers to? What are we doing special to avoid iterating on the symbols in included symtabs? > diff --git a/gdb/symtab.h b/gdb/symtab.h > index 845c49e057d..4f2b88859a5 100644 > --- a/gdb/symtab.h > +++ b/gdb/symtab.h > @@ -1458,6 +1458,11 @@ struct symbol : public general_symbol_info, public allocate_on_obstack > > void set_symtab (struct symtab *symtab); > > + /* Relocate this symbol. OBJFILE is the objfile holding this > + blockvector, and OFFSETS is the relocation offsets to use. */ > + > + void relocate (struct objfile *objfile, const section_offsets &offsets); The comment says "this blockvector", looks like a copy-pasto. Also, a struct symbol already knows its objfile (it has an objfile() method) if it is objfile-owned, which should be the case here. So it seems superfluous to pass the objfile here. Actually, the objfile parameter is not even used in symbol::relocate. Simon