From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 8D52B3857C45 for ; Tue, 18 Jan 2022 10:42:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D52B3857C45 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-113-gkwTJjfLPva0za0arHQyRg-1; Tue, 18 Jan 2022 05:42:03 -0500 X-MC-Unique: gkwTJjfLPva0za0arHQyRg-1 Received: by mail-wm1-f72.google.com with SMTP id f7-20020a1cc907000000b0034b63f314ccso1765576wmb.6 for ; Tue, 18 Jan 2022 02:42:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TDRHZbFa+u93MUaB8lR4eam+Z7L8Gmexn8vaZ4GxcXA=; b=m3+53iZhbnpNVu5rfcWNL+7hwm6Xt8mZQQq5VOhC4VBxOf/+7m2q/MVwno20l5qh4+ NU9ho3OGenPBEatmg35NRXHJcMj90VvRncvY7jllD0z3ckOaejWTKUzZyn4bC2XOZN/p pBKTkHw0DLRMPgLAsLhHM+gh92vY3CMX0MVY2ytPK3u05vilZzCYPFdrrILY/imTHYEj +m0p12z7F00H+/DL13GAOyEJrtN0ptxrEYGa1IKhbOzngyGW1Cas2fiAZ1Rwf3DODEQF CwwwuMttTaW+I4VSUtdPlnGdoK4nudhB0NI4FvCF0SQnFBOVPb+BWYoZnnAfcGwzu6xg sgJQ== X-Gm-Message-State: AOAM533xjXmUSwdiUGIFrwPXQhDiev9FITfVdV3QAuHL+koMgjqYXAe3 IqB5GWLR6aLMksXRv1mmSsnoAUjKeA2GBuRLT18wM8j/WSiH1P/wHBPwVY+kxFJXsUU7eG9if+b DCfalsIuXHXJAg4rueIrDEg== X-Received: by 2002:a05:6000:1ac8:: with SMTP id i8mr8687927wry.255.1642502521508; Tue, 18 Jan 2022 02:42:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDtWbdEvJpM4l9sm20G63a7kxGjMheW2LkMTU+tLlFmSLHCNlHslvsQIEqetCYz7A39P04TA== X-Received: by 2002:a05:6000:1ac8:: with SMTP id i8mr8687910wry.255.1642502521240; Tue, 18 Jan 2022 02:42:01 -0800 (PST) Received: from localhost (host86-188-49-82.range86-188.btcentralplus.com. [86.188.49.82]) by smtp.gmail.com with ESMTPSA id h13sm16169051wrx.8.2022.01.18.02.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 02:42:00 -0800 (PST) Date: Tue, 18 Jan 2022 10:41:59 +0000 From: Andrew Burgess To: Tankut Baris Aktemur Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 3/3] gdb: add the 'set/show suppress-notification-cli' command Message-ID: <20220118104159.GB622389@redhat.com> References: <3a4bd599cabeb95b5f4d18b5d0fb0c24d4bd4266.1638370938.git.tankut.baris.aktemur@intel.com> MIME-Version: 1.0 In-Reply-To: <3a4bd599cabeb95b5f4d18b5d0fb0c24d4bd4266.1638370938.git.tankut.baris.aktemur@intel.com> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 10:39:13 up 16 days, 19:33, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Tue, 18 Jan 2022 10:42:20 -0000 * Tankut Baris Aktemur [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; > > + > +/* 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 . */ > + > +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 . > + > +# 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 > 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 > >