From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 7/7] Add "set startup-quietly"
Date: Tue, 23 Jun 2020 07:20:06 -0600 [thread overview]
Message-ID: <20200623132006.15863-8-tom@tromey.com> (raw)
In-Reply-To: <20200623132006.15863-1-tom@tromey.com>
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 <tom@tromey.com>
* 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 <tom@tromey.com>
* gdb.texinfo (Mode Options): Mention "set startup-quietly".
gdb/testsuite/ChangeLog
2020-06-22 Tom Tromey <tom@tromey.com>
* 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
next prev parent reply other threads:[~2020-06-23 13:20 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 13:19 [PATCH v2 0/7] Some user-friendliness changes Tom Tromey
2020-06-23 13:20 ` [PATCH v2 1/7] Introduce read_entire_file Tom Tromey
2020-07-06 13:47 ` Simon Marchi
2020-10-02 10:24 ` Andrew Burgess
2020-06-23 13:20 ` [PATCH v2 2/7] Add "help news" Tom Tromey
2020-06-23 14:35 ` Eli Zaretskii
2020-06-23 18:18 ` Christian Biesinger
2020-07-05 15:59 ` Tom Tromey
2020-07-06 14:14 ` Simon Marchi
2020-07-11 15:30 ` Tom Tromey
2020-07-06 14:06 ` Simon Marchi
2020-07-06 14:18 ` Simon Marchi
2020-07-11 15:56 ` Tom Tromey
2020-07-06 14:22 ` Simon Marchi
2020-07-11 15:31 ` Tom Tromey
2020-06-23 13:20 ` [PATCH v2 3/7] Add "tips" file to gdb Tom Tromey
2020-06-23 14:36 ` Eli Zaretskii
2020-07-06 14:27 ` Simon Marchi
2020-06-23 13:20 ` [PATCH v2 4/7] Add get_standard_config_dir function Tom Tromey
2020-06-23 13:20 ` [PATCH v2 5/7] Add early startup command file Tom Tromey
2020-07-05 18:51 ` Tom Tromey
2020-08-26 15:47 ` Andrew Burgess
2020-08-27 16:32 ` Andrew Burgess
2020-06-23 13:20 ` [PATCH v2 6/7] Let the user control the startup style Tom Tromey
2020-06-23 14:41 ` Eli Zaretskii
2020-07-05 18:50 ` Tom Tromey
2020-07-05 19:02 ` Eli Zaretskii
2020-06-23 13:20 ` Tom Tromey [this message]
2020-06-23 14:45 ` [PATCH v2 7/7] Add "set startup-quietly" Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200623132006.15863-8-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox