From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ef5fLuV1vmpqIiQAWB0awg (envelope-from ) for ; Thu, 01 Oct 2026 11:01:57 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KgVj9O6e; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B97B41E051; Thu, 01 Oct 2026 11:01:57 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 DD8DD1E01F for ; Thu, 01 Oct 2026 11:01:56 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E71DE4BB3BB1 for ; Thu, 1 Oct 2026 15:01:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E71DE4BB3BB1 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KgVj9O6e Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 5ED224BA23D1 for ; Thu, 1 Oct 2026 15:01:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5ED224BA23D1 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5ED224BA23D1 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790866886; cv=none; b=Wnfe2x+Ox+RCXDYhDJ7fyFZlfN/GlztWfcnti4erPT13VWmzJfUFRwIXSTP84y0Z17zTExmETSRptPYxNcGkrEBLGxApDzYusHsLLwX3OElncMgzgPVYdhaoz2QC4+Iv5BluGVgLpPd8RjPIEV3/yUZGMbP1sNz6EIo1+UxmtE8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790866886; c=relaxed/simple; bh=qXMI/HMVAN++2W9xyK2xPGphYjx67/mVhzApGlIzflE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=SNNa86cn5fW1V+Snjks+k739D2rUY10tcGZv6xALtBhSFtzwbh8g9eXTYoTmqJqfHOiuXvuLwb2PbWn7wZYauODLuegdq0/UpkeeBUQmjNym4JyRnaPhwrMRycA+Mxq+cLtEKH/DINy9zPk97+LKMZ9unJjXprp3gXvxPChPGDo= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KgVj9O6e DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5ED224BA23D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790866886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dpdbtPUfZ3oekfrQY/ggXip8DYfSB6OKC+QN8SuRqBo=; b=KgVj9O6eUFSE0vn/uNfe6vlAVDbkfO71cqw+15AslNdQKHVB/ZIr6k/pnRwadM2T6EYjTR K0DJrh45bVW8EmotN5TakVvu2uQFu8nIY9vZ09TghPzJ1YoJldy1rlpXZ/e8HwlrMCjZ9R Pr0ygsWZEcASw9jk8jwsJw0Aiewlidg= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-Qt2HI85nP5mdsV5MPQBVVg-1; Thu, 01 Oct 2026 11:01:23 -0400 X-MC-Unique: Qt2HI85nP5mdsV5MPQBVVg-1 X-Mimecast-MFC-AGG-ID: Qt2HI85nP5mdsV5MPQBVVg_1790866882 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4a013ea30c0so18371545e9.0 for ; Thu, 01 Oct 2026 08:01:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790866881; x=1791471681; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=dpdbtPUfZ3oekfrQY/ggXip8DYfSB6OKC+QN8SuRqBo=; b=V0gsOoU000m2MK2P9CoGiE9AozgBsritS1pF0RAi0HjeN/S+SOHdr7kIG8fSuUeDDf j224bQEB9UYs+vamRJsUSQn2AZBknhEM07DvRx8tb+rEgQ5N3YSG+1LIrUuqyGzF03so jt5Ld23ud/sLdLvatuTKJTH062SKPV5KNTFiXDohABTG2EB2cQxz8ZKzFxe5zOkRiTUs ozf09NYD59EYrYw7Cp9hn6Beacs9sOQoCcytjn87Yu5ynuj6l/oUkZu3KcJjahQUWnz0 xjz3LR4UBurMAAyV8s9fUYkT7uv2MSaJdn8puoPAhXYczPjafJE5xbe2JGO5wRFQiUJf ygBA== X-Forwarded-Encrypted: i=1; AKwUvBxnvXYnJns+I6a7YJ35tXqhmWHdK7OpFbmi7aAl1vgnmBkbA1zubYLZQJwgQFHR3BqG7KC/yR3Uvfdcog==@sourceware.org X-Gm-Message-State: AFuF++nohDuE5XOK+XTtdwTYp/HxkVpsniuh7v6r8KIGpOgr5Emc55d3 r3pJKlgqPvylgd7nnPLxlnKkwMoqy+4h15LJBUiK4NDaAvo6UvhP6tN7NBuPBJRSyecvrnsnHR6 KkPad9vDqFiw7XPUoi+3AJbg2EnO3clHK6pAp6XWJWEn0KHaiNdvxPUjO77FCWDA= X-Gm-Gg: AYBFou0kQEDkzXqpWe1pOh/WMKHNwskPS4BPvpnwtuqZTE0TDwnVbWGsC2B9oAMYL44 LRl8pSdwEw+mhEe3Y22kKvVmewLWmFxaGXxsGUDg5vDzsBm12GzR+mzLJlr2aXOJmToWQyh9UWK QLcC8sIhDaqn7puLO8ACv2u7EUhBQpxAR83lSF0cbO71CiFoLdutmMPzk+tkSuLZzdoC3SxjVy9 JCzAKTsbtQ8YG1LguD/hDmWPONlWW3iHfl7HDNXPz3/5CmgrRZX/1ZWbyotn6tabn5SdWM7io1E 9E+KkNs4kGMJrl9ZpdLZ0PL4ntFFV6AezabTQUBegfY8iAzCVIDZm+m4sxSuDcUGK6Yv X-Received: by 2002:a05:600c:4e92:b0:4a0:1e53:e51f with SMTP id 5b1f17b1804b1-4a01e53e637mr63540665e9.14.1790866881428; Thu, 01 Oct 2026 08:01:21 -0700 (PDT) X-Received: by 2002:a05:600c:4e92:b0:4a0:1e53:e51f with SMTP id 5b1f17b1804b1-4a01e53e637mr63539625e9.14.1790866880579; Thu, 01 Oct 2026 08:01:20 -0700 (PDT) Received: from localhost ([213.31.44.29]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a02728edd2sm1774895e9.10.2026.10.01.08.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2026 08:01:20 -0700 (PDT) From: Andrew Burgess To: simon.marchi@polymtl.ca, gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH v2 06/11] gdb: use a switch on m_kind in add_matching_symbols In-Reply-To: <20261001020952.698419-7-simon.marchi@polymtl.ca> References: <20260929194119.155169-1-simon.marchi@efficios.com> <20261001020952.698419-7-simon.marchi@polymtl.ca> Date: Thu, 01 Oct 2026 16:01:19 +0100 Message-ID: <87y0chxy68.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MmcvJKCDLvjhdzc_9uZPITfnvyO8Vt1g261VmMP_HFY_1790866882 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 simon.marchi@polymtl.ca writes: > From: Simon Marchi > > 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? 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 Thanks, Andrew > } > - 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