From patchwork Sun Jan 29 16:21:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63878 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 CFFC2385B511 for ; Sun, 29 Jan 2023 16:21:49 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id C70773858CDA for ; Sun, 29 Jan 2023 16:21:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C70773858CDA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id D09101004B50E for ; Sun, 29 Jan 2023 16:21:22 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id MAQkp4x3jx5dfMAQkpmIRU; Sun, 29 Jan 2023 16:21:22 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=R+nGpfdX c=1 sm=1 tr=0 ts=63d69d02 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=iAAtyWHyVjSguO2617sA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=8zxLhGBft9VUGDiFaMR6ms9zxln8p8ls6P6ItlBDcDc=; b=DzqPt1ynjJ7JO+KayBHC5edsbc J8uXttoaq7asTJ1BoGjFeps68J6U1rBHQO9AB0evTY9U1MD4TY0aP1lIkGJOXDJux5aqqjLA3Wsny lFAZXavO4tcQGykPAX84F6VPs; Received: from 75-166-146-144.hlrn.qwest.net ([75.166.146.144]:59376 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pMAQk-001fCo-HS; Sun, 29 Jan 2023 09:21:22 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/5] Move show_user_1 to cli-cmds.c Date: Sun, 29 Jan 2023 09:21:02 -0700 Message-Id: <20230129162105.526266-3-tom@tromey.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129162105.526266-1-tom@tromey.com> References: <20230129162105.526266-1-tom@tromey.com> MIME-Version: 1.0 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: 75.166.146.144 X-Source-L: No X-Exim-ID: 1pMAQk-001fCo-HS X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-146-144.hlrn.qwest.net (localhost.localdomain) [75.166.146.144]:59376 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.5 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 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.29 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 Sender: "Gdb-patches" show_user_1 is only called from cli-cmds.c, so move it there and make it static. --- gdb/cli/cli-cmds.c | 35 +++++++++++++++++++++++++++++++++++ gdb/cli/cli-script.c | 35 ----------------------------------- gdb/cli/cli-script.h | 5 ----- 3 files changed, 35 insertions(+), 40 deletions(-) diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 6c0d780face..61f890a7dae 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1643,6 +1643,41 @@ make_command (const char *arg, int from_tty) } } +/* Print the definition of user command C to STREAM. Or, if C is a + prefix command, show the definitions of all user commands under C + (recursively). PREFIX and NAME combined are the name of the + current command. */ +static void +show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name, + struct ui_file *stream) +{ + if (cli_user_command_p (c)) + { + struct command_line *cmdlines = c->user_commands.get (); + + gdb_printf (stream, "User %scommand \"", + c->is_prefix () ? "prefix" : ""); + fprintf_styled (stream, title_style.style (), "%s%s", + prefix, name); + gdb_printf (stream, "\":\n"); + if (cmdlines) + { + print_command_lines (current_uiout, cmdlines, 1); + gdb_puts ("\n", stream); + } + } + + if (c->is_prefix ()) + { + const std::string prefixname = c->prefixname (); + + for (c = *c->subcommands; c != NULL; c = c->next) + if (c->theclass == class_user || c->is_prefix ()) + show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout); + } + +} + static void show_user (const char *args, int from_tty) { diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 92005ba8c38..0bd5803dc31 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -1651,41 +1651,6 @@ script_from_file (FILE *stream, const char *file) } } -/* Print the definition of user command C to STREAM. Or, if C is a - prefix command, show the definitions of all user commands under C - (recursively). PREFIX and NAME combined are the name of the - current command. */ -void -show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name, - struct ui_file *stream) -{ - if (cli_user_command_p (c)) - { - struct command_line *cmdlines = c->user_commands.get (); - - gdb_printf (stream, "User %scommand \"", - c->is_prefix () ? "prefix" : ""); - fprintf_styled (stream, title_style.style (), "%s%s", - prefix, name); - gdb_printf (stream, "\":\n"); - if (cmdlines) - { - print_command_lines (current_uiout, cmdlines, 1); - gdb_puts ("\n", stream); - } - } - - if (c->is_prefix ()) - { - const std::string prefixname = c->prefixname (); - - for (c = *c->subcommands; c != NULL; c = c->next) - if (c->theclass == class_user || c->is_prefix ()) - show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout); - } - -} - void _initialize_cli_script (); void _initialize_cli_script () diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h index da7307bbf8d..67ef0bb672e 100644 --- a/gdb/cli/cli-script.h +++ b/gdb/cli/cli-script.h @@ -130,11 +130,6 @@ extern counted_command_line read_command_lines_1 extern void script_from_file (FILE *stream, const char *file); -extern void show_user_1 (struct cmd_list_element *c, - const char *prefix, - const char *name, - struct ui_file *stream); - /* Execute the commands in CMDLINES. */ extern void execute_control_commands (struct command_line *cmdlines,