From: Simon Marchi <simon.marchi@efficios.com>
To: Andrew Burgess <aburgess@redhat.com>,
simon.marchi@polymtl.ca, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 06/11] gdb: use a switch on m_kind in add_matching_symbols
Date: Thu, 1 Oct 2026 11:07:51 -0400 [thread overview]
Message-ID: <38b4d102-1114-41a6-b16d-00a6f77faa66@efficios.com> (raw)
In-Reply-To: <87y0chxy68.fsf@redhat.com>
On 10/1/26 11:01 AM, Andrew Burgess wrote:
> simon.marchi@polymtl.ca writes:
>
>> From: Simon Marchi <simon.marchi@efficios.com>
>>
>> add_matching_symbols applies some filters that only make sense for some
>> kinds of searches: the type regexp for variables and functions, the
>> LOC_UNRESOLVED / enum constant filter for variables, and the line number
>> filter for modules. Some of these check m_kind, others check the
>> symbol's domain. Since the earlier sym->matches check only lets through
>> symbols whose domain corresponds to m_kind, the two are equivalent.
>>
>> Group these filters in a single switch on m_kind. Add a comment for
>> the module filter, which skips module declarations, because it wasn't
>> obvious to me at first sight.
>>
>> Change-Id: Idf1b366b4cfd16187848b64075a0067190c111fc
>> ---
>> gdb/symtab.c | 33 +++++++++++++++++++--------------
>> 1 file changed, 19 insertions(+), 14 deletions(-)
>>
>> diff --git a/gdb/symtab.c b/gdb/symtab.c
>> index 35dd2981a53a..6cc85a7eacc5 100644
>> --- a/gdb/symtab.c
>> +++ b/gdb/symtab.c
>> @@ -4858,25 +4858,30 @@ global_symbol_searcher::add_matching_symbols
>> nullptr, 0) != 0)
>> continue;
>>
>> - if (((sym->domain () == VAR_DOMAIN
>> - || sym->domain () == FUNCTION_DOMAIN)
>> - && type_regex.has_value ()
>> - && !regex_matches_sym_type_name (*type_regex, sym)))
>> - continue;
>> -
>> - if (m_kind == symbol_search_kind::VARIABLE)
>> + switch (m_kind)
>> {
>> + case symbol_search_kind::VARIABLE:
>> + /* LOC_CONST can be used for more than just enums, e.g.,
>> + C++ static const members. We only want to skip enums
>> + here. */
>> if (sym->loc_class () == LOC_UNRESOLVED
>> - /* LOC_CONST can be used for more than
>> - just enums, e.g., c++ static const
>> - members. We only want to skip enums
>> - here. */
>> || (sym->loc_class () == LOC_CONST
>> - && (sym->type ()->code () == TYPE_CODE_ENUM)))
>> + && sym->type ()->code () == TYPE_CODE_ENUM))
>> continue;
>> + [[fallthrough]];
>> +
>> + case symbol_search_kind::FUNCTION:
>> + if (type_regex.has_value ()
>> + && !regex_matches_sym_type_name (*type_regex, sym))
>> + continue;
>> + break;
>> +
>> + case symbol_search_kind::MODULE:
>> + /* Skip module declarations, keep only definitions. */
>> + if (sym->line () == 0)
>> + continue;
>> + break;
>
> I agree with Stephan's suggestion that you should add:
>
> case symbol_search_kind::TYPE:
> break;
>
> I would not focus on GDB's use or non-use of -Wswitch. Instead, my
> argument is that by specifically mentioning the extra case we make it
> clear that nothing needs to be done rather than leaving it for a future
> reader of the code to try and figure out if TYPE is missing on purpose,
> or by accident.
>
> I don't find the reasoning that there are lots of other missing case
> labels compelling, I think the argument for or against should stand on
> its own technical merits -- unless you're suggesting that the GDB style
> is to trim the case list as much as possible?
When seeing an empty case, my intuition would be to remove it, but I
really don't have strong feelings about that. Since you both mentioned
it, I'll add it.
>
> That said, I only care enough to send one email on the topic :) If
> you're still not convinced then go ahead:
>
> Approved-By: Andrew Burgess <aburgess@redhat.com>
Thanks,
Simon
next prev parent reply other threads:[~2026-10-01 15:08 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
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 [this message]
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=38b4d102-1114-41a6-b16d-00a6f77faa66@efficios.com \
--to=simon.marchi@efficios.com \
--cc=aburgess@redhat.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