From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id rdNdJ/QUvGqgkRkAWB0awg (envelope-from ) for ; Tue, 29 Sep 2026 15:43:48 -0400 Received: by simark.ca (Postfix, from userid 112) id 7DB641E090; Tue, 29 Sep 2026 15:43:48 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, 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 421E71E04E for ; Tue, 29 Sep 2026 15:43:47 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D7D4B4BA9025 for ; Tue, 29 Sep 2026 19:43:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7D4B4BA9025 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id C92714BA2E2B for ; Tue, 29 Sep 2026 19:43:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C92714BA2E2B Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C92714BA2E2B Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790711004; cv=none; b=T+ijxmGMY30uKieKYbGX1+9O1tL8JEthgBfP6Yzg2MRWai0/CCT9PFdWalOG7SJ69dDUTfetuNQk7wfPTGoeWcIFglowRlJvWVWcDs2GrjDVLMat6HB7kQZVMTp6GoOjyr5jnhx+kg6bGz4uumEBW8FbjtIYk6JvqAYbl2RlF0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790711004; c=relaxed/simple; bh=54SDyiTdQdbuqgQJVEHLHv2J4IHJDaz69wolg8A+kWQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=QzKgtDtEsHZ+9OqfcumAxi9IOQ/CCCawuCiDUpu0jqgJVWO3S/gpfCOjuL4nLORPa7MqrtUeADmzOlRzi/coPK+HkrTjrNAgNAEVcqdpM6j0h/1SottDIpubsIGUncrp6TFz9efKT1RGWQfysWGJqGF654vD6hkqskZeOlP3oS4= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C92714BA2E2B Received: by simark.ca (Postfix) id 315791E01F; Tue, 29 Sep 2026 15:43:24 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 8/9] gdb: pass result containers by reference in global_symbol_searcher Date: Tue, 29 Sep 2026 15:39:29 -0400 Message-ID: <20260929194119.155169-9-simon.marchi@efficios.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260929194119.155169-1-simon.marchi@efficios.com> References: <20260929194119.155169-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 add_matching_symbols and add_matching_msymbols take the container to add results to as a pointer, but it can never be nullptr. Pass it by reference instead. Change-Id: I65d8e14f2f3152d83afbe3b348fc91a8817b87fa --- gdb/symtab.c | 17 ++++++++--------- gdb/symtab.h | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 79e43eafde18..10a794004d33 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4899,7 +4899,7 @@ global_symbol_searcher::add_matching_symbols (objfile *objfile, const std::optional &name_regex, const std::optional &type_regex, - std::set *result_set) const + std::set &result_set) const { /* Add matching symbols (if not already present). */ for (compunit_symtab &cust : objfile->compunits ()) @@ -4918,8 +4918,8 @@ global_symbol_searcher::add_matching_symbols continue; /* Match, insert if not already in the results. */ - if (result_set->size () < m_max_search_results) - result_set->emplace (block, sym); + if (result_set.size () < m_max_search_results) + result_set.emplace (block, sym); else return false; } @@ -4934,7 +4934,7 @@ global_symbol_searcher::add_matching_symbols bool global_symbol_searcher::add_matching_msymbols (objfile *objfile, const std::optional &name_regex, - std::vector *results) const + std::vector &results) const { for (minimal_symbol *msymbol : objfile->msymbols ()) { @@ -4955,8 +4955,8 @@ global_symbol_searcher::add_matching_msymbols continue; /* Matching msymbol, add it to the results list. */ - if (results->size () < m_max_search_results) - results->emplace_back (GLOBAL_BLOCK, msymbol, objfile); + if (results.size () < m_max_search_results) + results.emplace_back (GLOBAL_BLOCK, msymbol, objfile); else return false; } @@ -5056,8 +5056,7 @@ global_symbol_searcher::search () const RESULT_SET set. Use a set here so that we can easily detect duplicates as we go, and can therefore track how many unique matches we have found so far. */ - if (!add_matching_symbols (&objfile, name_regex, type_regex, - &result_set)) + if (!add_matching_symbols (&objfile, name_regex, type_regex, result_set)) break; } @@ -5077,7 +5076,7 @@ global_symbol_searcher::search () const gdb_assert (m_kind == symbol_search_kind::VARIABLE || m_kind == symbol_search_kind::FUNCTION); for (objfile &objfile : current_program_space->objfiles ()) - if (!add_matching_msymbols (&objfile, name_regex, &result)) + if (!add_matching_msymbols (&objfile, name_regex, result)) break; } diff --git a/gdb/symtab.h b/gdb/symtab.h index 5dd0475e4491..e382b64b427c 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2705,7 +2705,7 @@ class global_symbol_searcher bool add_matching_symbols (objfile *objfile, const std::optional &name_regex, const std::optional &type_regex, - std::set *result_set) const; + std::set &result_set) const; /* Add msymbols from OBJFILE that match NAME_REGEX and M_KIND, to the results vector RESULTS. Return false if we stop adding results early @@ -2715,7 +2715,7 @@ class global_symbol_searcher didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS. */ bool add_matching_msymbols (objfile *objfile, const std::optional &name_regex, - std::vector *results) const; + std::vector &results) const; /* Return true if MSYMBOL is of type M_KIND. */ bool is_suitable_msymbol (const minimal_symbol *msymbol) const; -- 2.55.0