This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
PR 8507 - Remote watchpoint limit really large
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 29 Dec 2008 05:25:11 +0000
- Subject: PR 8507 - Remote watchpoint limit really large
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
2008-12-29 Pedro Alves <pedro@codesourcery.com>
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, _("\