From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6DzIJpMRfl8SUQAAWB0awg (envelope-from ) for ; Wed, 07 Oct 2020 15:05:55 -0400 Received: by simark.ca (Postfix, from userid 112) id 1912F1EF7B; Wed, 7 Oct 2020 15:05:54 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A2F381EF4A for ; Wed, 7 Oct 2020 15:05:44 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 476B53857039; Wed, 7 Oct 2020 19:05:44 +0000 (GMT) Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by sourceware.org (Postfix) with ESMTPS id 3024F385781A for ; Wed, 7 Oct 2020 19:05:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3024F385781A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x444.google.com with SMTP id e17so3522023wru.12 for ; Wed, 07 Oct 2020 12:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E4HQP+mKVZCybRpeW0oy4ZSVN8u/CvyXw5h0asoHu3U=; b=emryN5+oG/+MrwHE7TeWw2r8HQJNW+2E5u5YpF85lesnkDrgNNzdminyKcD8+gYAOB RiBGOZAuvwxzxX9jh4UFLUFzkF+vvN47gWRSN82FBRf6xWzz87RhFajSckXu6CRziuSP QR2sKBlduwyQAvl6UWOmDKDNV5sfAN/vrynSuXY2AQzh05w1vJ87lIGZ4EnxNnCEFihD lmLIxORbLRzQ5HNvCkWEJYk2XF/tZyqZ89QRN5PLbDpztf1Pb/heppai6w/0U/Zw29Sq HNedJKZbUYZegbFE4kpvIKv9JhJOUWgI/c0LHRbURN8exsfS/XEFxleiNkNdxc/WnzKI la4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E4HQP+mKVZCybRpeW0oy4ZSVN8u/CvyXw5h0asoHu3U=; b=AZiNlhV4OYMHuDqZKuPTb1lrQI0swEuQn2l6Ob0lDs20AFnOiPv94dyu/tuIAsfhko BwhwMT28lbo78+2OUmSEEC6Y/ljwh9I2qmkL3cmrVgEUmymHLReKkA1Te+oGYdGlXaja ZnkJcT/PwaoODWD+nfXLSilwIj/+/PKCPN9wl5Nos4n7Xggei8i7rxZ6xNxcoWpsrQLZ 5wyGyWDu2n9hm/WGllOybpWp6+xxVhU67Lj3kn4LE+RD4iGS+FXt4STc9kmGSfKmanjH Y3qyHzttCDDI2B2rj8aUyGaZAkkvAsFrGFds/ZLRRc5LqZEd40Ue3Rx3g6yHpC/7aCLk WXlQ== X-Gm-Message-State: AOAM53169K6S2wOkq5fxoXFb84cqa5hyBzOPXsHaJciHT44PvidZkGMj a5JMiP+Q8eyCgl8C4+VU9rMTWmkMYAwiCA== X-Google-Smtp-Source: ABdhPJy8d7KSemneQKXgbtfhNPiyaqK32N99HbeIaInFfnCHSVYRu6sVzxR+W0sKDTjh7l0YtFjESQ== X-Received: by 2002:adf:f212:: with SMTP id p18mr5313108wro.386.1602097538746; Wed, 07 Oct 2020 12:05:38 -0700 (PDT) Received: from localhost (host109-151-14-50.range109-151.btcentralplus.com. [109.151.14.50]) by smtp.gmail.com with ESMTPSA id 71sm3526745wrm.20.2020.10.07.12.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Oct 2020 12:05:37 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: [PATCH 7/7] Add "set startup-quietly" Date: Wed, 7 Oct 2020 21:05:11 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" From: Tom Tromey 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. 2020-07-05 Tom Tromey * 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-07-05 Tom Tromey * gdb.texinfo (Mode Options): Mention "set startup-quietly". gdb/testsuite/ChangeLog 2020-07-05 Tom Tromey * gdb.base/persist.exp: Add startup-quietly test. --- gdb/ChangeLog | 10 ++++++++ gdb/NEWS | 7 ++++++ gdb/doc/ChangeLog | 4 +++ gdb/doc/gdb.texinfo | 15 ++++++++++++ gdb/main.c | 5 ++++ gdb/testsuite/ChangeLog | 4 +++ gdb/testsuite/gdb.base/persist.exp | 1 + gdb/top.c | 39 ++++++++++++++++++++++++++++++ gdb/top.h | 5 ++++ 9 files changed, 90 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index d72d51b18b6..9b69ea70c11 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -139,6 +139,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 f11948e8c4f..1162f0d46ac 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -1114,6 +1114,21 @@ ``Quiet''. Do not print the introductory and copyright messages. These messages are also suppressed in batch mode. +@kindex set startup-quietly +@kindex show startup-quietly +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. Changing this setting will cause it to automatically +be saved in a special configuration file, which is read by +@value{GDBN} early in its startup. + +The directory in which this file appears depends on the host platform. +On most systems, the file is 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 850b6b6708d..e067158d4e3 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -1080,6 +1080,11 @@ captured_main_1 (struct captured_main_args *context) CMDARG_STARTUP_COMMAND, &ret); startup_file_read = true; + /* Recheck if we're starting up quietly after processing the startup + scripts and commands. */ + 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. */ if (set_args) diff --git a/gdb/testsuite/gdb.base/persist.exp b/gdb/testsuite/gdb.base/persist.exp index e0525786feb..3e7791f2ad0 100644 --- a/gdb/testsuite/gdb.base/persist.exp +++ b/gdb/testsuite/gdb.base/persist.exp @@ -64,4 +64,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/top.c b/gdb/top.c index e4c80c6dadb..c05b5506ef2 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -2153,6 +2153,34 @@ 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; +} + +/* 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) { @@ -2307,6 +2335,17 @@ input settings."), show_interactive_mode, &setlist, &showlist); + c = 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_default_startup_writer (c); + 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.25.4