From patchwork Tue Nov 21 03:53:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80394 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 69126385840E for ; Tue, 21 Nov 2023 03:53:53 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id A1E303858D3C for ; Tue, 21 Nov 2023 03:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1E303858D3C 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 A1E303858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538802; cv=none; b=V9ZV+AgPRUsvAIfl3HlSeFQpMpjxPgmSkAVUyjN49yvHhP5dlyfiren3iC2K/XjhDxPzmaCyHiKO6A2pBba/YqK0k6DP6xXVMoKTGjpb2G1S9HlBGLlMavHYxXmCTbwUZB6A1tvtyizaeAwswoUBEEltHOnaAr4VXXT0FcsKq3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538802; c=relaxed/simple; bh=yz4bqxH6115JZxyYFGXVhBvZatjTgzmlTXwyHRlW0KE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=jRth2rSsn8oEq+eZN+hF95g1uveUBCxQlvRxlrscQ3bJQM09p53X8qQM0RF9ksN/KQCK6gZ7ZkpfBXNSffIYQJ2ZCU++mAy+9lPAlZ28qwEZpcpo/idvlulZEWN5TwJg9cdNDQK8YWuLjCLLN4nJGagyFdHOjyVXvA44bl3KpvQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6006a.ext.cloudfilter.net ([10.0.30.182]) by cmsmtp with ESMTPS id 520arn4qY6nOZ5HpArzrP7; Tue, 21 Nov 2023 03:53:20 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp9rEg3nGKIc5Hp9rxrMv; Tue, 21 Nov 2023 03:53:19 +0000 X-Authority-Analysis: v=2.4 cv=E+beGIRl c=1 sm=1 tr=0 ts=655c29af a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=BNY50KLci1gA: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=52cZKN//gJYibADxzMb4fH4/04dNy/VaWMzKZF3P4pY=; b=YOLVirEN2A5/B3UTsIv64lJX+1 0sFqnoLV62YuxPIkghGYy01k9Y78DlzoKVIZcR1upP1IEh1/NK0n2FTwcFOab/In9Ds06+U79o0+f iUrpL7yiQOavdcNxv/02fbEhQ; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:47856 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 1r5Hp9-0040be-0w for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:19 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:38 -0700 Subject: [PATCH 07/29] Simplify symbol_to_info_string MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-7-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@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.77.73 X-Source-L: No X-Exim-ID: 1r5Hp9-0040be-0w X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net ([192.168.0.21]) [97.122.77.73]:47856 X-Source-Auth: tom+tromey.com X-Email-Count: 8 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfNe/jyH1QdgT8ORa67r7bxITDv1C+cJBIQbWujccnzFBf759BRMze/ONiIrzZCzWiZe6mJA8ITQmw5O/a3cpB5CMkYmpt7wl9Wo/JCL/sfFcwsRuLMad jqD0j5vvf8bZd7Kc+4M+Zy0Zf0B2sgpD6yKRL8B6jaP+rWgCQP4z9qy82luNeBm75rfuhafvknRB2LO7UbehD2MRyJZEltnKiFI= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, 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 d26378e8310..7492d007fba 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 5ec56f4f2af..6abebcd929c 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4957,19 +4957,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; @@ -4988,9 +4988,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; @@ -5005,23 +5003,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 (); @@ -5043,7 +5039,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 ()); } @@ -5139,10 +5135,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 ()); } @@ -5378,7 +5371,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 { @@ -6739,8 +6732,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 21c84cbe006..71d37e84a43 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2639,11 +2639,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);