From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SeUmLpfBvWryTCEAWB0awg (envelope-from ) for ; Wed, 30 Sep 2026 22:12:39 -0400 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=sr85IkjX; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B8D951E033; Wed, 30 Sep 2026 22:12:39 -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.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 ED95B1E033 for ; Wed, 30 Sep 2026 22:12:38 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AE03D4BB1C24 for ; Thu, 1 Oct 2026 02:12:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE03D4BB1C24 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=sr85IkjX Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id D04214BB58B6 for ; Thu, 1 Oct 2026 02:12:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D04214BB58B6 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 D04214BB58B6 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790820725; cv=none; b=q7+fneap5nWPFKDKqkdzW5r+Uo9EXlEoekSR8JAEXTwrfhuYj9HmHyuQxnHKkziPPpQxJZICT83tDVr7sL8OXzpPAKGfe3aX3pG5qxwzROwExUCa0iIRtFcHuzOruTJrdqVh8SkDbtID9Kwzzy7tw5CkkwWDR3UExh4FbXaocY0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790820725; c=relaxed/simple; bh=YMPe3eOGJp5O6SAUdwJ//5vcsGvOVR2F75UnVdnZKv8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=nKYxLQyPTO3tUDqJZLZiSrmg8HcswyK4lDwU+DtIc7Gsm9QfC+DPrK5xi42EJWtsTuuj6LJWPMDwen+SGM53E0BHDkXt+5BJ61FbCTlcnYyhKM9sUFSPMK9AtHqSZQ4qK7KGEz/EWdSVHQF+MMD7fdDPfzdNItqtle/gnzhbMc4= ARC-Authentication-Results: i=1; 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=sr85IkjX DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D04214BB58B6 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 6912Bwn4168309 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Sep 2026 22:12:03 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 6912Bwn4168309 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1790820723; bh=d77wAGPuRHt3v+RA1sqC7CntVWpKlllU5jSL2vzeZI0=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=sr85IkjXbHOI0diCPjXdiY6P19LwxI3Ql0STBWm22WRQPZYLbEL79bErK2LmBUVDK rAVEJ6iPBpIJrso5RFk9pCJDyJmPMvr4t5D2tqfKxIYiK2LMD3TCmroIdoLh6oU5MX b2FvGirqgXTsBIGvbEjMG/l0zcUAyc+U9iyJ7pZSigj6EkSdzC7LJrDcdEhn2hNGMV lr4RN/2MZ4amk3PVOlIzKcHuwCJchDISUd+dIrcHY6AInT1WT693MjamSKJTwU057n ps/6hWEO0FXSVJMKBDnCjEqouAA4GpL77XlqbQMCHnlxNEnYSdhVby0HHaU76+Jm0B /QLvjk7+qIqpA== Received: by simark.ca (Postfix) id E061B1E051; Wed, 30 Sep 2026 22:11:57 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 10/11] gdb: change some pointers to references in global_symbol_searcher Date: Wed, 30 Sep 2026 22:09:27 -0400 Message-ID: <20261001020952.698419-11-simon.marchi@polymtl.ca> 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-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 1 Oct 2026 02:11:58 +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 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. The objfiles are also passed by pointer to the various helper methods, switch that to references. Change-Id: I65d8e14f2f3152d83afbe3b348fc91a8817b87fa --- gdb/symtab.c | 39 +++++++++++++++++++-------------------- gdb/symtab.h | 10 +++++----- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index ef21f285abcd..af748190ddd5 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4830,7 +4830,7 @@ global_symbol_searcher::msymbol_matches bool global_symbol_searcher::expand_symtabs - (objfile *objfile, + (objfile &objfile, const std::optional &name_regex) const { bool found_func_msymbol_without_debug_info = false; @@ -4843,7 +4843,7 @@ global_symbol_searcher::expand_symtabs if (!m_filenames.empty ()) file_matcher = do_file_match; - objfile->search + objfile.search (file_matcher, &lookup_name_info::match_any (), [&] (const char *symname) @@ -4870,7 +4870,7 @@ global_symbol_searcher::expand_symtabs if (m_filenames.empty () && m_kind == symbol_search_kind::FUNCTION) { - for (minimal_symbol *msymbol : objfile->msymbols ()) + for (minimal_symbol *msymbol : objfile.msymbols ()) { QUIT; @@ -4882,7 +4882,7 @@ global_symbol_searcher::expand_symtabs will add matching symbols or msymbols to the results list, and that requires that the symbols tables are expanded. */ if (find_compunit_symtab_for_pc - (msymbol->value_address (objfile)) == nullptr) + (msymbol->value_address (&objfile)) == nullptr) found_func_msymbol_without_debug_info = true; } } @@ -4894,13 +4894,13 @@ global_symbol_searcher::expand_symtabs bool global_symbol_searcher::add_matching_symbols - (objfile *objfile, + (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 ()) + for (compunit_symtab &cust : objfile.compunits ()) { const struct blockvector *bv = cust.blockvector (); @@ -4916,8 +4916,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; } @@ -4931,10 +4931,10 @@ global_symbol_searcher::add_matching_symbols bool global_symbol_searcher::add_matching_msymbols - (objfile *objfile, const std::optional &name_regex, - std::vector *results) const + (objfile &objfile, const std::optional &name_regex, + std::vector &results) const { - for (minimal_symbol *msymbol : objfile->msymbols ()) + for (minimal_symbol *msymbol : objfile.msymbols ()) { QUIT; @@ -4945,16 +4945,16 @@ global_symbol_searcher::add_matching_msymbols symbol might be found via find_pc_symtab. */ if (m_kind == symbol_search_kind::FUNCTION && (find_compunit_symtab_for_pc - (msymbol->value_address (objfile)) != NULL)) + (msymbol->value_address (&objfile)) != NULL)) continue; if (lookup_symbol_in_objfile_from_linkage_name - (objfile, msymbol->linkage_name (), SEARCH_VFT).symbol != NULL) + (&objfile, msymbol->linkage_name (), SEARCH_VFT).symbol != NULL) 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; } @@ -5047,14 +5047,13 @@ global_symbol_searcher::search () const /* Expand symtabs within objfile that possibly contain matching symbols. */ found_func_msymbol_without_debug_info - |= expand_symtabs (&objfile, name_regex); + |= expand_symtabs (objfile, name_regex); /* Find matching symbols within OBJFILE and add them in to the 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; } @@ -5074,7 +5073,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 cf629387a17c..117d3fb0134f 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2707,7 +2707,7 @@ class global_symbol_searcher Return true if a matching function msymbol without debug info was seen, meaning that msymbols should later be considered for the results list. */ - bool expand_symtabs (objfile *objfile, + bool expand_symtabs (objfile &objfile, const std::optional &name_regex) const; /* Add symbols from symtabs in OBJFILE that match NAME_REGEX, and @@ -2717,10 +2717,10 @@ class global_symbol_searcher otherwise return true. Returning true does not indicate that any results were added, just that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS. */ - bool add_matching_symbols (objfile *objfile, + 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 @@ -2728,9 +2728,9 @@ class global_symbol_searcher results limit M_MAX_SEARCH_RESULTS), otherwise return true. Returning true does not indicate that any results were added, just that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS. */ - bool add_matching_msymbols (objfile *objfile, + 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