From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YRZkEY5F4Wll4xwAWB0awg (envelope-from ) for ; Thu, 16 Apr 2026 16:24:46 -0400 Received: by simark.ca (Postfix, from userid 112) id 382F01E04F; Thu, 16 Apr 2026 16:24:46 -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 39A631E0CA for ; Thu, 16 Apr 2026 16:24:38 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id B939D4C9176E for ; Thu, 16 Apr 2026 20:24:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B939D4C9176E Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id C36364BAD171 for ; Thu, 16 Apr 2026 20:24:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C36364BAD171 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 C36364BAD171 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=1776371050; cv=none; b=IMC8+qwNni0jxcCkFDW14vkO76IhJgiycxCqFO1e/xIcjLpesILUb36x7oZPY3tAnav6KjCnRh5VxqrnuY/vYeiKUk57MLeHxXj7Qd68fMny9r4/k76OvX3PCgRxEZpi+mwG1pVeP/E5mh6ibsIYUzexFoSNTZUJEa4xYNBFEaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776371050; c=relaxed/simple; bh=RkVeSI/8uxY9kEBY4dQx+W/UjcDXG8XsRMufGiKQRo0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Q3tHhkh7yHc/ktFXQqg2cowd58TE+69iI/ChmEhDDmQ43gYC6wUSwfBOrU9T8G5IXOGraeHQOaLQRWeeozq+aPF7gSYNn6TMNddSSmCVRKsc47B6B9+qmSrI+PhKmHzjPqde8UoJ/z+3BkjuyNF0/a1gXynLE9KOhiPx9e/eQNg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C36364BAD171 Received: by simark.ca (Postfix) id 5CC681E0C3; Thu, 16 Apr 2026 16:24:10 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 02/11] gdb: rename search_symtabs_expansion_listener -> compunit_symtab_iteration_callback Date: Thu, 16 Apr 2026 16:16:12 -0400 Message-ID: <20260416202408.422441-3-simon.marchi@efficios.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260416202408.422441-1-simon.marchi@efficios.com> References: <20260416202408.422441-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 From: Simon Marchi I think that the name search_symtabs_expansion_listener function type no longer makes sense for the following reasons: - Since we have both `symtab` and `compunit_symtab` structs, I like when we are specific about which one we're talking about. In this case, the callback takes a `compunit_symtab`. - Following series "Search symbols via quick API" [1] last year (I believe commit f88f9f42db8 ("Have expand_symtabs_matching work for already-expanded CUs")), the callback gets called for all matching compunit_symtabs, not just those that get expanded. I therefore propose to rename it to compunit_symtab_iteration_callback. I chose "callback" over "listener", because I think that listener implies that there is some event happening, that we listen for. That made sense before where we would listen for the "expansion" event. But now since it just gets called back for all matching CUs, I think that "callback" makes more sense. I renamed the parameters accordingly. [1] https://inbox.sourceware.org/gdb-patches/20250909-search-in-psyms-v4-0-e7ef9e3b6479@tromey.com/ Change-Id: Ia5a662e6d37caf8e0272424ddbbd82f05bdb5ebe --- gdb/dwarf2/cooked-index.h | 2 +- gdb/dwarf2/read.c | 21 +++++++++++---------- gdb/dwarf2/read.h | 6 +++--- gdb/expanded-symbol.c | 8 ++++---- gdb/expanded-symbol.h | 2 +- gdb/objfiles.h | 2 +- gdb/quick-symbol.h | 21 +++++++++++---------- gdb/symfile-debug.c | 10 +++++----- 8 files changed, 37 insertions(+), 35 deletions(-) diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index d265e86e67d8..00a15661677b 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -242,7 +242,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions search_symtabs_file_matcher file_matcher, const lookup_name_info *lookup_name, search_symtabs_symbol_matcher symbol_matcher, - search_symtabs_expansion_listener listener, + compunit_symtab_iteration_callback compunit_callback, block_search_flags search_flags, domain_search_flags domain, search_symtabs_lang_matcher lang_matcher) override; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 02e6c00dfef5..6146ff78b678 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1457,7 +1457,7 @@ struct readnow_functions : public dwarf2_base_index_functions search_symtabs_file_matcher file_matcher, const lookup_name_info *lookup_name, search_symtabs_symbol_matcher symbol_matcher, - search_symtabs_expansion_listener listener, + compunit_symtab_iteration_callback compunit_callback, block_search_flags search_flags, domain_search_flags domain, search_symtabs_lang_matcher lang_matcher) override @@ -1480,8 +1480,9 @@ struct readnow_functions : public dwarf2_base_index_functions || per_cu->unit_type (false) == 0 || per_objfile->get_compunit_symtab (per_cu.get ()) == nullptr) continue; - if (!search_one (per_cu.get (), per_objfile, cus_to_skip, listener, - lang_matcher)) + + if (!search_one (per_cu.get (), per_objfile, cus_to_skip, + compunit_callback, lang_matcher)) return false; } return true; @@ -1923,7 +1924,7 @@ dwarf2_base_index_functions::search_one (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, auto_bool_vector &cus_to_skip, - search_symtabs_expansion_listener listener, + compunit_symtab_iteration_callback compunit_callback, search_symtabs_lang_matcher lang_matcher) { /* Already visited, or intentionally skipped. */ @@ -1943,10 +1944,10 @@ dwarf2_base_index_functions::search_one = dw2_instantiate_symtab (per_cu, per_objfile, false); gdb_assert (symtab != nullptr); - if (listener != nullptr) + if (compunit_callback != nullptr) { cus_to_skip.set (per_cu->index, true); - return listener (symtab); + return compunit_callback (symtab); } return true; @@ -14035,7 +14036,7 @@ cooked_index_functions::search search_symtabs_file_matcher file_matcher, const lookup_name_info *lookup_name, search_symtabs_symbol_matcher symbol_matcher, - search_symtabs_expansion_listener listener, + compunit_symtab_iteration_callback compunit_callback, block_search_flags search_flags, domain_search_flags domain, search_symtabs_lang_matcher lang_matcher) @@ -14055,7 +14056,7 @@ cooked_index_functions::search { QUIT; - if (!search_one (per_cu, per_objfile, cus_to_skip, listener, + if (!search_one (per_cu, per_objfile, cus_to_skip, compunit_callback, lang_matcher)) return false; } @@ -14223,8 +14224,8 @@ cooked_index_functions::search bool check = entry->visit_defining_cus ([&] (dwarf2_per_cu *per_cu) { - return search_one (per_cu, per_objfile, cus_to_skip, listener, - nullptr); + return search_one (per_cu, per_objfile, cus_to_skip, + compunit_callback, nullptr); }); if (!check) return false; diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index fddaaa7d9e5c..40b55a33bc8d 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -1319,11 +1319,11 @@ struct dwarf2_base_index_functions : public quick_symbol_functions protected: /* If CUS_TO_SKIP does not include the CU's index and the CU's language - matches LANG_MATCHER, expand the CU and call LISTENER (if provided) on - it. */ + matches LANG_MATCHER, expand the CU and call COMPUNIT_CALLBACK (if + provided) on it. */ bool search_one (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, auto_bool_vector &cus_to_skip, - search_symtabs_expansion_listener listener, + compunit_symtab_iteration_callback compunit_callback, search_symtabs_lang_matcher lang_matcher); }; diff --git a/gdb/expanded-symbol.c b/gdb/expanded-symbol.c index d885fe33fa84..fee55cd23db3 100644 --- a/gdb/expanded-symbol.c +++ b/gdb/expanded-symbol.c @@ -53,7 +53,7 @@ expanded_symbols_functions::search search_symtabs_file_matcher file_matcher, const lookup_name_info *lookup_name, search_symtabs_symbol_matcher symbol_matcher, - search_symtabs_expansion_listener listener, + compunit_symtab_iteration_callback compunit_callback, block_search_flags search_flags, domain_search_flags domain, search_symtabs_lang_matcher lang_matcher) @@ -88,11 +88,11 @@ expanded_symbols_functions::search continue; } - /* Here we simply call the listener (if any) without bothering to + /* Here we simply call the callback (if any) without bothering to consult lookup_name and symbol_matcher (if any). This should be - okay since i) all symtabs are already expanded and ii) listeners + okay since i) all symtabs are already expanded and ii) callbacks iterate over matching symbols themselves. */ - if (listener != nullptr && !listener (cu)) + if (compunit_callback != nullptr && !compunit_callback (cu)) return false; } return true; diff --git a/gdb/expanded-symbol.h b/gdb/expanded-symbol.h index 885390ccb124..fc42938d9d3d 100644 --- a/gdb/expanded-symbol.h +++ b/gdb/expanded-symbol.h @@ -70,7 +70,7 @@ struct expanded_symbols_functions : public quick_symbol_functions search_symtabs_file_matcher file_matcher, const lookup_name_info *lookup_name, search_symtabs_symbol_matcher symbol_matcher, - search_symtabs_expansion_listener listener, + compunit_symtab_iteration_callback compunit_callback, block_search_flags search_flags, domain_search_flags domain, search_symtabs_lang_matcher lang_matcher) override; diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 89ac559ce813..aafac6ac93c6 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -622,7 +622,7 @@ struct objfile : intrusive_list_node (search_symtabs_file_matcher file_matcher, const lookup_name_info *lookup_name, search_symtabs_symbol_matcher symbol_matcher, - search_symtabs_expansion_listener listener, + compunit_symtab_iteration_callback compunit_callback, block_search_flags search_flags, domain_search_flags domain, search_symtabs_lang_matcher lang_matcher = nullptr); diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h index a0b00b455020..9cecc1bf52c1 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -55,11 +55,12 @@ using search_symtabs_symbol_matcher using search_symtabs_lang_matcher = gdb::function_view; -/* Callback for quick_symbol_functions::search to be called when - symtab matches (perhaps expanding it first). If this returns true, - more symtabs are checked; if it returns false, iteration stops. */ +/* Callback for quick_symbol_functions::search to be called when a + compunit_symtab matches (perhaps expanding it first). If this + returns true, more compunit_symtabs are checked; if it returns false, + iteration stops. */ -using search_symtabs_expansion_listener +using compunit_symtab_iteration_callback = gdb::function_view; /* The "quick" symbol functions exist so that symbol readers can @@ -151,17 +152,17 @@ struct quick_symbol_functions Otherwise, the symbol's symbol table is expanded if needed. Then (regardless of whether the symbol table was already - expanded, or just expanded in response to this search), LISTENER - is called. If LISTENER returns false, execution stops and this - method returns false. Otherwise, more files are considered. - This method returns true if all calls to LISTENER return - true. */ + expanded, or just expanded in response to this search), + COMPUNIT_CALLBACK is called. If COMPUNIT_CALLBACK returns false, + execution stops and this method returns false. Otherwise, more + files are considered. This method returns true if all calls to + COMPUNIT_CALLBACK return true. */ virtual bool search (struct objfile *objfile, search_symtabs_file_matcher file_matcher, const lookup_name_info *lookup_name, search_symtabs_symbol_matcher symbol_matcher, - search_symtabs_expansion_listener listener, + compunit_symtab_iteration_callback compunit_callback, block_search_flags search_flags, domain_search_flags domain, search_symtabs_lang_matcher lang_matcher = nullptr) = 0; diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 2c9deba20ae4..d26662e20656 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -255,7 +255,7 @@ objfile::map_symtabs_matching_filename return false; }; - auto listener = [&] (compunit_symtab *symtab) + auto compunit_callback = [&] (compunit_symtab *symtab) { /* Skip included compunits, as they are searched by iterate_over_one_compunit_symtab. */ @@ -271,7 +271,7 @@ objfile::map_symtabs_matching_filename for (const auto &iter : qf) { if (!iter->search (this, match_one_filename, nullptr, nullptr, - listener, + compunit_callback, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, SEARCH_ALL_DOMAINS)) { @@ -401,7 +401,7 @@ bool objfile::search (search_symtabs_file_matcher file_matcher, const lookup_name_info *lookup_name, search_symtabs_symbol_matcher symbol_matcher, - search_symtabs_expansion_listener listener, + compunit_symtab_iteration_callback compunit_callback, block_search_flags search_flags, domain_search_flags domain, search_symtabs_lang_matcher lang_matcher) @@ -415,12 +415,12 @@ objfile::search (search_symtabs_file_matcher file_matcher, objfile_debug_name (this), host_address_to_string (&file_matcher), host_address_to_string (&symbol_matcher), - host_address_to_string (&listener), + host_address_to_string (&compunit_callback), domain_name (domain).c_str ()); for (const auto &iter : qf) if (!iter->search (this, file_matcher, lookup_name, symbol_matcher, - listener, search_flags, domain, lang_matcher)) + compunit_callback, search_flags, domain, lang_matcher)) return false; return true; } -- 2.53.0