From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway36.websitewelcome.com (gateway36.websitewelcome.com [192.185.201.2]) by sourceware.org (Postfix) with ESMTPS id 0B18E395C85D for ; Tue, 23 Jun 2020 13:20:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0B18E395C85D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 0CB204015BFE9 for ; Tue, 23 Jun 2020 07:41:35 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id niqQj9R9IBb5dniqQjRCR7; Tue, 23 Jun 2020 08:20:10 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=75zMJhOBC4B/7/jODOF5VHC7EVFtL9L81RmFAZFE2RQ=; b=QIvEuKUmwFllGOGMM1FBej5z0+ L1hqNo/csc0kEXKlKkHbwv54ctu0ZtdQ+A7LQDTzozI3mdV2v/rrtJA6MfBS6wldfiP7yjryoyD0a 5KKyKHy02kwCZu6Kc+lvbknHh; Received: from 174-16-104-48.hlrn.qwest.net ([174.16.104.48]:45100 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1jniqQ-002fzZ-Cr; Tue, 23 Jun 2020 07:20:10 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 7/7] Add "set startup-quietly" Date: Tue, 23 Jun 2020 07:20:06 -0600 Message-Id: <20200623132006.15863-8-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200623132006.15863-1-tom@tromey.com> References: <20200623132006.15863-1-tom@tromey.com> 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: 174.16.104.48 X-Source-L: No X-Exim-ID: 1jniqQ-002fzZ-Cr X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-104-48.hlrn.qwest.net (bapiya.Home) [174.16.104.48]:45100 X-Source-Auth: tom+tromey.com X-Email-Count: 8 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3037.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , X-List-Received-Date: Tue, 23 Jun 2020 13:20:25 -0000 This adds a new command to change gdb to behave as though "-quiet" were always given. This is done by using the early startup file infrastructure. gdb/ChangeLog 2020-06-22 Tom Tromey * tips: Add a tip. * NEWS: Add entry. * top.h (check_quiet_mode): Declare. * top.c (startup_quiet): New global. (check_quiet_mode, set_startup_quiet, show_startup_quiet) (write_startup_quietly): New functions. (init_main): Register new command and callback. * main.c (captured_main_1): Call check_quiet_mode. gdb/doc/ChangeLog 2020-03-28 Tom Tromey * gdb.texinfo (Mode Options): Mention "set startup-quietly". gdb/testsuite/ChangeLog 2020-06-22 Tom Tromey * gdb.base/persist.exp: Add startup-quietly test. --- gdb/ChangeLog | 11 +++++++ gdb/NEWS | 7 +++++ gdb/doc/ChangeLog | 4 +++ gdb/doc/gdb.texinfo | 13 ++++++++ gdb/main.c | 7 ++++- gdb/testsuite/ChangeLog | 4 +++ gdb/testsuite/gdb.base/persist.exp | 1 + gdb/tips | 3 ++ gdb/top.c | 48 ++++++++++++++++++++++++++++++ gdb/top.h | 5 ++++ 10 files changed, 102 insertions(+), 1 deletion(-) diff --git a/gdb/NEWS b/gdb/NEWS index 8f474c51bf4..31cfdc95ae1 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -87,6 +87,13 @@ set style startup intensity VALUE a special configuration file, so that it can be read during startup and applied. +set startup-quietly on|off +show startup-quietly + When enabled, this causes GDB to act as if "-silent" were always + passed on the command line. This saves the setting into a special + configuration file, so that it can be read during startup and + applied. + tui new-layout NAME WINDOW WEIGHT [WINDOW WEIGHT]... Define a new TUI layout, specifying its name and the windows that will be displayed. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 7c3fe7d38a2..ba44369c10e 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -1124,6 +1124,19 @@ in your home directory. ``Quiet''. Do not print the introductory and copyright messages. These messages are also suppressed in batch mode. +This can also be enabled using @code{set startup-quietly on}. The +default is @code{off}. Use @code{show startup-quietly} to see the +current setting. Unlike most settings in @value{GDBN}, this one is +automatically saved by creating a special file in a configuration +directory. + +The default value for this directory depends on the host platform. On +most systems, the index is cached in the @file{gdb} subdirectory of +the directory pointed to by the @env{XDG_CONFIG_HOME} environment +variable, if it is defined, else in the @file{.config/gdb} subdirectory +of your home directory. However, on some systems, the default may +differ according to local convention. + @item -batch @cindex @code{--batch} Run in batch mode. Exit with status @code{0} after processing all the diff --git a/gdb/main.c b/gdb/main.c index bd1f6d6b2c5..34752d27737 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -936,7 +936,12 @@ captured_main_1 (struct captured_main_args *context) /* Set the startup style. */ if (!inhibit_gdbinit && !inhibit_home_gdbinit) - read_startup_file (); + { + read_startup_file (); + + if (!quiet) + quiet = check_quiet_mode (); + } /* Now that gdb_init has created the initial inferior, we're in position to set args for that inferior. */ diff --git a/gdb/testsuite/gdb.base/persist.exp b/gdb/testsuite/gdb.base/persist.exp index 76a55d558c3..adffa488aa5 100644 --- a/gdb/testsuite/gdb.base/persist.exp +++ b/gdb/testsuite/gdb.base/persist.exp @@ -61,4 +61,5 @@ save_vars { env(XDG_CONFIG_HOME) } { set contents [require_changed "set style startup foreground green" $filename $contents] set contents [require_changed "set style startup background green" $filename $contents] set contents [require_changed "set style startup intensity dim" $filename $contents] + set contents [require_changed "set startup-quietly on" $filename $contents] } diff --git a/gdb/tips b/gdb/tips index a9c89747aa4..a83dc2c9ddc 100644 --- a/gdb/tips +++ b/gdb/tips @@ -10,3 +10,6 @@ Type "show configuration" for configuration details. % You can use the "set style startup" family of commands to change the style used for tips. +% +You can use "set startup-quietly on" to have GDB always start up +silently. diff --git a/gdb/top.c b/gdb/top.c index e86ce4020f3..910b9d0dfcb 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -2196,6 +2196,43 @@ set_history_filename (const char *args, } } +/* Whether we're in quiet startup mode. */ + +static bool startup_quiet; + +/* See top.h. */ + +bool +check_quiet_mode () +{ + return startup_quiet; +} + +/* Write "set startup-quietly" to the file. */ + +static void +write_startup_quietly (ui_file *outfile) +{ + fprintf_unfiltered (outfile, "set startup-quietly %s\n", + startup_quiet ? "on" : "off"); +} + +/* Set the startup-quiet flag. */ + +static void +set_startup_quiet (const char *args, int from_tty, struct cmd_list_element *c) +{ + write_startup_file (); +} + +static void +show_startup_quiet (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("Whether to start up quietly is %s.\n"), + value); +} + static void init_gdb_version_vars (void) { @@ -2350,6 +2387,17 @@ input settings."), show_interactive_mode, &setlist, &showlist); + add_setshow_boolean_cmd ("startup-quietly", class_support, + &startup_quiet, _("\ +Set whether GDB should start up quietly."), _("\ +Show whether GDB should start up quietly."), NULL, + set_startup_quiet, + show_startup_quiet, + &setlist, &showlist); + /* Arrange to write "set startup-quietly" to the early startup + file. */ + add_startup_writer (write_startup_quietly); + c = add_cmd ("new-ui", class_support, new_ui_command, _("\ Create a new UI.\n\ Usage: new-ui INTERPRETER TTY\n\ diff --git a/gdb/top.h b/gdb/top.h index fd992977155..85e178c527a 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -298,4 +298,9 @@ extern char *handle_line_of_input (struct buffer *cmd_line_buffer, const char *rl, int repeat, const char *annotation_suffix); +/* Call at startup to see if the user has requested that gdb start up + quietly. */ + +extern bool check_quiet_mode (); + #endif -- 2.17.2