From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id E/fUEHDlD2CUIgAAWB0awg (envelope-from ) for ; Tue, 26 Jan 2021 04:48:32 -0500 Received: by simark.ca (Postfix, from userid 112) id 22C351EF82; Tue, 26 Jan 2021 04:48:32 -0500 (EST) 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=ham 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 1DDBA1E945 for ; Tue, 26 Jan 2021 04:48:30 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C93E03AA9C49; Tue, 26 Jan 2021 09:48:29 +0000 (GMT) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 641A63836C54 for ; Tue, 26 Jan 2021 09:48:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 641A63836C54 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-x431.google.com with SMTP id a9so15733660wrt.5 for ; Tue, 26 Jan 2021 01:48:25 -0800 (PST) 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=BFS7mqAPky/U1s3hNPSFSxodqHUI8ppNAcLOJIDgDsw=; b=TsGAEIOSrJMWYlwmbX6YY+vV9ZkrIvEvSoKXGBgGuZTmnXBZFPEWxmmvKfNRLwF9m6 hiij7+0QWmzKj1y2EMEIuu6c/gTGFMpO5a0af10VDPQ2jKVPI8H+KjVMRp64nn36MDcS 8ntouv2/EFT6usBTvP3E84nq0brMclHJ7CE+Mtb3xZz8C4YG74Ah71i0kHAgmfxPDix4 uiVBnjwkoY20IUjH4seqMb71mJP2M+MFg7SD3j4I56OUbNgIW4X/VwEz1MP7/YUdcLyv Lh/FivK6HJyf81yUG1mk0ZjvOeDMyu2xg+5Msu+h/ZMNyvOAEZccONCr+0H8wFNUCXuS KNYA== 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=BFS7mqAPky/U1s3hNPSFSxodqHUI8ppNAcLOJIDgDsw=; b=WhStV4nNc+xRRW8N8i4GGAd0RqLwZi2+1EJLQTRVpvO71TQDS15hl1dFZdWJ9sTnqF sD9hPIGt+RT7PFFdo9Zq036TAVXBaAubwmugXvcFhM+0Mfxy0UPWT+8NG+IcWPSOdfl6 5itwTsdQwRrX0/4BmK+j5v+wiXRF1Q805ISWoFW5Zkt9nkKJWvI58gXoaZdmjWkD7Tjw QOlrgl27fjwXlUF4agDFXh8Ahto1tPBUnCkGOC/6HK2w2VHWFZz+ZrGTvZ7e4ZrzMiG/ wqJU1ejy3eFT5MWtMz50NY/6Wt/ARK9SHdZp7Zy+kbmf2pUp1ppgIM0mEzuXZrUBaHaC hPlQ== X-Gm-Message-State: AOAM530+IvUEhD5pjLGItPiBoihA8IQHcVTYOeroE6Jqrhmd21Bc/gce oZ2QMDW0TgzPcrcyUeiJ8aVGgJve6u454g== X-Google-Smtp-Source: ABdhPJxJqfAClmtx/53TU3pJcR5Vx7cYi1XsonsBp/sQ195lQDwa/PDqDfTqOf/DPPD8kEJ7hgNPbg== X-Received: by 2002:adf:8b41:: with SMTP id v1mr5064076wra.282.1611654504308; Tue, 26 Jan 2021 01:48:24 -0800 (PST) Received: from localhost (host86-166-129-180.range86-166.btcentralplus.com. [86.166.129.180]) by smtp.gmail.com with ESMTPSA id g12sm2488116wmh.14.2021.01.26.01.48.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 01:48:23 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: [PATCHv2 3/3] gdb: add "set startup-quietly" command Date: Tue, 26 Jan 2021 09:48:13 +0000 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 new command can be added to the gdbstartup 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. --- gdb/ChangeLog | 11 +++++++ gdb/NEWS | 6 ++++ gdb/doc/ChangeLog | 5 ++++ gdb/doc/gdb.texinfo | 9 ++++++ gdb/main.c | 5 ++++ gdb/testsuite/ChangeLog | 4 +++ gdb/testsuite/gdb.base/startup-file.exp | 39 +++++++++++++++++++++++++ gdb/top.c | 33 +++++++++++++++++++++ gdb/top.h | 5 ++++ 9 files changed, 117 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index 368cab5fec6..2bd2ec7e975 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -92,6 +92,12 @@ set style version background COLOR set style version intensity VALUE Control the styling of GDB's version number text. +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 command needs to be added to a + gdbstartup file in order to affect GDB. + *** Changes in GDB 10 * There are new feature names for ARC targets: "org.gnu.gdb.arc.core" diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 09f64302ba6..224cc9ae85a 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -1114,6 +1114,15 @@ ``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 have no affect on the +current @value{GDBN} session. Add @code{set startup-quietly on} to +the startup command file (@pxref{Initialization Files,,Initialization +Files}) to affect future @value{GDBN} sessions. + @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 fe1ca27c255..1f863d191bc 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -1058,6 +1058,11 @@ captured_main_1 (struct captured_main_args *context) execute_cmdargs (&cmdarg_vec, CMDARG_STARTUP_FILE, CMDARG_STARTUP_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/gdb.base/startup-file.exp b/gdb/testsuite/gdb.base/startup-file.exp index e871a193ffa..d3f46c7e4c4 100644 --- a/gdb/testsuite/gdb.base/startup-file.exp +++ b/gdb/testsuite/gdb.base/startup-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,5 +121,29 @@ 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 08c47422514..5d3c951b8a2 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -2146,6 +2146,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) { @@ -2300,6 +2322,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 .gdbstartup 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 f58bebbb385..9438e52331b 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 -- 2.25.4