[binutils-gdb] gdb: rename search_symtabs_expansion_listener -> compunit_symtab_iteration_callback
Simon Marchi via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=85d417c37274603f5265ce67e348789e5c8417cf commit 85d417c37274603f5265ce67e348789e5c8417cf Author: Simon Marchi <[email protected]> Date: Thu Apr 16 16:16:12 2026 -0400 gdb: rename search_symtabs_expansion_listener -> compunit_symtab_iteration_callback 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/[email protected]/ Change-Id: Ia5a662e6d37caf8e0272424ddbbd82f05bdb5ebe Approved-By: Tom Tromey <[email protected]> Diff: --- 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 d265e86e67d..00a15661677 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 02e6c00dfef..6146ff78b67 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 fddaaa7d9e5..40b55a33bc8 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 d885fe33fa8..fee55cd23db 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 885390ccb12..fc42938d9d3 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 89ac559ce81..aafac6ac93c 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -622,7 +622,7 @@ public: (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 a0b00b45502..9cecc1bf52c 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<bool (enum language lang)>; -/* 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<bool (compunit_symtab *symtab)>; /* 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 2c9deba20ae..d26662e2065 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; }