From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 5WfdMQVevmoexCMAWB0awg (envelope-from ) for ; Thu, 01 Oct 2026 09:20:05 -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=Rolj8Xp1; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B5FF11E051; Thu, 01 Oct 2026 09:20:05 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.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,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 D9E0A1E033 for ; Thu, 01 Oct 2026 09:20:04 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B5AE74BB5937 for ; Thu, 1 Oct 2026 13:20:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5AE74BB5937 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=Rolj8Xp1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 6FC654BAE7D8 for ; Thu, 1 Oct 2026 13:19:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6FC654BAE7D8 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 6FC654BAE7D8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790860777; cv=none; b=Y1bNN9BqSo3vEb6RmfLL3XYvoXCs4KhFtXrFq11u1CzYUZo/Sk3OQhGUYkphnprqsjNl8g11/2esqufZkI8UCFcj5K+lGPM2ZIlDxVIhFJLjXrFEWmCq5Dnf0YZUR658AxookWZW3faZ1RWkoSYz0TgoXsH5/3lwiK1KNkP3LUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790860777; c=relaxed/simple; bh=zu6C9yc7LnKBelcwdgpvuAE+Mop2az183hg3NdR9Rno=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=H0Koej29SjI7amenETVff3vUN/4Lc7tHYfoT9oCTkTkf75+5fPc12y0PliY6S41taQBMF8xfo+QUZgpCfgbH+gx2Hv6f2y7tp1YByT+pT1fPoKVo0b/HJ8fycVN/wncENd1Ur5SDXlPPl4jhLkek1k8vBrIcMqUvGz3XyIv2Npc= 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=Rolj8Xp1 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FC654BAE7D8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790860776; 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=S5VOmJ/M4NdZqZxPuesbGEJIV2BC1rlIPH+AshdjyQ4=; b=Rolj8Xp1n9rTfbePvacZxjAjLRmnLMwhcLCx0gb40x4wTGgJkyvmqNxFzs/eT3ueNRTNQG BiawKibDP7e1/22szXoQ3JT26Cyz+VZFE+9kaG4RnLs5uVjDT24WMubquznE/HFCkq14cR l7Ae7Ij1Os1gpyOY3UYBSUSqo6U1toI= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-Uef8kuVNMU6Rm1DGWW-zFQ-1; Thu, 01 Oct 2026 09:19:34 -0400 X-MC-Unique: Uef8kuVNMU6Rm1DGWW-zFQ-1 X-Mimecast-MFC-AGG-ID: Uef8kuVNMU6Rm1DGWW-zFQ_1790860774 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4a0023f2b97so25383365e9.2 for ; Thu, 01 Oct 2026 06:19:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790860773; x=1791465573; 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=S5VOmJ/M4NdZqZxPuesbGEJIV2BC1rlIPH+AshdjyQ4=; b=JfVmJy3dHsYwgMHfhHvZ9RPee1YDyBbNHMgzMHyrbb/NldFaWie8jtUoUmbZVAtBbC choOJsHSEUzn2Z2K1a8a9P1NSdjmHmIPeKSNpUgbuLSwkigooP4o1j9D9/foFKRYUCor fbzxJcREuFj50AkHkgYhHO6tVz5k7AxmlW/sCMpRYmS0GDdFuMb54DUl1NX4pEN2WuLr KHLfEgvWBkU+9ygiDz5BHxeuzN238jf/6jdIUMD1oKCGoqZB6+1Ho/JBHH9tAeqFoQBO 83rj2uNmVgyf29wL7e/DxjQPgxm70QXtLZhFHeLTqQjFRIg+rw4ounXAH/Igo7oOIlHx a66g== X-Forwarded-Encrypted: i=1; AKwUvBzmKrkgPVxcUYiy7DCYR9QYbyT79Ab1TTZhSJ3qqluCNaCZJ6c8INpsWWCsj+lNXTQ+bgARe0mrZklKAw==@sourceware.org X-Gm-Message-State: AFuF++niVycVI3C+1/CNUkG2C2I6l5knY2+RMtFWxk6nOw9EibVFJs4f c5pGnuTXEB4FsTGnkEZVPOWXzELk3f2aLS2H/Ucu1M+f9kNCIw1DvTmkyrG6yvUpqXZP3vFqTwg 8HEackx1gD/ZwhM7aubRDkD9s3sG9dO3ACbWNqWIGXLxBeClmSVC4tBGSFynG8SOpFY4XvUg= X-Gm-Gg: AYBFou0qKnYBPlSpSFzPKN9P/IHVL6vCldZqj1dg8KIYeqJbK4uZcq86BOSGOjwV91q 31jhdU+W4/Q4hTiAk8Klu4297+UOu3TVEAP52h6suYAC/z4DcJZ3YmUMCp3IJhlVi6B3ZFG49n/ qdDmdvS3dC351BGZbuV4JMH+2csXcirpA+juuQLxwydcfPknAQyt6dNCt68cyplKOr+XGp2Idtf zWv42Xanpq6PD1xIHFMEf64+QPDfyC47CooYGPzlFfo2qQZaCLGSJX6NKDY/bayN5prVu79Rqoj HLTayKpRwku1i4sive3/Ybagcocj6pOaFsuATd1mfeXodM3rFlkMmCWcvxDZzBHQMKcQHA== X-Received: by 2002:a05:600c:8712:b0:49f:cc2a:f73a with SMTP id 5b1f17b1804b1-4a01b0117ffmr81481515e9.25.1790860773593; Thu, 01 Oct 2026 06:19:33 -0700 (PDT) X-Received: by 2002:a05:600c:8712:b0:49f:cc2a:f73a with SMTP id 5b1f17b1804b1-4a01b0117ffmr81481045e9.25.1790860773110; Thu, 01 Oct 2026 06:19:33 -0700 (PDT) Received: from localhost ([213.31.44.29]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a0267ad715sm1582315e9.0.2026.10.01.06.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2026 06:19:32 -0700 (PDT) From: Andrew Burgess To: simon.marchi@polymtl.ca, gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH v2 03/11] gdb: factor out regexp compilation from global_symbol_searcher::search In-Reply-To: <20261001020952.698419-4-simon.marchi@polymtl.ca> References: <20260929194119.155169-1-simon.marchi@efficios.com> <20261001020952.698419-4-simon.marchi@polymtl.ca> Date: Thu, 01 Oct 2026 14:19:31 +0100 Message-ID: <877bk1zhgc.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 402lNaxFC1gPtVzj7B-hgq7NLxOp5aBLBgsnF2d8kQc_1790860774 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 > > Factor out the scopes that compile the regexps, in order to make > global_symbol_searcher::search itself simpler to read. Factor out a helper > to compile a symbol search regex as well. Three super minor nits, two of which are pre-existing, see inline... > diff --git a/gdb/symtab.c b/gdb/symtab.c > index aae82218b5cf..49e8719f4ec0 100644 > --- a/gdb/symtab.c > +++ b/gdb/symtab.c > @@ -4938,66 +4938,86 @@ global_symbol_searcher::add_matching_msymbols > return true; > } > > -/* See symtab.h. */ > +/* Compile REGEXP, a symbol name or symbol type regexp. > > -std::vector > -global_symbol_searcher::search () const > + If REGEXP is nullptr, return an empty optional. */ > + > +static std::optional > +compile_symbol_search_regex (const char *regexp) > { > - std::optional name_regex; > - std::optional type_regex; > + if (regexp == nullptr) > + return {}; > > - if (m_symbol_name_regexp != NULL) > - { > - const char *symbol_name_regexp = m_symbol_name_regexp; > - std::string symbol_name_regexp_holder; > + int cflags > + = REG_NOSUB | (case_sensitivity == case_sensitive_off ? REG_ICASE : 0); > > - /* Make sure spacing is right for C++ operators. > - This is just a courtesy to make the matching less sensitive > - to how many spaces the user leaves between 'operator' > - and or . */ > - const char *op_end; > - const char *opname = operator_chars (symbol_name_regexp, &op_end); > + return std::make_optional (regexp, cflags, > + _("Invalid regexp")); I think the indentation of the "Invalid regexp" line is off. > +} > > - if (*opname) > - { > - int fix = -1; /* -1 means ok; otherwise number of > - spaces needed. */ > +/* See symtab.h. */ > > - if (c_isalpha (*opname) || *opname == '_' || *opname == '$') > - { > - /* There should 1 space between 'operator' and 'TYPENAME'. */ > - if (opname[-1] != ' ' || opname[-2] == ' ') > - fix = 1; > - } > - else > - { > - /* There should 0 spaces between 'operator' and 'OPERATOR'. */ > - if (opname[-1] == ' ') > - fix = 0; > - } > - /* If wrong number of spaces, fix it. */ > - if (fix >= 0) > - { > - symbol_name_regexp_holder > - = string_printf ("operator%.*s%s", fix, " ", opname); > - symbol_name_regexp = symbol_name_regexp_holder.c_str (); > - } > - } > +std::optional > +global_symbol_searcher::compile_name_regex () const > +{ > + if (m_symbol_name_regexp == nullptr) > + return {}; > > - int cflags = REG_NOSUB | (case_sensitivity == case_sensitive_off > - ? REG_ICASE : 0); > - name_regex.emplace (symbol_name_regexp, cflags, > - _("Invalid regexp")); > - } > + const char *symbol_name_regexp = m_symbol_name_regexp; > + std::string symbol_name_regexp_holder; > + > + /* Make sure spacing is right for C++ operators. > + This is just a courtesy to make the matching less sensitive > + to how many spaces the user leaves between 'operator' > + and or . */ > + const char *op_end; > + const char *opname = operator_chars (symbol_name_regexp, &op_end); > > - if (m_symbol_type_regexp != NULL) > + if (*opname) > { > - int cflags = REG_NOSUB | (case_sensitivity == case_sensitive_off > - ? REG_ICASE : 0); > - type_regex.emplace (m_symbol_type_regexp, cflags, > - _("Invalid regexp")); > + /* -1 means ok; otherwise number of spaces needed. */ > + int fix = -1; > + > + if (c_isalpha (*opname) || *opname == '_' || *opname == '$') > + { > + /* There should 1 space between 'operator' and 'TYPENAME'. */ This comment has a (pre-existing) missing 'be': /* There should BE 1 space between .... */ > + if (opname[-1] != ' ' || opname[-2] == ' ') > + fix = 1; > + } > + else > + { > + /* There should 0 spaces between 'operator' and 'OPERATOR'. */ Same missing 'BE' here. With those all fixed: Approved-By: Andrew Burgess Thanks, Andrew