From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WdXxJn8UvGoGjxkAWB0awg (envelope-from ) for ; Tue, 29 Sep 2026 15:41:51 -0400 Received: by simark.ca (Postfix, from userid 112) id 35C461E051; Tue, 29 Sep 2026 15:41:51 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 258271E051 for ; Tue, 29 Sep 2026 15:41:48 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 208AC4BA23DB for ; Tue, 29 Sep 2026 19:41:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 208AC4BA23DB Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 84F5D4BA23D0 for ; Tue, 29 Sep 2026 19:41:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 84F5D4BA23D0 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 84F5D4BA23D0 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790710883; cv=none; b=h7dcNIf/rmUzXeai4u6cMTghbpzhJfqdGkugKrTBPmq/InTAxYGWtqQ1QykIk7znzaEDFF6P19GKSkurBF1pLXwk42ZPUyElhPpMH8yQHNXflSsy1M3hO/p1oXPsPYTTdcdBYkIDaBqRDfu+1WhUEZ36uXe/xFQeJhMRbopz/28= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790710883; c=relaxed/simple; bh=78aGUMeAmm9+TG9iYPviym723UUOPhHD/NJagrZMNaY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=AHk9tXQoenaRFLggujWAh2g1Hgs2kAJMiyAFRQiCtCr7xbvCaJpQs/27rYjHYaI/Wn80bhm0oNwFfJqnOR1EeUEh3Im0EQZwU5mXkK6W9SfKH1otiHwBHqlk6Sz5NDgQJ3u5IJw7QonWVLrq9f9MXo/unZqJpqHNIXGxBrlNNDY= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84F5D4BA23D0 Received: by simark.ca (Postfix) id EF14C1E091; Tue, 29 Sep 2026 15:41:22 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 4/9] gdb: use a switch on m_kind in add_matching_symbols Date: Tue, 29 Sep 2026 15:39:25 -0400 Message-ID: <20260929194119.155169-5-simon.marchi@efficios.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260929194119.155169-1-simon.marchi@efficios.com> References: <20260929194119.155169-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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 4b2c4be8d117..2bb1cbf1b9ad 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4860,25 +4860,30 @@ global_symbol_searcher::add_matching_symbols nullptr, 0) != 0) continue; - if (((sym->domain () == VAR_DOMAIN - || sym->domain () == FUNCTION_DOMAIN) - && type_regex.has_value () - && !treg_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 () + && !treg_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; } - if (sym->domain () == MODULE_DOMAIN && sym->line () == 0) - continue; /* Match, insert if not already in the results. */ if (result_set->size () < m_max_search_results) -- 2.55.0