From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 0121F3858403 for ; Thu, 25 Nov 2021 03:12:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0121F3858403 X-ASG-Debug-ID: 1637809918-0c856e2e462bf780001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id ty23wr5zaFJjmEAA (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 24 Nov 2021 22:11:58 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id AD615441B21; Wed, 24 Nov 2021 22:11:58 -0500 (EST) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] gdb: convert maintenance target-async and target-non-stop settings to callbacks Date: Wed, 24 Nov 2021 22:11:58 -0500 X-ASG-Orig-Subj: [PATCH] gdb: convert maintenance target-async and target-non-stop settings to callbacks Message-Id: <20211125031158.631457-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1637809918 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 4748 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.94182 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-16.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, 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: Thu, 25 Nov 2021 03:12:11 -0000 From: Simon Marchi This simplifies things a bit, as we don't need two variables and think about reverting target_async_permitted_1 and target_non_stop_enabled_1 values if we can't change the setting. Change-Id: I36acab045dacf02ae1988486cfdb27c1dff309f6 --- gdb/target.c | 68 +++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/gdb/target.c b/gdb/target.c index 8fe27c775ea7..b1f5c092d23d 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -4344,27 +4344,24 @@ target_thread_events (int enable) just for maintainers to use when debugging gdb. */ bool target_async_permitted = true; -/* The set command writes to this variable. If the inferior is - executing, target_async_permitted is *not* updated. */ -static bool target_async_permitted_1 = true; - static void -maint_set_target_async_command (const char *args, int from_tty, - struct cmd_list_element *c) +set_maint_target_async (bool permitted) { if (have_live_inferiors ()) - { - target_async_permitted_1 = target_async_permitted; - error (_("Cannot change this setting while the inferior is running.")); - } + error (_("Cannot change this setting while the inferior is running.")); - target_async_permitted = target_async_permitted_1; + target_async_permitted = permitted; +} + +static bool +get_maint_target_async () +{ + return target_async_permitted; } static void -maint_show_target_async_command (struct ui_file *file, int from_tty, - struct cmd_list_element *c, - const char *value) +show_maint_target_async (ui_file *file, int from_tty, + cmd_list_element *c, const char *value) { fprintf_filtered (file, _("Controlling the inferior in " @@ -4416,31 +4413,28 @@ exists_non_stop_target () mode. This is just for maintainers to use when debugging gdb. */ enum auto_boolean target_non_stop_enabled = AUTO_BOOLEAN_AUTO; -/* The set command writes to this variable. If the inferior is - executing, target_non_stop_enabled is *not* updated. */ -static enum auto_boolean target_non_stop_enabled_1 = AUTO_BOOLEAN_AUTO; - -/* Implementation of "maint set target-non-stop". */ +/* Set callback for maint target-non-stop setting. */ static void -maint_set_target_non_stop_command (const char *args, int from_tty, - struct cmd_list_element *c) +set_maint_target_non_stop (auto_boolean enabled) { if (have_live_inferiors ()) - { - target_non_stop_enabled_1 = target_non_stop_enabled; - error (_("Cannot change this setting while the inferior is running.")); - } + error (_("Cannot change this setting while the inferior is running.")); - target_non_stop_enabled = target_non_stop_enabled_1; + target_non_stop_enabled = enabled; } -/* Implementation of "maint show target-non-stop". */ +/* Get callback for maint target-non-stop setting. */ + +static auto_boolean +get_maint_target_non_stop () +{ + return target_non_stop_enabled; +} static void -maint_show_target_non_stop_command (struct ui_file *file, int from_tty, - struct cmd_list_element *c, - const char *value) +show_maint_target_non_stop (ui_file *file, int from_tty, + cmd_list_element *c, const char *value) { if (target_non_stop_enabled == AUTO_BOOLEAN_AUTO) fprintf_filtered (file, @@ -4546,22 +4540,24 @@ result in significant performance improvement for remote targets."), &maintenanceprintlist); add_setshow_boolean_cmd ("target-async", no_class, - &target_async_permitted_1, _("\ + _("\ Set whether gdb controls the inferior in asynchronous mode."), _("\ Show whether gdb controls the inferior in asynchronous mode."), _("\ Tells gdb whether to control the inferior in asynchronous mode."), - maint_set_target_async_command, - maint_show_target_async_command, + set_maint_target_async, + get_maint_target_async, + show_maint_target_async, &maintenance_set_cmdlist, &maintenance_show_cmdlist); add_setshow_auto_boolean_cmd ("target-non-stop", no_class, - &target_non_stop_enabled_1, _("\ + _("\ Set whether gdb always controls the inferior in non-stop mode."), _("\ Show whether gdb always controls the inferior in non-stop mode."), _("\ Tells gdb whether to control the inferior in non-stop mode."), - maint_set_target_non_stop_command, - maint_show_target_non_stop_command, + set_maint_target_non_stop, + get_maint_target_non_stop, + show_maint_target_non_stop, &maintenance_set_cmdlist, &maintenance_show_cmdlist); -- 2.33.1