From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 510 invoked by alias); 29 Dec 2008 05:25:53 -0000 Received: (qmail 501 invoked by uid 22791); 29 Dec 2008 05:25:52 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Dec 2008 05:25:16 +0000 Received: (qmail 15111 invoked from network); 29 Dec 2008 05:25:13 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 29 Dec 2008 05:25:13 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: PR 8507 - Remote watchpoint limit really large Date: Mon, 29 Dec 2008 05:25:00 -0000 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_38FWJBVtkvVs0tP" Message-Id: <200812290525.11823.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-12/txt/msg00440.txt.bz2 --Boundary-00=_38FWJBVtkvVs0tP Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 950 PR 8507 is about this command: (gdb) help show remote hardware-watchpoint-limit Show the maximum number of target hardware watchpoints. Specify a negative limit for unlimited. And the fact that a negative value (default is -1), shows through as a large positive value, which is somewhat confusing: (gdb) show remote hardware-watchpoint-limit The maximum number of target hardware watchpoints is 4294967295. Notice that the "show" help explicitly mentioned "Specify a negative limit for unlimited.". This patch fixes it to show: (gdb) set remote hardware-watchpoint-limit -1 (gdb) show remote hardware-watchpoint-limit The maximum number of target hardware watchpoints is unlimited. There's no current enum var_types for this integer usage, where 0 really means zero, and negatives mean unlimited, so I've added one. "set/show remote hardware-breakpoint-limit" has the same issue, so it gets the same fix. Comments? -- Pedro Alves --Boundary-00=_38FWJBVtkvVs0tP Content-Type: text/x-diff; charset="iso 8859-15"; name="pr8507.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr8507.diff" Content-length: 7129 2008-12-29 Pedro Alves PR gdb/8507: * command.h (enum var_types): Add var_zinteger_nu. (add_setshow_zinteger_nu_cmd): Declare. * cli/cli-decode.c (add_setshow_zinteger_nu_cmd): New. * cli/cli-setshow.c (do_setshow_command): Handle it. * remote.c (_initialize_remote): Make the hardware-watchpoint-limit and hardware-breakpoint-limit commands zinteger_nu commands. --- gdb/cli/cli-decode.c | 21 +++++++++++++++++++++ gdb/cli/cli-setshow.c | 16 ++++++++++++++++ gdb/command.h | 27 ++++++++++++++++++++++++--- gdb/remote.c | 16 ++++++++-------- 4 files changed, 69 insertions(+), 11 deletions(-) Index: src/gdb/command.h =================================================================== --- src.orig/gdb/command.h 2008-12-29 04:42:35.000000000 +0000 +++ src/gdb/command.h 2008-12-29 05:08:03.000000000 +0000 @@ -71,22 +71,32 @@ typedef enum var_types to mean "unlimited", which is stored in *VAR as INT_MAX. */ var_integer, + /* ZeroableInteger. *VAR is an int. Like Unsigned Integer except + that zero really means zero. */ + var_zinteger, + + /* ZeroableIntegerNegativeUnlimited. *VAR is an int. Zero really + means zero, and negative values mean "unlimited", which is + stored as UINT_MAX. */ + var_zinteger_nu, + /* String which the user enters with escapes (e.g. the user types \n and it is a real newline in the stored string). *VAR is a malloc'd string, or NULL if the string is empty. */ var_string, + /* String which stores what the user types verbatim. *VAR is a malloc'd string, or NULL if the string is empty. */ var_string_noescape, + /* String which stores a filename. (*VAR) is a malloc'd string, or "" if the string was empty. */ var_optional_filename, + /* String which stores a filename. (*VAR) is a malloc'd string. */ var_filename, - /* ZeroableInteger. *VAR is an int. Like Unsigned Integer except - that zero really means zero. */ - var_zinteger, + /* Enumerated type. Can only have one of the specified values. *VAR is a char pointer to the name of the element that we find. */ var_enum @@ -332,6 +342,17 @@ extern void add_setshow_zinteger_cmd (ch struct cmd_list_element **set_list, struct cmd_list_element **show_list); +extern void add_setshow_zinteger_nu_cmd (char *name, + enum command_class class, + int *var, + const char *set_doc, + const char *show_doc, + const char *help_doc, + cmd_sfunc_ftype *set_func, + show_value_ftype *show_func, + struct cmd_list_element **set_list, + struct cmd_list_element **show_list); + /* Do a "show" command for each thing on a command list. */ extern void cmd_show_list (struct cmd_list_element *, int, char *); Index: src/gdb/cli/cli-decode.c =================================================================== --- src.orig/gdb/cli/cli-decode.c 2008-12-29 04:42:48.000000000 +0000 +++ src/gdb/cli/cli-decode.c 2008-12-29 04:54:51.000000000 +0000 @@ -639,6 +639,27 @@ add_setshow_zinteger_cmd (char *name, en NULL, NULL); } +/* Add element named NAME to both the set and show command LISTs (the + list for set/show or some sublist thereof). CLASS is as in + add_cmd. VAR is address of the variable which will contain the + value. SET_DOC and SHOW_DOC are the documentation strings. */ +void +add_setshow_zinteger_nu_cmd (char *name, enum command_class class, + int *var, + const char *set_doc, const char *show_doc, + const char *help_doc, + cmd_sfunc_ftype *set_func, + show_value_ftype *show_func, + struct cmd_list_element **set_list, + struct cmd_list_element **show_list) +{ + add_setshow_cmd_full (name, class, var_zinteger_nu, var, + set_doc, show_doc, help_doc, + set_func, show_func, + set_list, show_list, + NULL, NULL); +} + /* Remove the command named NAME from the command list. Return the list commands which were aliased to the deleted command. If the command had no aliases, return NULL. The various *HOOKs are set to Index: src/gdb/cli/cli-setshow.c =================================================================== --- src.orig/gdb/cli/cli-setshow.c 2008-12-29 04:42:48.000000000 +0000 +++ src/gdb/cli/cli-setshow.c 2008-12-29 05:19:41.000000000 +0000 @@ -213,6 +213,21 @@ do_setshow_command (char *arg, int from_ if (*(unsigned int *) c->var == 0) *(unsigned int *) c->var = UINT_MAX; break; + case var_zinteger_nu: + { + LONGEST val; + + if (arg == NULL) + error_no_arg (_("integer to set it to.")); + val = parse_and_eval_long (arg); + if (val < 0) + *(int *) c->var = UINT_MAX; + else if (val > INT_MAX) + error (_("integer %s out of range"), plongest (val)); + else + *(int *) c->var = val; + break; + } case var_integer: { unsigned int val; @@ -345,6 +360,7 @@ do_setshow_command (char *arg, int from_ } break; case var_uinteger: + case var_zinteger_nu: if (*(unsigned int *) c->var == UINT_MAX) { fputs_filtered ("unlimited", stb->stream); Index: src/gdb/remote.c =================================================================== --- src.orig/gdb/remote.c 2008-12-29 03:43:20.000000000 +0000 +++ src/gdb/remote.c 2008-12-29 05:10:34.000000000 +0000 @@ -8979,20 +8979,20 @@ further restriction and ``limit'' to ena _("Show the maximum number of bytes per memory-read packet."), &remote_show_cmdlist); - add_setshow_zinteger_cmd ("hardware-watchpoint-limit", no_class, - &remote_hw_watchpoint_limit, _("\ + add_setshow_zinteger_nu_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-breakpoint-limit", no_class, - &remote_hw_breakpoint_limit, _("\ + NULL, NULL, /* FIXME: i18n: The maximum number of target hardware watchpoints is %s. */ + &remote_set_cmdlist, &remote_show_cmdlist); + add_setshow_zinteger_nu_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. */ - &remote_set_cmdlist, &remote_show_cmdlist); + NULL, NULL, /* FIXME: i18n: The maximum number of target hardware breakpoints is %s. */ + &remote_set_cmdlist, &remote_show_cmdlist); add_setshow_integer_cmd ("remoteaddresssize", class_obscure, &remote_address_size, _("\ --Boundary-00=_38FWJBVtkvVs0tP--