From patchwork Mon Jul 9 17:10:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 28282 Received: (qmail 116556 invoked by alias); 9 Jul 2018 17:10:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 116526 invoked by uid 89); 9 Jul 2018 17:10:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:sk:static-, H*r:sk:static-, H*RU:sk:static- X-HELO: mail-wr1-f66.google.com Received: from mail-wr1-f66.google.com (HELO mail-wr1-f66.google.com) (209.85.221.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jul 2018 17:10:51 +0000 Received: by mail-wr1-f66.google.com with SMTP id j5-v6so5240625wrr.8 for ; Mon, 09 Jul 2018 10:10:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=OAZBsNFUdumDaFgIWAZGSHGsFiSqOSfc7l3+VT55CrI=; b=XF75dKNFSiljAz5l0x0v7IDIRI3T+Zecg+XcuhA7o0LrJ0POJ/IxL+SPBsxNi6kC01 8nWBlrclAsiEUn/1+QzlMRLlDKBQML5M/ow3Dlwr7yQ0Hhhh3Sg4VgT3a2hDIMSM2P86 oBWMMNe1AaJxDpnBUwk2T7pDcXWdUWLvzRpX4Go+qO9GkHLQGYhRxBSCFNOmg6cBN2eS HwsWAs8+H69CIklVy07LBxzt6L3rjGkN36enQysfpiPUICOK9izFX6dgtOknNn6tqrOQ FsPhtNTVky2J5FDsdVoc5X6/oU5JzCalesNpUjvctQt9ecnqriOMfpyoVlqhly2aK7TA NN2g== Return-Path: Received: from localhost (static-84-9-246-36.vodafonexdsl.co.uk. [84.9.246.36]) by smtp.gmail.com with ESMTPSA id g125-v6sm16732663wmf.16.2018.07.09.10.10.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jul 2018 10:10:47 -0700 (PDT) Date: Mon, 9 Jul 2018 18:10:46 +0100 From: Andrew Burgess To: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb: Use add_setshow_zuinteger_unlimited_cmd in remote.c Message-ID: <20180709171045.GE3978@embecosm.com> References: <20180702221146.20201-1-andrew.burgess@embecosm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180702221146.20201-1-andrew.burgess@embecosm.com> X-Fortune: If everything is coming your way then you're in the wrong lane. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Thanks for all the feedback, here's the final version I pushed: --- [PATCH] gdb: Use add_setshow_zuinteger_unlimited_cmd in remote.c Switch to use add_setshow_zuinteger_unlimited_cmd for some of the control variables in remote.c. The variables hardware-watchpoint-limit, hardware-breakpoint-limit, and hardware-watchpoint-length-limit are all changed. For example, a user will now see this: (gdb) show remote hardware-breakpoint-limit The maximum number of target hardware breakpoints is unlimited. Instead of this: (gdb) show remote hardware-breakpoint-limit The maximum number of target hardware breakpoints is -1. And can do this: (gdb) set remote hardware-breakpoint-limit unlimited However, previously any negative value implied "unlimited", now only -1, or the text "unlimited" can be used for unlimited. Any other negative value will give an error about invalid input. This is a small change in the user interface, but, hopefully, this will not cause too many problems. I've also added show functions for these three variables to allow for internationalisation. gdb/ChangeLog: * remote.c (show_hardware_watchpoint_limit): New function. (show_hardware_watchpoint_length_limit): New function. (show_hardware_breakpoint_limit): New function. (_initialize_remote): Use add_setshow_zuinteger_unlimited_cmd where appropriate, update help text. gdb/doc/ChangeLog: * gdb.texinfo (Remote Configuration): Update descriptions for set/show of hardware-watchpoint-limit, hardware-breakpoint-limit, and hardware-watchpoint-length-limit variables. --- gdb/ChangeLog | 8 +++++++ gdb/doc/ChangeLog | 6 ++++++ gdb/doc/gdb.texinfo | 18 +++++++++++----- gdb/remote.c | 61 +++++++++++++++++++++++++++++++++++++++-------------- 4 files changed, 72 insertions(+), 21 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 91ec2199580..245d3f1b973 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -21161,16 +21161,24 @@ @anchor{set remote hardware-breakpoint-limit} @item set remote hardware-watchpoint-limit @var{limit} @itemx set remote hardware-breakpoint-limit @var{limit} -Restrict @value{GDBN} to using @var{limit} remote hardware breakpoint or -watchpoints. A limit of -1, the default, is treated as unlimited. +Restrict @value{GDBN} to using @var{limit} remote hardware watchpoints +or breakpoints. The @var{limit} can be set to 0 to disable hardware +watchpoints or breakpoints, and @code{unlimited} for unlimited +watchpoints or breakpoints. + +@item show remote hardware-watchpoint-limit +@itemx show remote hardware-breakpoint-limit +Show the current limit for the number of hardware watchpoints or +breakpoints that @value{GDBN} can use. @cindex limit hardware watchpoints length @cindex remote target, limit watchpoints length @anchor{set remote hardware-watchpoint-length-limit} @item set remote hardware-watchpoint-length-limit @var{limit} -Restrict @value{GDBN} to using @var{limit} bytes for the maximum length of -a remote hardware watchpoint. A limit of -1, the default, is treated -as unlimited. +Restrict @value{GDBN} to using @var{limit} bytes for the maximum +length of a remote hardware watchpoint. A @var{limit} of 0 disables +hardware watchpoints and @code{unlimited} allows watchpoints of any +length. @item show remote hardware-watchpoint-length-limit Show the current limit (in bytes) of the maximum length of diff --git a/gdb/remote.c b/gdb/remote.c index d5accc64c78..297c198ed69 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1728,6 +1728,39 @@ show_memory_write_packet_size (const char *args, int from_tty) show_memory_packet_size (&memory_write_packet_config); } +/* Show the number of hardware watchpoints that can be used. */ + +static void +show_hardware_watchpoint_limit (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("The maximum number of target hardware " + "watchpoints is %s.\n"), value); +} + +/* Show the length limit (in bytes) for hardware watchpoints. */ + +static void +show_hardware_watchpoint_length_limit (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("The maximum length (in bytes) of a target " + "hardware watchpoint is %s.\n"), value); +} + +/* Show the number of hardware breakpoints that can be used. */ + +static void +show_hardware_breakpoint_limit (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("The maximum number of target hardware " + "breakpoints is %s.\n"), value); +} + long remote_target::get_memory_write_packet_size () { @@ -14347,32 +14380,28 @@ further restriction and ``limit'' to enable that restriction."), _("Show the maximum number of bytes per memory-read packet."), &remote_show_cmdlist); - add_setshow_zinteger_cmd ("hardware-watchpoint-limit", no_class, + add_setshow_zuinteger_unlimited_cmd ("hardware-watchpoint-limit", no_class, &remote_hw_watchpoint_limit, _("\ Set the maximum number of target hardware watchpoints."), _("\ Show the maximum number of target hardware watchpoints."), _("\ -Specify a negative limit for unlimited."), - NULL, NULL, /* FIXME: i18n: The maximum - number of target hardware - watchpoints is %s. */ - &remote_set_cmdlist, &remote_show_cmdlist); - add_setshow_zinteger_cmd ("hardware-watchpoint-length-limit", no_class, +Specify \"unlimited\" for unlimited hardware watchpoints."), + NULL, show_hardware_watchpoint_limit, + &remote_set_cmdlist, + &remote_show_cmdlist); + add_setshow_zuinteger_unlimited_cmd ("hardware-watchpoint-length-limit", + no_class, &remote_hw_watchpoint_length_limit, _("\ Set the maximum length (in bytes) of a target hardware watchpoint."), _("\ Show the maximum length (in bytes) of a target hardware watchpoint."), _("\ -Specify a negative limit for unlimited."), - NULL, NULL, /* FIXME: i18n: The maximum - length (in bytes) of a target - hardware watchpoint is %s. */ +Specify \"unlimited\" to allow watchpoints of unlimited size."), + NULL, show_hardware_watchpoint_length_limit, &remote_set_cmdlist, &remote_show_cmdlist); - add_setshow_zinteger_cmd ("hardware-breakpoint-limit", no_class, + add_setshow_zuinteger_unlimited_cmd ("hardware-breakpoint-limit", no_class, &remote_hw_breakpoint_limit, _("\ Set the maximum number of target hardware breakpoints."), _("\ Show the maximum number of target hardware breakpoints."), _("\ -Specify a negative limit for unlimited."), - NULL, NULL, /* FIXME: i18n: The maximum - number of target hardware - breakpoints is %s. */ +Specify \"unlimited\" for unlimited hardware breakpoints."), + NULL, show_hardware_breakpoint_limit, &remote_set_cmdlist, &remote_show_cmdlist); add_setshow_zuinteger_cmd ("remoteaddresssize", class_obscure,