From: Simon Marchi <simon.marchi@efficios.com>
To: "Rohr, Stephan" <stephan.rohr@intel.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/9] gdb: add symbol_search_kind enum for global_symbol_searcher
Date: Wed, 30 Sep 2026 10:50:43 -0400 [thread overview]
Message-ID: <c9ded2f6-6e50-4513-a71a-8480ed99667a@efficios.com> (raw)
In-Reply-To: <DS7PR11MB6247455443EA9D148423EAB5938B2@DS7PR11MB6247.namprd11.prod.outlook.com>
On 2026-09-30 05:31, Rohr, Stephan wrote:
> Hi Simon,
>
> see my feedback inlined below.
>
> Thanks
> Stephan
>
>> -----Original Message-----
>> From: Simon Marchi <simon.marchi@efficios.com>
>> Sent: Tuesday, 29 September 2026 21:39
>> To: gdb-patches@sourceware.org
>> Cc: Simon Marchi <simon.marchi@efficios.com>
>> Subject: [PATCH 1/9] gdb: add symbol_search_kind enum for
>> global_symbol_searcher
>>
>> While reading the global_symbol_searcher code, something that was not
>> clear to me was that despite accepting a domain_search_flags, searches
>
> Double spaces in ", searches".
Done.
>> are mutually exclusive between types, variables and functions.
>>
>> One snippet of code that really confused me was (now removed by a
>> previous commit):
>>
>
> Should we mention the previous commit " gdb: Skip useless minsym scan in
> variable-only symbol searches" explicitly? It may help future readers of the
> patch.
Done.
>> diff --git a/gdb/symtab.c b/gdb/symtab.c
>> index 27070f74f83e..708df078e2ea 100644
>> --- a/gdb/symtab.c
>> +++ b/gdb/symtab.c
>> @@ -4698,11 +4698,31 @@ treg_matches_sym_type_name (const
>> compiled_regex &treg,
>> return treg.exec (printed_sym_type_name.c_str (), 0, NULL, 0) == 0;
>> }
>>
>> +/* Return the domain search flags matching symbols of kind KIND. */
>> +
>> +static domain_search_flags
>> +to_search_flags (symbol_search_kind kind)
>
> Same name as " to_search_flags (domain_enum domain)" in symtab.h.
> Not sure if this might be confusing. I don't have a strong opinion here.
Yes, that's the intent, two overloads that do the same job but with
different input.
>> +{
>> + switch (kind)
>> + {
>> + case symbol_search_kind::VARIABLE:
>> + return SEARCH_VAR_DOMAIN;
>> + case symbol_search_kind::FUNCTION:
>> + return SEARCH_FUNCTION_DOMAIN;
>> + case symbol_search_kind::TYPE:
>
> Should we add a comment why the " SEARCH_STRUCT_DOMAIN" is
> included? I think this might be helpful for future readers, e.g.
> "Some languages have a tag namespace. Search the "STRUCT_DOMAIN", too."
I hesitated to put that clarification on the enumerator itself, but then
thought that the code here would make it clear that
symbol_search_kind::TYPE includes both the bare types and the "struct
domain" types. given your comment, I would add that clarification on
the enumerator:
/* Type names, including those with a struct/union/enum prefix (STRUCT
domain). */
TYPE,
>> @@ -5166,20 +5179,20 @@ symtab_symbol_info (bool quiet, bool
>> exclude_minsyms,
>> const char *classname;
>> switch (kind)
>> {
>> - case VAR_DOMAIN:
>> + case symbol_search_kind::VARIABLE:
>> classname = "variable";
>> break;
>> - case FUNCTION_DOMAIN:
>> + case symbol_search_kind::FUNCTION:
>> classname = "function";
>> break;
>> - case TYPE_DOMAIN:
>> + case symbol_search_kind::TYPE:
>> classname = "type";
>> break;
>> - case MODULE_DOMAIN:
>> + case symbol_search_kind::MODULE:
>> classname = "module";
>> break;
>> default:
>> - gdb_assert_not_reached ("invalid domain enum");
>> + gdb_assert_not_reached ("invalid symbol_search_kind");
>
> I think we could drop the "default" case as part of this refactoring. All
> cases are handled; we lose compile time warnings for unhandled cases with
> the "default" case.
Agreed that we can drop the default. Note that we don't build with
-Wswitch, but we specifically enable it locally here and there.
>> diff --git a/gdb/symtab.h b/gdb/symtab.h
>> index 6443216fd7f0..a35449fbeeda 100644
>> --- a/gdb/symtab.h
>> +++ b/gdb/symtab.h
>> @@ -2586,6 +2586,23 @@ struct symbol_search
>> const symbol_search &sym_b);
>> };
>>
>> +/* The kind of symbols searched for by global_symbol_searcher. */
>> +
>> +enum class symbol_search_kind
>> +{
>> + /* Variables, excluding enum constants. */
>> + VARIABLE,
>> +
>> + /* Functions. */
>> + FUNCTION,
>> +
>> + /* Type names. */
>
> IIUC, this covers "SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN" ?
> Should the comment be extended to state this explicitly, e.g., "Type names,
> including struct, union and enum tags." ?
Done, as per the comment above.
Simon
next prev parent reply other threads:[~2026-09-30 14:51 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 19:39 [PATCH 0/9] Cleanups in global_symbol_searcher Simon Marchi
2026-09-29 19:39 ` [PATCH 1/9] gdb: add symbol_search_kind enum for global_symbol_searcher Simon Marchi
2026-09-30 9:31 ` Rohr, Stephan
2026-09-30 14:50 ` Simon Marchi [this message]
2026-09-29 19:39 ` [PATCH 2/9] gdb: factor out regexp compilation from global_symbol_searcher::search Simon Marchi
2026-09-30 12:10 ` Rohr, Stephan
2026-09-30 16:21 ` Simon Marchi
2026-09-29 19:39 ` [PATCH 3/9] gdb: simplify insertion in global_symbol_searcher::add_matching_symbols Simon Marchi
2026-09-30 8:20 ` Rohr, Stephan
2026-09-30 16:36 ` Simon Marchi
2026-09-29 19:39 ` [PATCH 4/9] gdb: use a switch on m_kind in add_matching_symbols Simon Marchi
[not found] ` <DS7PR11MB624725508FC878F3C263C2B3938B2@DS7PR11MB6247.namprd11.prod.outlook.com>
2026-09-30 19:41 ` Simon Marchi
2026-09-29 19:39 ` [PATCH 5/9] gdb: make global_symbol_searcher::is_suitable_msymbol non-static Simon Marchi
2026-09-30 12:39 ` Rohr, Stephan
2026-09-29 19:39 ` [PATCH 6/9] gdb: update comment of global_symbol_searcher::expand_symtabs Simon Marchi
2026-09-30 13:08 ` Rohr, Stephan
2026-09-30 20:01 ` Simon Marchi
2026-09-29 19:39 ` [PATCH 7/9] gdb: add matching helpers to global_symbol_searcher Simon Marchi
2026-09-30 13:51 ` Rohr, Stephan
2026-09-30 20:27 ` Simon Marchi
2026-09-29 19:39 ` [PATCH 8/9] gdb: pass result containers by reference in global_symbol_searcher Simon Marchi
2026-09-30 13:58 ` Rohr, Stephan
2026-10-01 1:33 ` Simon Marchi
2026-09-29 19:39 ` [PATCH 9/9] gdb: fix some comments " Simon Marchi
2026-09-30 14:01 ` Rohr, Stephan
2026-10-01 1:38 ` Simon Marchi
2026-10-01 2:09 ` [PATCH v2 00/11] Cleanups " simon.marchi
2026-10-01 2:09 ` [PATCH v2 01/11] gdb: add symbol_search_kind enum for global_symbol_searcher simon.marchi
2026-10-01 10:30 ` Andrew Burgess
2026-10-01 13:22 ` Simon Marchi
2026-10-01 15:35 ` Tom Tromey
2026-10-01 2:09 ` [PATCH v2 02/11] gdb: rename some preg/treg variables simon.marchi
2026-10-01 12:59 ` Andrew Burgess
2026-10-01 13:52 ` Simon Marchi
2026-10-01 2:09 ` [PATCH v2 03/11] gdb: factor out regexp compilation from global_symbol_searcher::search simon.marchi
2026-10-01 13:19 ` Andrew Burgess
2026-10-01 13:54 ` Simon Marchi
2026-10-01 2:09 ` [PATCH v2 04/11] gdb: use compile_symbol_search_regex in stack.c simon.marchi
2026-10-01 13:43 ` Andrew Burgess
2026-10-01 15:36 ` Tom Tromey
2026-10-01 15:52 ` Simon Marchi
2026-10-01 2:09 ` [PATCH v2 05/11] gdb: simplify insertion in global_symbol_searcher::add_matching_symbols simon.marchi
2026-10-01 13:46 ` Andrew Burgess
2026-10-01 2:09 ` [PATCH v2 06/11] gdb: use a switch on m_kind in add_matching_symbols simon.marchi
2026-10-01 15:01 ` Andrew Burgess
2026-10-01 15:07 ` Simon Marchi
2026-10-01 2:09 ` [PATCH v2 07/11] gdb: make global_symbol_searcher::is_suitable_msymbol non-static simon.marchi
2026-10-01 15:09 ` Andrew Burgess
2026-10-01 2:09 ` [PATCH v2 08/11] gdb: update comments of global_symbol_searcher::expand_symtabs simon.marchi
2026-10-01 15:13 ` Andrew Burgess
2026-10-01 2:09 ` [PATCH v2 09/11] gdb: add matching helpers to global_symbol_searcher simon.marchi
2026-10-01 15:39 ` Andrew Burgess
2026-10-01 15:48 ` Simon Marchi
2026-10-01 2:09 ` [PATCH v2 10/11] gdb: change some pointers to references in global_symbol_searcher simon.marchi
2026-10-01 15:53 ` Andrew Burgess
2026-10-01 15:55 ` Simon Marchi
2026-10-01 2:09 ` [PATCH v2 11/11] gdb: fix some comments " simon.marchi
2026-10-01 15:56 ` Andrew Burgess
2026-10-01 17:47 ` 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=c9ded2f6-6e50-4513-a71a-8480ed99667a@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
--cc=stephan.rohr@intel.com \
/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