From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 02/11] gdb: rename search_symtabs_expansion_listener -> compunit_symtab_iteration_callback
Date: Thu, 16 Apr 2026 16:16:12 -0400 [thread overview]
Message-ID: <20260416202408.422441-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20260416202408.422441-1-simon.marchi@efficios.com>
From: Simon Marchi <simon.marchi@polymtl.ca>
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<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);
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<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 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
next prev parent reply other threads:[~2026-04-16 20:24 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 20:16 [PATCH 00/11] Readability improvements of some iteration functions Simon Marchi
2026-04-16 20:16 ` [PATCH 01/11] gdb/dwarf: remove unused file_match parameter from dwarf2_base_index_functions::search_one Simon Marchi
2026-04-17 11:11 ` Andrew Burgess
2026-04-16 20:16 ` Simon Marchi [this message]
2026-04-17 15:08 ` [PATCH 02/11] gdb: rename search_symtabs_expansion_listener -> compunit_symtab_iteration_callback Simon Marchi
2026-04-17 17:17 ` Tom Tromey
2026-04-17 19:34 ` Simon Marchi
2026-04-16 20:16 ` [PATCH 03/11] gdb: introduce iteration_status enum, use it for search callbacks Simon Marchi
2026-04-17 11:01 ` Andrew Burgess
2026-04-17 14:33 ` Simon Marchi
2026-04-17 14:34 ` Tom Tromey
2026-04-16 20:16 ` [PATCH 04/11] gdb, gdbserver: make iterate_over_lwps_ftype a function_view Simon Marchi
2026-04-17 11:09 ` Andrew Burgess
2026-04-17 14:37 ` Simon Marchi
2026-04-16 20:16 ` [PATCH 05/11] gdb, gdbserver: split iterate_over_lwps in for_each_lwp and find_lwp Simon Marchi
2026-04-17 11:25 ` Andrew Burgess
2026-04-17 14:53 ` Simon Marchi
2026-04-16 20:16 ` [PATCH 06/11] gdb: split iterate_over_threads in for_each_thread and find_thread Simon Marchi
2026-04-17 11:33 ` Andrew Burgess
2026-04-16 20:16 ` [PATCH 07/11] gdb: split iterate_over_minimal_symbols in for_each_minimal_symbol and find_minimal_symbol Simon Marchi
2026-04-17 12:13 ` Andrew Burgess
2026-04-16 20:16 ` [PATCH 08/11] gdb: split iterate_over_symtabs in for_each_symtab and find_symtab Simon Marchi
2026-04-17 13:31 ` Andrew Burgess
2026-04-17 14:54 ` Simon Marchi
2026-04-16 20:16 ` [PATCH 09/11] gdb: change objfile::map_symtabs_matching_filename to find_symtab_matching_filename Simon Marchi
2026-04-17 13:50 ` Andrew Burgess
2026-04-17 15:03 ` Simon Marchi
2026-04-16 20:16 ` [PATCH 10/11] gdb: make symbol_found_callback_ftype a function_view Simon Marchi
2026-04-17 13:55 ` Andrew Burgess
2026-04-17 15:04 ` Simon Marchi
2026-04-16 20:16 ` [PATCH 11/11] gdb: make iterate_over_symbols return void, rename to for_each_symbol Simon Marchi
2026-04-17 14:05 ` Andrew Burgess
2026-04-17 15:06 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260416202408.422441-3-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox