public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 3/3] gdb: add the 'set/show suppress-notification-cli' command
Date: Tue, 18 Jan 2022 10:41:59 +0000	[thread overview]
Message-ID: <20220118104159.GB622389@redhat.com> (raw)
In-Reply-To: <3a4bd599cabeb95b5f4d18b5d0fb0c24d4bd4266.1638370938.git.tankut.baris.aktemur@intel.com>

* Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> [2021-12-01 16:08:29 +0100]:

> GDB already has a flag to suppress printing notification events, such
> as thread and inferior context switches, on the CLI.  This is used
> internally when executing commands.  Make the flag available to the
> user via a new command.  This is expected to be useful in scripts.

I agree with Tom that this should not be a maint command if you expect
users to be using it.  I also agree it needs a doc entry.

What I would add, is that I think you need to expand on
"notifications" is more places with an explicit list of exactly what
is being suppressed.  Even for someone familiar with GDB it's not
clear what this covers, and for a user, trying to achieve some result
it's not obvious what the flag is expected to do.

Thanks,
Andrew



> ---
>  gdb/NEWS                                      |  5 +++
>  gdb/cli/cli-cmds.c                            | 35 +++++++++++++++++++
>  .../gdb.base/cli-suppress-notification.c      | 22 ++++++++++++
>  .../gdb.base/cli-suppress-notification.exp    | 33 +++++++++++++++++
>  4 files changed, 95 insertions(+)
>  create mode 100644 gdb/testsuite/gdb.base/cli-suppress-notification.c
>  create mode 100644 gdb/testsuite/gdb.base/cli-suppress-notification.exp
> 
> diff --git a/gdb/NEWS b/gdb/NEWS
> index eeca1d39b10..76c9738bf03 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -39,6 +39,11 @@ set logging enabled on|off
>  show logging enabled
>    These commands set or show whether logging is enabled or disabled.
>  
> +maint set suppress-notification-cli (on|off)
> +maint show suppress-notification-cli
> +  This controls whether printing the notification events is suppressed
> +  for CLI.
> +
>  * Changed commands
>  
>  maint packet
> diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
> index 3fe47940076..5ad0a29052c 100644
> --- a/gdb/cli/cli-cmds.c
> +++ b/gdb/cli/cli-cmds.c
> @@ -192,6 +192,11 @@ static const char *const script_ext_enums[] = {
>  
>  static const char *script_ext_mode = script_ext_soft;
>  \f
> +
> +/* User-controllable flag to suppress event notification on CLI.  */
> +
> +static bool user_wants_cli_suppress_notification = false;
> +
>  /* Utility used everywhere when at least one argument is needed and
>     none is supplied.  */
>  
> @@ -2123,6 +2128,24 @@ show_max_user_call_depth (struct ui_file *file, int from_tty,
>  		    value);
>  }
>  
> +static void
> +maint_show_suppress_notification_cli (ui_file *file, int from_tty,
> +				      cmd_list_element *c, const char *value)
> +{
> +  fprintf_filtered (file, _("Suppression of printing CLI notification events "
> +			    "is %s.\n"), value);
> +}
> +
> +static void
> +maint_set_suppress_notification_cli (const char *args, int from_tty,
> +				     cmd_list_element *c)
> +{
> +  cli_suppress_notification.user_selected_context
> +    = user_wants_cli_suppress_notification;
> +  cli_suppress_notification.normal_stop
> +    = user_wants_cli_suppress_notification;
> +}
> +
>  /* Returns the cmd_list_element in SHOWLIST corresponding to the first
>     argument of ARGV, which must contain one single value.
>     Throws an error if no value provided, or value not correct.
> @@ -2720,6 +2743,18 @@ Make \"wLapPeu\" an alias of 2 nested \"with\":\n\
>  
>    set_cmd_completer_handle_brkchars (c, alias_command_completer);
>  
> +  add_setshow_boolean_cmd ("suppress-notification-cli", no_class,
> +			   &user_wants_cli_suppress_notification,
> +			   _("\
> +Set whether printing notification events on CLI is suppressed."), _("\
> +Show whether printing notification events on CLI is suppressed."), _("\
> +When on, printing notification events (such as inferior/thread switch)\n\
> +on CLI is suppressed."),
> +			   maint_set_suppress_notification_cli,
> +			   maint_show_suppress_notification_cli,
> +			   &maintenance_set_cmdlist,
> +			   &maintenance_show_cmdlist);
> +
>    const char *source_help_text = xstrprintf (_("\
>  Read commands from a file named FILE.\n\
>  \n\
> diff --git a/gdb/testsuite/gdb.base/cli-suppress-notification.c b/gdb/testsuite/gdb.base/cli-suppress-notification.c
> new file mode 100644
> index 00000000000..d5142fed2ca
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/cli-suppress-notification.c
> @@ -0,0 +1,22 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> +   Copyright 2020-2021 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +int
> +main ()
> +{
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.base/cli-suppress-notification.exp b/gdb/testsuite/gdb.base/cli-suppress-notification.exp
> new file mode 100644
> index 00000000000..97fc83eb94a
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/cli-suppress-notification.exp
> @@ -0,0 +1,33 @@
> +# Copyright 2020-2021 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# Test the cli-suppress-notification command.
> +
> +standard_testfile
> +
> +if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} {
> +    return
> +}
> +
> +if {![runto_main]} {
> +    return
> +}
> +
> +gdb_test "inferior 1" ".*Switching to inferior 1 .* to thread 1 .*" \
> +    "not suppressed"
> +
> +gdb_test_no_output "maint set suppress-notification-cli on"
> +
> +gdb_test_no_output "inferior 1" "suppressed"
> -- 
> 2.33.1
> 
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928
> 
> 


  parent reply	other threads:[~2022-01-18 10:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01 15:08 [PATCH 0/3] Suppressing CLI notifications Tankut Baris Aktemur
2021-12-01 15:08 ` [PATCH 1/3] gdb/cli: convert cli_suppress_notification from int to bool Tankut Baris Aktemur
2022-01-14 15:52   ` Tom Tromey
2021-12-01 15:08 ` [PATCH 2/3] gdb/cli: add a 'normal_stop' option to 'cli_suppress_notification' Tankut Baris Aktemur
2022-01-14 16:01   ` Tom Tromey
2021-12-01 15:08 ` [PATCH 3/3] gdb: add the 'set/show suppress-notification-cli' command Tankut Baris Aktemur
2022-01-14 16:04   ` Tom Tromey
2022-01-18 10:41   ` Andrew Burgess [this message]
2022-01-14 12:13 ` [PATCH 0/3] Suppressing CLI notifications Aktemur, Tankut Baris

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=20220118104159.GB622389@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tankut.baris.aktemur@intel.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).