From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EXXPBRzBvWryTCEAWB0awg (envelope-from ) for ; Wed, 30 Sep 2026 22:10:36 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=q636sO4c; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 13A311E051; Wed, 30 Sep 2026 22:10:36 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, 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 E1F8F1E033 for ; Wed, 30 Sep 2026 22:10:34 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B8F144BB58E8 for ; Thu, 1 Oct 2026 02:10:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8F144BB58E8 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=q636sO4c Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 1680F4BB58B7 for ; Thu, 1 Oct 2026 02:10:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1680F4BB58B7 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1680F4BB58B7 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790820602; cv=none; b=Ou+LYtu/LC5Ga91ZPSp1QsAQJ8rvmPqXMToHqkxsSq6onlPeDZgNSPUk78U9ewxhZGK1SGCr8qnTRFiTPYtw7J/3Dix12jheoNjNvO/VOBWBMIRoiR94QgWAIPLnnT0SNUsuCqlYUaGJ8EB3Dmhg/AZGUIFzbTt+oKQDslxFx2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790820602; c=relaxed/simple; bh=f+FnxhKaDAMo2jTLHaPj4YJ9/0w9dMyED3TnPveGgBk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YNnGU32tXPFVTMQqNHGDk2DchA/l3T08Lfc2031d7ISJ2/aSHWt6LJhnHGuDqo4r/cp6yANZfZ0l76cHw2dx047DAIK85XHvHFWYVIBCY2t5hhNDN8abFWKcbn1OpY92qNKj8MGTcb3vh7cb/9tl+U/c+mon9RkImbkP3rVo5C4= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=q636sO4c DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1680F4BB58B7 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 69129tC9167678 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Sep 2026 22:09:59 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 69129tC9167678 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1790820600; bh=yFJkm2JbXZV98JXQZ4F4UM4mRBecodpXnodJPGKDKC0=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=q636sO4cOkBe1WGk9W7lpB/7ZgesPSNU4CWPZyJvOmL8ZsxFcUdMiGLZECCmvMRV/ n71BQgp+CQZh/SfBpKxdp2bHKzx2IL7NUVsVy2r16apkBHqFnqrBfkPKCieOVekVT5 IuEsJWPPymdyGZDVfcuCLHI1TXcwIwGtWwGrxobetEJdMRv4h70SHE/P+iKrMDEDDG NzVScqAWW7EvyL+kEZEPOGkZVDPsTc5aBX7W4w+k6dDKfw1ek7frzK5GWBRhQbJkqx Pi2qO57/j47vuiVnsDTv+guzacMJ6a0058G4LoICjdO9P+U6PL1/alwIPUYifbJZ0E A6MqsMZ4olmQA== Received: by simark.ca (Postfix) id D04171E051; Wed, 30 Sep 2026 22:09:54 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 02/11] gdb: rename some preg/treg variables Date: Wed, 30 Sep 2026 22:09:19 -0400 Message-ID: <20261001020952.698419-3-simon.marchi@polymtl.ca> 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-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 1 Oct 2026 02:09:55 +0000 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 From: Simon Marchi global_symbol_searcher and some code around that use "preg" and "treg" as variable, parameter or field names. Rename to the clearer "name_regex" and "type_regex". I guess that "preg" came from the parameter name of regcomp/regexec, and treg was derived from that. Change-Id: Ic74c6acde11976d0b26757614d2b2c3093b147cf --- gdb/stack.c | 20 ++++++++-------- gdb/symtab.c | 68 +++++++++++++++++++++++++++------------------------- gdb/symtab.h | 42 +++++++++++++++++--------------- 3 files changed, 68 insertions(+), 62 deletions(-) diff --git a/gdb/stack.c b/gdb/stack.c index 7fe05bb52a81..79a67865affe 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -2289,8 +2289,8 @@ iterate_over_block_local_vars_printing struct print_variable_and_value_data { - std::optional preg; - std::optional treg; + std::optional name_regex; + std::optional type_regex; struct frame_id frame_id; int num_tabs; struct ui_file *stream; @@ -2312,11 +2312,11 @@ print_variable_and_value_data::operator() (const char *print_name, { frame_info_ptr frame; - if (preg.has_value () - && preg->exec (sym->natural_name (), 0, NULL, 0) != 0) + if (name_regex.has_value () + && name_regex->exec (sym->natural_name (), 0, NULL, 0) != 0) return; - if (treg.has_value () - && !treg_matches_sym_type_name (*treg, sym)) + if (type_regex.has_value () + && !regex_matches_sym_type_name (*type_regex, sym)) return; if (language_def (sym->language ())->symbol_printing_suppressed (sym)) return; @@ -2399,8 +2399,8 @@ print_frame_local_vars (const frame_info_ptr &frame, return; } - prepare_reg (regexp, &cb_data.preg); - prepare_reg (t_regexp, &cb_data.treg); + prepare_reg (regexp, &cb_data.name_regex); + prepare_reg (t_regexp, &cb_data.type_regex); cb_data.frame_id = get_frame_id (frame); cb_data.num_tabs = 4 * num_tabs; cb_data.stream = stream; @@ -2592,8 +2592,8 @@ print_frame_arg_vars (const frame_info_ptr &frame, return; } - prepare_reg (regexp, &cb_data.preg); - prepare_reg (t_regexp, &cb_data.treg); + prepare_reg (regexp, &cb_data.name_regex); + prepare_reg (t_regexp, &cb_data.type_regex); cb_data.frame_id = get_frame_id (frame); cb_data.num_tabs = 0; cb_data.stream = stream; diff --git a/gdb/symtab.c b/gdb/symtab.c index f80e96b48285..aae82218b5cf 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4666,18 +4666,16 @@ symbol_search::compare_search_syms (const symbol_search &sym_a, return -1; } -/* Returns true if the type_name of symbol_type of SYM matches TREG. - If SYM has no symbol_type or symbol_name, returns false. */ +/* See symtab.h. */ bool -treg_matches_sym_type_name (const compiled_regex &treg, - const struct symbol *sym) +regex_matches_sym_type_name (const compiled_regex &type_regex, + const symbol *sym) { struct type *sym_type; std::string printed_sym_type_name; - symbol_lookup_debug_printf_v ("treg_matches_sym_type_name, sym %s", - sym->natural_name ()); + symbol_lookup_debug_printf_v ("sym %s", sym->natural_name ()); sym_type = sym->type (); if (sym_type == NULL) @@ -4695,7 +4693,7 @@ treg_matches_sym_type_name (const compiled_regex &treg, if (printed_sym_type_name.empty ()) return false; - return treg.exec (printed_sym_type_name.c_str (), 0, NULL, 0) == 0; + return type_regex.exec (printed_sym_type_name.c_str (), 0, NULL, 0) == 0; } /* Return the domain search flags matching symbols of kind KIND. */ @@ -4745,7 +4743,8 @@ global_symbol_searcher::is_suitable_msymbol bool global_symbol_searcher::expand_symtabs - (objfile *objfile, const std::optional &preg) const + (objfile *objfile, + const std::optional &name_regex) const { bool found_func_msymbol_without_debug_info = false; @@ -4762,8 +4761,8 @@ global_symbol_searcher::expand_symtabs &lookup_name_info::match_any (), [&] (const char *symname) { - return (!preg.has_value () - || preg->exec (symname, 0, NULL, 0) == 0); + return (!name_regex.has_value () + || name_regex->exec (symname, 0, NULL, 0) == 0); }, NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, @@ -4794,9 +4793,9 @@ global_symbol_searcher::expand_symtabs if (is_suitable_msymbol (m_kind, msymbol)) { - if (!preg.has_value () - || preg->exec (msymbol->natural_name (), 0, - NULL, 0) == 0) + if (!name_regex.has_value () + || name_regex->exec (msymbol->natural_name (), 0, + NULL, 0) == 0) { /* An important side-effect of this lookup function is to expand the symbol table if msymbol is found, later @@ -4819,8 +4818,8 @@ global_symbol_searcher::expand_symtabs bool global_symbol_searcher::add_matching_symbols (objfile *objfile, - const std::optional &preg, - const std::optional &treg, + const std::optional &name_regex, + const std::optional &type_regex, std::set *result_set) const { domain_search_flags domain = to_search_flags (m_kind); @@ -4854,14 +4853,15 @@ global_symbol_searcher::add_matching_symbols if (!sym->matches (domain)) continue; - if (preg.has_value () && preg->exec (sym->natural_name (), 0, - nullptr, 0) != 0) + if (name_regex.has_value () + && name_regex->exec (sym->natural_name (), 0, + nullptr, 0) != 0) continue; if (((sym->domain () == VAR_DOMAIN || sym->domain () == FUNCTION_DOMAIN) - && treg.has_value () - && !treg_matches_sym_type_name (*treg, sym))) + && type_regex.has_value () + && !regex_matches_sym_type_name (*type_regex, sym))) continue; if (m_kind == symbol_search_kind::VARIABLE) @@ -4898,7 +4898,7 @@ global_symbol_searcher::add_matching_symbols bool global_symbol_searcher::add_matching_msymbols - (objfile *objfile, const std::optional &preg, + (objfile *objfile, const std::optional &name_regex, std::vector *results) const { for (minimal_symbol *msymbol : objfile->msymbols ()) @@ -4910,9 +4910,9 @@ global_symbol_searcher::add_matching_msymbols if (is_suitable_msymbol (m_kind, msymbol)) { - if (!preg.has_value () - || preg->exec (msymbol->natural_name (), 0, - NULL, 0) == 0) + if (!name_regex.has_value () + || name_regex->exec (msymbol->natural_name (), 0, + NULL, 0) == 0) { /* For functions we can do a quick check of whether the symbol might be found via find_pc_symtab. */ @@ -4943,8 +4943,8 @@ global_symbol_searcher::add_matching_msymbols std::vector global_symbol_searcher::search () const { - std::optional preg; - std::optional treg; + std::optional name_regex; + std::optional type_regex; if (m_symbol_name_regexp != NULL) { @@ -4986,16 +4986,16 @@ global_symbol_searcher::search () const int cflags = REG_NOSUB | (case_sensitivity == case_sensitive_off ? REG_ICASE : 0); - preg.emplace (symbol_name_regexp, cflags, - _("Invalid regexp")); + name_regex.emplace (symbol_name_regexp, cflags, + _("Invalid regexp")); } if (m_symbol_type_regexp != NULL) { int cflags = REG_NOSUB | (case_sensitivity == case_sensitive_off ? REG_ICASE : 0); - treg.emplace (m_symbol_type_regexp, cflags, - _("Invalid regexp")); + type_regex.emplace (m_symbol_type_regexp, cflags, + _("Invalid regexp")); } bool found_func_msymbol_without_debug_info = false; @@ -5004,13 +5004,15 @@ global_symbol_searcher::search () const { /* Expand symtabs within objfile that possibly contain matching symbols. */ - found_func_msymbol_without_debug_info |= expand_symtabs (&objfile, preg); + found_func_msymbol_without_debug_info + |= expand_symtabs (&objfile, name_regex); /* Find matching symbols within OBJFILE and add them in to the RESULT_SET set. Use a set here so that we can easily detect duplicates as we go, and can therefore track how many unique matches we have found so far. */ - if (!add_matching_symbols (&objfile, preg, treg, &result_set)) + if (!add_matching_symbols (&objfile, name_regex, type_regex, + &result_set)) break; } @@ -5025,12 +5027,12 @@ global_symbol_searcher::search () const if ((found_func_msymbol_without_debug_info || (m_filenames.empty () && m_kind == symbol_search_kind::VARIABLE)) && !m_exclude_minsyms - && !treg.has_value ()) + && !type_regex.has_value ()) { gdb_assert (m_kind == symbol_search_kind::VARIABLE || m_kind == symbol_search_kind::FUNCTION); for (objfile &objfile : current_program_space->objfiles ()) - if (!add_matching_msymbols (&objfile, preg, &result)) + if (!add_matching_msymbols (&objfile, name_regex, &result)) break; } diff --git a/gdb/symtab.h b/gdb/symtab.h index d21933759b6a..e4cfa31e25e7 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2670,31 +2670,32 @@ class global_symbol_searcher of SIZE_MAX, there is no "unlimited". */ size_t m_max_search_results = SIZE_MAX; - /* Expand symtabs in OBJFILE that match PREG, are of type M_KIND. Return - true if any msymbols were seen that we should later consider adding to - the results list. */ + /* Expand symtabs in OBJFILE that match NAME_REGEX, are of type M_KIND. + Return true if any msymbols were seen that we should later consider + adding to the results list. */ bool expand_symtabs (objfile *objfile, - const std::optional &preg) const; + const std::optional &name_regex) const; - /* Add symbols from symtabs in OBJFILE that match PREG, and TREG, and are - of type M_KIND, to the results set RESULTS_SET. Return false if we - stop adding results early due to having already found too many results - (based on M_MAX_SEARCH_RESULTS limit), otherwise return true. + /* Add symbols from symtabs in OBJFILE that match NAME_REGEX, and + TYPE_REGEX, and are of type M_KIND, to the results set RESULTS_SET. + Return false if we stop adding results early due to having already + found too many results (based on M_MAX_SEARCH_RESULTS limit), + otherwise return true. Returning true does not indicate that any results were added, just that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS. */ bool add_matching_symbols (objfile *objfile, - const std::optional &preg, - const std::optional &treg, + const std::optional &name_regex, + const std::optional &type_regex, std::set *result_set) const; - /* Add msymbols from OBJFILE that match PREG and M_KIND, to the results - vector RESULTS. Return false if we stop adding results early due to - having already found too many results (based on max search results - limit M_MAX_SEARCH_RESULTS), otherwise return true. Returning true - does not indicate that any results were added, just that we didn't - _not_ add a result due to reaching MAX_SEARCH_RESULTS. */ + /* Add msymbols from OBJFILE that match NAME_REGEX and M_KIND, to the + results vector RESULTS. Return false if we stop adding results early + due to having already found too many results (based on max search + results limit M_MAX_SEARCH_RESULTS), otherwise return true. Returning + true does not indicate that any results were added, just that we + didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS. */ bool add_matching_msymbols (objfile *objfile, - const std::optional &preg, + const std::optional &name_regex, std::vector *results) const; /* Return true if MSYMBOL is of type KIND. */ @@ -2723,8 +2724,11 @@ extern std::vector search_module_symbols extern std::string symbol_to_info_string (struct symbol *sym, int block); -extern bool treg_matches_sym_type_name (const compiled_regex &treg, - const struct symbol *sym); +/* Returns true if the SYM's type name matches TYPE_REGEX. + If SYM has no type name, returns false. */ + +extern bool regex_matches_sym_type_name (const compiled_regex &type_regex, + const symbol *sym); /* The name of the ``main'' function. */ extern const char *main_name (); -- 2.55.0