From patchwork Thu Jan 18 20:32:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84370 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F326138582B7 for ; Thu, 18 Jan 2024 20:33:51 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id C47A43858C31 for ; Thu, 18 Jan 2024 20:32:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C47A43858C31 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C47A43858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609936; cv=none; b=i7XQ4VuIl5TORwy0WDZZJg7nj12dtwL+SimyHsO3HYsdkLV3V+NegukiQkwOm2QKmyV+iXRxO+rNvZ/jk5WnVW+fXKp66tQAnXWzaTrV6DwCGa1tS3mo9Vpo4yI7VF83syUkpPimpf+nOQdjLNCDeXtzfMdGEQyOKeovuvuhDKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609936; c=relaxed/simple; bh=+xxWby9p7bL5LLVlFfyhH3Eh9HWGG7wDQk0SUZvumw4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=sReCqaqsNm9moJhuR1XFBEsqv1h6QYCMpDFaJIMmUjg1HZjnWpaQtdCwMOxbGch417lzqCTsOJWNhNhUH7jaFC87+o5E6f+KsOsCdQaV9V5k/17t3Z3L9HxkY7r9JiB1PqWx2c0Yz9BB6r6ehwPoW0Lq3upqUo+cQuCzdPtamTk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id QWJqrgbIkoMN9QZ3ZrOoA4; Thu, 18 Jan 2024 20:32:10 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3ZrjZHufPByQZ3Zrj6Ig; Thu, 18 Jan 2024 20:32:09 +0000 X-Authority-Analysis: v=2.4 cv=T+af8tGQ c=1 sm=1 tr=0 ts=65a98ac9 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=cCc6LzOX12iO7udG6-IA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=NyIYbjj8O+kyAh64YeTveIs0NMjMOfNq1m05UkSoYnc=; b=TiK5L9yN/NF0wNJdtMhw4KJgIQ Fy5b+O8ac9TvL4fxYTxHcWMmn8KtNWcrzHxgOT62GEwlJb+it+VDcXY8CwuCarAuHq1THGOxhsgRl nVhO87cPgxemiH4igNCqQs/lM; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rQZ3Y-002DCj-38 for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:09 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:06 -0700 Subject: [PATCH v2 08/30] Simplify symbol_to_info_string MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-8-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.68.157 X-Source-L: No X-Exim-ID: 1rQZ3Y-002DCj-38 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 10 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfKA14jNDwuoETeLVcuFg7W5gFo5SdwYdwfVTPsgA3k5RwbjlTNe3EpqYkKujOd9FOgWCcij2KlRyv3XPYqxUWW8TbonZO4VSjV8Dn55+LBLprPjZT4N0 xdKqiLvdo2cxWq32AJaPAn300GBc01ARTIpBcp4LN/VkbTVoqAMi2jDKafsUAkY8Ww4Q5+/JDw4Gbhu+QDlakvCto+N0q3NEE+0= X-Spam-Status: No, score=-3022.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+patchwork=sourceware.org@sourceware.org Thi simplifies symbol_to_info_string, removing the 'kind' parameter and instead having it use the symbol's domain. --- gdb/mi/mi-symbol-cmds.c | 2 +- gdb/symtab.c | 44 ++++++++++++++++++-------------------------- gdb/symtab.h | 6 ++---- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index d3ec16fcb21..758f5974706 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -87,7 +87,7 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind, type_print (sym->type (), "", &tmp_stream, -1); uiout->field_string ("type", tmp_stream.string ()); - std::string str = symbol_to_info_string (sym, block, kind); + std::string str = symbol_to_info_string (sym, block); uiout->field_string ("description", str); } } diff --git a/gdb/symtab.c b/gdb/symtab.c index 7c0a69108d4..b408941f998 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5054,19 +5054,19 @@ global_symbol_searcher::search () const /* See symtab.h. */ std::string -symbol_to_info_string (struct symbol *sym, int block, - enum search_domain kind) +symbol_to_info_string (struct symbol *sym, int block) { std::string str; gdb_assert (block == GLOBAL_BLOCK || block == STATIC_BLOCK); - if (kind != TYPES_DOMAIN && block == STATIC_BLOCK) + if (block == STATIC_BLOCK + && sym->domain () == VAR_DOMAIN + && sym->aclass () != LOC_TYPEDEF) str += "static "; /* Typedef that is not a C++ class. */ - if (kind == TYPES_DOMAIN - && sym->domain () != STRUCT_DOMAIN) + if (sym->domain () == VAR_DOMAIN && sym->aclass () == LOC_TYPEDEF) { string_file tmp_stream; @@ -5085,9 +5085,7 @@ symbol_to_info_string (struct symbol *sym, int block, str += tmp_stream.string (); } /* variable, func, or typedef-that-is-c++-class. */ - else if (kind < TYPES_DOMAIN - || (kind == TYPES_DOMAIN - && sym->domain () == STRUCT_DOMAIN)) + else if (sym->domain () == VAR_DOMAIN || sym->domain () == STRUCT_DOMAIN) { string_file tmp_stream; @@ -5102,23 +5100,21 @@ symbol_to_info_string (struct symbol *sym, int block, /* Printing of modules is currently done here, maybe at some future point we might want a language specific method to print the module symbol so that we can customise the output more. */ - else if (kind == MODULES_DOMAIN) + else if (sym->domain () == MODULE_DOMAIN) str += sym->print_name (); return str; } -/* Helper function for symbol info commands, for example 'info functions', - 'info variables', etc. KIND is the kind of symbol we searched for, and - BLOCK is the type of block the symbols was found in, either GLOBAL_BLOCK - or STATIC_BLOCK. SYM is the symbol we found. If LAST is not NULL, - print file and line number information for the symbol as well. Skip - printing the filename if it matches LAST. */ +/* Helper function for symbol info commands, for example 'info + functions', 'info variables', etc. BLOCK is the type of block the + symbols was found in, either GLOBAL_BLOCK or STATIC_BLOCK. SYM is + the symbol we found. If LAST is not NULL, print file and line + number information for the symbol as well. Skip printing the + filename if it matches LAST. */ static void -print_symbol_info (enum search_domain kind, - struct symbol *sym, - int block, const char *last) +print_symbol_info (struct symbol *sym, int block, const char *last) { scoped_switch_to_sym_language_if_auto l (sym); struct symtab *s = sym->symtab (); @@ -5140,7 +5136,7 @@ print_symbol_info (enum search_domain kind, gdb_puts ("\t"); } - std::string str = symbol_to_info_string (sym, block, kind); + std::string str = symbol_to_info_string (sym, block); gdb_printf ("%s\n", str.c_str ()); } @@ -5236,10 +5232,7 @@ symtab_symbol_info (bool quiet, bool exclude_minsyms, } else { - print_symbol_info (kind, - p.symbol, - p.block, - last_filename); + print_symbol_info (p.symbol, p.block, last_filename); last_filename = symtab_to_filename_for_display (p.symbol->symtab ()); } @@ -5475,7 +5468,7 @@ rbreak_command (const char *regexp, int from_tty) string = string_printf ("%s:'%s'", fullname, p.symbol->linkage_name ()); break_command (&string[0], from_tty); - print_symbol_info (FUNCTIONS_DOMAIN, p.symbol, p.block, NULL); + print_symbol_info (p.symbol, p.block, nullptr); } else { @@ -6838,8 +6831,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, last_filename = ""; } - print_symbol_info (FUNCTIONS_DOMAIN, q.symbol, q.block, - last_filename); + print_symbol_info (q.symbol, q.block, last_filename); last_filename = symtab_to_filename_for_display (q.symbol->symtab ()); } diff --git a/gdb/symtab.h b/gdb/symtab.h index 3f2d98add1e..0a5f2633fe8 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2664,11 +2664,9 @@ extern std::vector search_module_symbols /* Convert a global or static symbol SYM (based on BLOCK, which should be either GLOBAL_BLOCK or STATIC_BLOCK) into a string for use in 'info' - type commands (e.g. 'info variables', 'info functions', etc). KIND is - the type of symbol that was searched for which gave us SYM. */ + type commands (e.g. 'info variables', 'info functions', etc). */ -extern std::string symbol_to_info_string (struct symbol *sym, int block, - enum search_domain kind); +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);