From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KSabL3fJlGkNOj8AWB0awg (envelope-from ) for ; Tue, 17 Feb 2026 15:03:03 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=JgqCSyHj; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B9B301E0BA; Tue, 17 Feb 2026 15:03:03 -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 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 748B31E08D for ; Tue, 17 Feb 2026 15:03:02 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 2AF344BA23F5 for ; Tue, 17 Feb 2026 20:03:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2AF344BA23F5 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=JgqCSyHj Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 67C684BA23CC for ; Tue, 17 Feb 2026 20:02:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 67C684BA23CC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 67C684BA23CC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771358526; cv=none; b=th3hPpK8jTXhi39PMHQwS2Q1Qo+bVOAA9xZVS5FfN5jsebkY+Qh7HLk03hbkrs9VyUNqFD21zcndkY3WNNi2hGbbdsyzwz7m8EklLPNNRqNUl0Y2yVFwYtLJHuy6etoDGsgK9jz45xgSJ/ayLsD7CHFkgIF+e4WTWx126/86hns= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771358526; c=relaxed/simple; bh=+29IEvNckt/NvoND/SKWVkq0fAxrnIHmRKlFm+YIlM8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=vpo8EGlWjCnDUEMAne/0JqQkqJcxUp0gdRQkmkkvLCdMG0ybNT6GeXWUpp0h0jcgUB3yOKLifQ68q5XJ3wOhf1q7kfxc7XaT1zokonoAyvnfdbx+WWXsU955/BAk6eNs+1wV9iD5ikJGntX8WbAqkVGdzNQhv6JQpRvK7DTseIQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 67C684BA23CC 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 61HK20Tm176103 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Feb 2026 15:02:05 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 61HK20Tm176103 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1771358525; bh=An/wwydI63NDgcMYfucdxm02/dYzsB5VXsY5impdYhA=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=JgqCSyHjbW6fh4bXEKpOOR1vAhuc5M8AifIACOx0Bm/GmKcTG1EP4dv3DrWP6yYhX KlzT382t1SNu3wFBkErv/GcuWrAJF/eY5rooJJMZvF3Pogwjn0bBhXk94KgAdh7/VG I1MNdpImuC2BOq5r5GRfI1wPpuoMkkAgXax6eMbCqoHsZIf5yMxWIi1o0t1r77cJpF 36hAJk+IIjS7+RSI5/twdI+c2pBOQ5mhySfkrYJSbWaE44c5XpFIXIbS2998OTiaBB cV7+KinOaKMdzo0PgCmzj5VDgTZYovDw9rt5h8yAfHLTKFme9c9HcRR5Q/yR43ykej 62/mTd+9xJglg== Received: by simark.ca (Postfix) id A3EFB1E0F4; Tue, 17 Feb 2026 14:53:33 -0500 (EST) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 7/9] gdb: make expanded_symbols_functions hold compunit symtabs Date: Tue, 17 Feb 2026 14:50:56 -0500 Message-ID: <20260217195329.3833518-8-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260217195329.3833518-1-simon.marchi@polymtl.ca> References: <20260203065435.3092465-1-simon.marchi@polymtl.ca> <20260217195329.3833518-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 17 Feb 2026 20:02:00 +0000 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 From: Simon Marchi Change the expanded_symbols_functions quick functions type to hold and use a list of compunit symtab to search. Currently, an expanded_symbols_functions instance will search all the compunits in the objfile. This is not efficient if an expanded_symbols_functions instance exists alongside another quick functions object in an objfile, as the compunits belonging to that other object will be unnecessarily searched. And at worst, I think it could be a source of subtle bugs. For instance, if the order of quick functions determine the order in which we want the search to happen (the comment in elf_symfile_read suggests this is the case), then having expanded_symbols_functions search the compunits from other quick functions objects would not respect that ordering. Update the expanded_symbols_functions constructor to accept a vector of compunits and store this vector in a field. Update expanded_symbols_functions methods to use that vector instead of the objfile's compunits. Right now the sole user of expanded_symbols_functions is JIT. Update it to keep a vector of compunits as they are finalized, and pass this vector to the expanded_symbols_functions object. Change-Id: Idf8de18b25fd3f71766166d6f420184af3c26b7e --- gdb/expanded-symbol.c | 16 ++++++++-------- gdb/expanded-symbol.h | 8 ++++++++ gdb/jit.c | 16 ++++++++++++---- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/gdb/expanded-symbol.c b/gdb/expanded-symbol.c index 050608795f93..d885fe33fa84 100644 --- a/gdb/expanded-symbol.c +++ b/gdb/expanded-symbol.c @@ -28,10 +28,10 @@ symtab * expanded_symbols_functions::find_last_source_symtab (objfile *objfile) { - if (objfile->compunit_symtabs.empty ()) + if (m_compunit_symtabs.empty ()) return nullptr; else - return objfile->compunit_symtabs.back ().primary_filetab (); + return m_compunit_symtabs.back ()->primary_filetab (); } /* See expanded-symbol.h. */ @@ -61,15 +61,15 @@ expanded_symbols_functions::search /* This invariant is documented in quick-functions.h. */ gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr); - for (compunit_symtab &cu : objfile->compunits ()) + for (compunit_symtab *cu : m_compunit_symtabs) { - if (lang_matcher != nullptr && !lang_matcher (cu.language ())) + if (lang_matcher != nullptr && !lang_matcher (cu->language ())) continue; if (file_matcher != nullptr) { bool matched = false; - for (auto st : cu.filetabs ()) + for (auto st : cu->filetabs ()) { if (file_matcher (st->filename (), false)) { @@ -92,7 +92,7 @@ expanded_symbols_functions::search consult lookup_name and symbol_matcher (if any). This should be okay since i) all symtabs are already expanded and ii) listeners iterate over matching symbols themselves. */ - if (listener != nullptr && !listener (&cu)) + if (listener != nullptr && !listener (cu)) return false; } return true; @@ -104,9 +104,9 @@ symbol * expanded_symbols_functions::find_symbol_by_address (objfile *objfile, CORE_ADDR address) { - for (compunit_symtab &symtab : objfile->compunits ()) + for (compunit_symtab *symtab : m_compunit_symtabs) { - symbol *sym = symtab.symbol_at_address (address); + symbol *sym = symtab->symbol_at_address (address); if (sym != nullptr) return sym; } diff --git a/gdb/expanded-symbol.h b/gdb/expanded-symbol.h index c088d74f7e59..885390ccb124 100644 --- a/gdb/expanded-symbol.h +++ b/gdb/expanded-symbol.h @@ -29,6 +29,11 @@ struct expanded_symbols_functions : public quick_symbol_functions { + explicit expanded_symbols_functions + (std::vector compunit_symtabs) + : m_compunit_symtabs (std::move (compunit_symtabs)) + {} + bool has_symbols (objfile *objfile) override { return true; @@ -86,6 +91,9 @@ struct expanded_symbols_functions : public quick_symbol_functions bool need_fullname) override { } + +private: + std::vector m_compunit_symtabs; }; diff --git a/gdb/jit.c b/gdb/jit.c index 21e8667a7af6..5fa3869316c3 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -513,9 +513,11 @@ jit_symtab_close_impl (struct gdb_symbol_callbacks *cb, ABI). */ } -/* Transform STAB to a proper symtab, and add it it OBJFILE. */ +/* Transform STAB to a proper symtab, and add it it OBJFILE. -static void + Return the created symtab. */ + +static compunit_symtab * finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) { CORE_ADDR begin, end; @@ -653,6 +655,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) /* Move just built blockvector over to CUST. */ cust->set_blockvector (std::move (bv)); + + return cust; } /* Called when closing a gdb_objfile. Converts OBJ to a proper @@ -673,10 +677,14 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb, objfile->section_offsets.push_back (0); objfile->sect_index_text = 0; objfile->per_bfd->gdbarch = priv_data->gdbarch; - objfile->qf.emplace_front (new expanded_symbols_functions); + + std::vector compunit_symtabs; for (gdb_symtab &symtab : obj->symtabs) - finalize_symtab (&symtab, objfile); + compunit_symtabs.emplace_back (finalize_symtab (&symtab, objfile)); + + objfile->qf.emplace_front (std::make_unique + (std::move (compunit_symtabs))); add_objfile_entry (objfile, priv_data->entry_addr, priv_data->entry.symfile_addr, -- 2.53.0