aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-07-05 13:02:40 -0600
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-04-15 10:34:09 +0100
commit5809fbf2e289fc524d3086da62918876b66cefa8 (patch)
tree991a62f7b453e581a709e31f7d7365da9c979d4b /gdb
parent92e4e97a9f569bf23b0f74479f32280c1f24cc6b (diff)
downloadfsf-binutils-gdb-5809fbf2e289fc524d3086da62918876b66cefa8.zip
fsf-binutils-gdb-5809fbf2e289fc524d3086da62918876b66cefa8.tar.gz
fsf-binutils-gdb-5809fbf2e289fc524d3086da62918876b66cefa8.tar.bz2
gdb: add "set startup-quietly" command
This adds a new command to change GDB to behave as though "-quiet" were always given. This new command can be added to the gdbearlyinit file to affect future GDB sessions. gdb/ChangeLog: * NEWS: Add entry. * main.c (captured_main_1): Call check_quiet_mode. * top.c (startup_quiet): New global. (check_quiet_mode): New function. (show_startup_quiet): New function. (init_main): Register new command. * top.h (check_quiet_mode): Declare. gdb/doc/ChangeLog: * gdb.texinfo (Mode Options): Mention "set startup-quietly". gdb/testsuite/ChangeLog: * gdb.base/startup-file.exp: Add more tests.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/NEWS7
-rw-r--r--gdb/doc/ChangeLog5
-rw-r--r--gdb/doc/gdb.texinfo8
-rw-r--r--gdb/main.c5
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.base/early-init-file.exp39
-rw-r--r--gdb/top.c33
-rw-r--r--gdb/top.h5
9 files changed, 117 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ee3aeb8..5385058 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2021-04-15 Tom Tromey <tom@tromey.com>
+ Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * NEWS: Add entry.
+ * main.c (captured_main_1): Call check_quiet_mode.
+ * top.c (startup_quiet): New global.
+ (check_quiet_mode): New function.
+ (show_startup_quiet): New function.
+ (init_main): Register new command.
+ * top.h (check_quiet_mode): Declare.
+
2021-04-15 Andrew Burgess <andrew.burgess@embecosm.com>
PR cli/25956
diff --git a/gdb/NEWS b/gdb/NEWS
index c5f8605..faccf40 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -94,6 +94,13 @@ memory-tag set-allocation-tag ADDRESS LENGTH TAGS
memory-tag check POINTER
Validate that POINTER's logical tag matches the allocation tag.
+set startup-quietly on|off
+show startup-quietly
+ When 'on', this causes GDB to act as if "-silent" were passed on the
+ command line. This command needs to be added to an early
+ initialization file (e.g. ~/.config/gdb/gdbearlyinit) in order to
+ affect GDB.
+
* Changed commands
break [PROBE_MODIFIER] [LOCATION] [thread THREADNUM]
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index b27bd18..32801bf 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-15 Tom Tromey <tom@tromey.com>
+ Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.texinfo (Mode Options): Mention "set startup-quietly".
+
2021-04-15 Andrew Burgess <andrew.burgess@embecosm.com>
PR cli/25956
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 4351378..d13cbda 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -1112,6 +1112,14 @@ are still loaded.
``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. Place @code{set startup-quietly on} into your early
+initialization file (@pxref{Initialization Files,,Initialization
+Files}) to have future @value{GDBN} sessions startup quietly.
+
@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 5633381..60c08fb 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1053,6 +1053,11 @@ captured_main_1 (struct captured_main_args *context)
execute_cmdargs (&cmdarg_vec, CMDARG_EARLYINIT_FILE,
CMDARG_EARLYINIT_COMMAND, &ret);
+ /* 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/ChangeLog b/gdb/testsuite/ChangeLog
index 04872d8..f58d771 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2021-04-15 Andrew Burgess <andrew.burgess@embecosm.com>
+ * gdb.base/startup-file.exp: Add more tests.
+
+2021-04-15 Andrew Burgess <andrew.burgess@embecosm.com>
+
PR cli/25956
* gdb.base/early-init-file.c: New file.
* gdb.base/early-init-file.exp: New file.
diff --git a/gdb/testsuite/gdb.base/early-init-file.exp b/gdb/testsuite/gdb.base/early-init-file.exp
index 4873e5b..9d5e84c 100644
--- a/gdb/testsuite/gdb.base/early-init-file.exp
+++ b/gdb/testsuite/gdb.base/early-init-file.exp
@@ -66,6 +66,21 @@ proc setup_home_directories { prefix content } {
return [list $home_dir $xdg_home_dir]
}
+# Restart GDB and ensure that there's no license text, we should just
+# drop straight to the prompt.
+proc check_gdb_startups_up_quietly { message } {
+ global gdb_prompt
+
+ gdb_exit
+ gdb_spawn
+
+ gdb_test_multiple "" $message {
+ -re "^$gdb_prompt $" {
+ pass $gdb_test_name
+ }
+ }
+}
+
save_vars { env(TERM) } {
# We need an ANSI-capable terminal to get the output.
setenv TERM ansi
@@ -106,4 +121,28 @@ save_vars { env(TERM) } {
check_gdb_startup_version_string none \
"check version string is unstyled using XDG_CONFIG_HOME"
}
+
+ # Create two directories to use for the quiet startup test.
+ set dirs [setup_home_directories "quiet" "set startup-quietly on"]
+ set home_dir [lindex $dirs 0]
+ set xdg_home_dir [lindex $dirs 1]
+
+ # Now arrange to use the fake home directory startup file.
+ save_vars { INTERNAL_GDBFLAGS env(HOME) env(XDG_CONFIG_HOME) } {
+ set INTERNAL_GDBFLAGS [string map {"-nx" ""} $INTERNAL_GDBFLAGS]
+
+ # Now test GDB when using the HOME directory.
+ set env(HOME) $home_dir
+ unset -nocomplain env(XDG_CONFIG_HOME)
+ check_gdb_startups_up_quietly \
+ "check GDB starts quietly using HOME"
+
+ # Now test using the XDG_CONFIG_HOME folder. We still need to
+ # have a HOME directory set otherwise GDB will issue an error
+ # about not knowing where to place the index cache.
+ set env(XDG_CONFIG_HOME) $xdg_home_dir
+ set env(HOME) $empty_home_dir
+ check_gdb_startups_up_quietly \
+ "check GDB starts quietly using XDG_CONFIG_HOME"
+ }
}
diff --git a/gdb/top.c b/gdb/top.c
index c374a8d..ecd90a1 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -2163,6 +2163,28 @@ 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;
+}
+
+/* Show whether GDB should start up in quiet mode. */
+
+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)
{
@@ -2319,6 +2341,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."), _("\
+This setting will not affect the current session. Instead this command\n\
+should be added to the .gdbearlyinit file in the users home directory to\n\
+affect future GDB sessions."),
+ NULL,
+ show_startup_quiet,
+ &setlist, &showlist);
+
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 f58bebb..9438e52 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -291,4 +291,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