From: Simon Marchi <simon.marchi@efficios.com>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 09/11] gdb: change objfile::map_symtabs_matching_filename to find_symtab_matching_filename
Date: Fri, 17 Apr 2026 11:03:41 -0400 [thread overview]
Message-ID: <9026e071-144f-4f13-ba9e-a668b3f3f95b@efficios.com> (raw)
In-Reply-To: <87a4v1elwx.fsf@redhat.com>
On 4/17/26 9:50 AM, Andrew Burgess wrote:
> Simon Marchi <simon.marchi@efficios.com> writes:
>
>> The only user of objfile::map_symtabs_matching_filename uses that method
>> to find the first matching symtab. It would therefore be more natural
>> for that method to be a "find" method, returning the first symtab
>> matching the predicate.
>>
>> Change map_symtabs_matching_filename to be
>> find_symtab_in_compunit_symtab, and the internal
>> iterate_over_one_compunit_symtab to be find_symtab_in_compunit_symtab.
>
> Typo:
>
> Change map_symtabs_matching_filename to be find_symtab_in_compunit_symtab, and ..."
>
> Should be:
>
> Change map_symtabs_matching_filename to be find_symtab_matching_filename, and ..."
Done.
>>
>> This makes function find_symtab simpler.
>>
>> Change-Id: Id14a95498fad243495d6eab18810d0c4ab8dbf90
>> ---
>> gdb/objfiles.h | 16 +++-----
>> gdb/symfile-debug.c | 89 +++++++++++++++++++++------------------------
>> gdb/symtab.c | 20 ++--------
>> 3 files changed, 52 insertions(+), 73 deletions(-)
>>
>
>> diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
>> index 8e4892649508..d90f400f379c 100644
>> --- a/gdb/symfile-debug.c
>> +++ b/gdb/symfile-debug.c
>> @@ -159,29 +159,30 @@ objfile::forget_cached_source_info ()
>> iter->forget_cached_source_info (this);
>> }
>>
>> -/* Check for a symtab of a specific name by searching some symtabs.
>> +/* Find the first symtab of CUST matching BASE_NAME, NAME and REAL_PATH, for
>> + which CALLBACK returns true.
>>
>> If NAME is not absolute, then REAL_PATH is NULL
>> If NAME is absolute, then REAL_PATH is the gdb_realpath form of NAME.
>>
>> The return value, NAME, REAL_PATH and CALLBACK are identical to the
>> - `map_symtabs_matching_filename' method of quick_symbol_functions.
>> + `find_symtab_matching_filename' method of quick_symbol_functions.
>
> This comment doesn't make sense. The find_symtab_matching_filename
> function is a member function of `objfile` not
> `quick_symbol_functions`. You didn't write that, but it looks like a
> pre-existing mistake in the comment. Can you fix that please? Maybe:
>
> The return value, NAME, REAL_PATH and CALLBACK are identical to the
> `objfile::find_symtab_matching_filename' method.
>
> Would do?
Ah, it's possible that
quick_symbol_functions::map_symtabs_matching_filename existed before,
and then it was merged into the do-it-all search method.
Fixed as you suggested.
>> @@ -254,6 +258,7 @@ objfile::map_symtabs_matching_filename
>> return false;
>> };
>>
>> + symtab *result = nullptr;
>> auto compunit_callback = [&] (compunit_symtab *symtab)
>> {
>> /* Skip included compunits, as they are searched by
>
> The next line of this comment references
> iterate_over_one_compunit_symtab, and should be updated to
> find_symtab_in_compunit_symtab.
Fixed.
>> diff --git a/gdb/symtab.c b/gdb/symtab.c
>> index 6a5c8c7058e4..fd841318387e 100644
>> --- a/gdb/symtab.c
>> +++ b/gdb/symtab.c
>> @@ -637,8 +637,6 @@ static symtab *
>> find_symtab (program_space *pspace, const char *name,
>> find_symtab_callback_ftype callback)
>> {
>> - struct symtab *result = NULL;
>> -
>
> Ahh, I should have looked ahead! I complained about this in the last
> patch, but I see it's now gone. No need to change the last patch I
> guess.
No worries, it was easy to fix. I also don't look ahead much when
reviewing patches, otherwise it's a lot of tokens to hold in the small
context window in my brain.
>
>> gdb::unique_xmalloc_ptr<char> real_path;
>>
>> /* Here we are interested in canonicalizing an absolute path, not
>
> Approved-By: Andrew Burgess <aburgess@redhat.com>
Thanks,
Simon
next prev parent reply other threads:[~2026-04-17 15:06 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 ` [PATCH 02/11] gdb: rename search_symtabs_expansion_listener -> compunit_symtab_iteration_callback Simon Marchi
2026-04-17 15:08 ` 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 [this message]
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=9026e071-144f-4f13-ba9e-a668b3f3f95b@efficios.com \
--to=simon.marchi@efficios.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/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