Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 2/3] var_integer -> var_zuinteger_unlimited
Date: Mon, 13 Aug 2012 15:28:00 -0000	[thread overview]
Message-ID: <1344871663-915-3-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1344871663-915-1-git-send-email-yao@codesourcery.com>

Hi,
With previous patch applied, var_integer are still used in two palces,
'listsize' and 'remotetimeout'.  They are similar, 0 is allowed, and -1
means unlimited.  Existing 'enum var_types' don't cover this kind of
command, so I create a new one 'var_zuinteger_unlimited'.

After this patch, var_integer is only used in python.

gdb:

2012-08-13  Yao Qi  <yao@codesourcery.com>

	* cli/cli-decode.c (add_setshow_zuinteger_unlimited_cmd): New.
	* cli/cli-setshow.c (do_set_command): Handle case
	'var_zuinteger_unlimited'.
	(do_show_command): Likewise.
	* cli/cli-cmds.c (init_cmds): Call add_setshow_zuinteger_unlimited_cmd
	for command 'remotetimeout'.
	* command.h (enum var_types): New zuinteger_unlimited.
	* source.c (_initialize_source): Call add_setshow_zuinteger_unlimited_cmd
	for command 'set listsize'.

gdb/doc:

2012-08-13  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo(List): Describe the meaning of 0 and -1 in
	'set listsize'.

2012-08-13  Yao Qi  <yao@codesourcery.com>

	* gdb.base/list.exp (set_listsize): Don't set arg to "unlimited"
	when it is less than 0.
---
 gdb/cli/cli-cmds.c              |    9 +++++----
 gdb/cli/cli-decode.c            |   19 +++++++++++++++++++
 gdb/cli/cli-setshow.c           |   30 +++++++++++++++++++++++++++++-
 gdb/command.h                   |   15 +++++++++++++++
 gdb/doc/gdb.texinfo             |    2 ++
 gdb/source.c                    |    8 ++++----
 gdb/testsuite/gdb.base/list.exp |    2 +-
 7 files changed, 75 insertions(+), 10 deletions(-)

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 3d70c9e..4b23a0f 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1825,14 +1825,15 @@ is displayed."),
 			    show_remote_debug,
 			    &setdebuglist, &showdebuglist);
 
-  add_setshow_integer_cmd ("remotetimeout", no_class, &remote_timeout, _("\
+  add_setshow_zuinteger_unlimited_cmd ("remotetimeout", no_class,
+				       &remote_timeout, _("\
 Set timeout limit to wait for target to respond."), _("\
 Show timeout limit to wait for target to respond."), _("\
 This value is used to set the time limit for gdb to wait for a response\n\
 from the target."),
-			   NULL,
-			   show_remote_timeout,
-			   &setlist, &showlist);
+				       NULL,
+				       show_remote_timeout,
+				       &setlist, &showlist);
 
   add_prefix_cmd ("debug", no_class, set_debug,
 		  _("Generic command for setting gdb debugging flags"),
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 3c2e152..9e8218c 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -692,6 +692,25 @@ add_setshow_zinteger_cmd (char *name, enum command_class class,
 			NULL, NULL);
 }
 
+void
+add_setshow_zuinteger_unlimited_cmd (char *name,
+				     enum command_class class,
+				     unsigned 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_zuinteger_unlimited, var,
+			set_doc, show_doc, help_doc,
+			set_func, show_func,
+			set_list, show_list,
+			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
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 89e095a..9d8cb2e 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -379,6 +379,26 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c)
 	  }
       }
       break;
+    case var_zuinteger_unlimited:
+      {
+	LONGEST val;
+
+	if (arg == NULL)
+	  error_no_arg (_("integer to set it to."));
+	val = parse_and_eval_long (arg);
+
+	if (val >= INT_MAX)
+	  error (_("integer %s out of range"), plongest (val));
+	else if (val < -1)
+	  error (_("only -1 is allowed to set as unlimited"));
+
+	if (*(int *) c->var != val)
+	  {
+	    *(int *) c->var = val;
+	    option_changed = 1;
+	  }
+      }
+      break;
     default:
       error (_("gdb internal error: bad var_type in do_setshow_command"));
     }
@@ -478,6 +498,7 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c)
 	  break;
 	case var_integer:
 	case var_zinteger:
+	case var_zuinteger_unlimited:
 	  {
 	    char s[64];
 
@@ -562,7 +583,14 @@ do_show_command (char *arg, int from_tty, struct cmd_list_element *c)
       else
 	fprintf_filtered (stb, "%d", *(int *) c->var);
       break;
-
+    case var_zuinteger_unlimited:
+      {
+	if (*(int *) c->var == -1)
+	  fputs_filtered ("unlimited", stb);
+	else
+	  fprintf_filtered (stb, "%u", *(int *) c->var);
+      }
+      break;
     default:
       error (_("gdb internal error: bad var_type in do_show_command"));
     }
diff --git a/gdb/command.h b/gdb/command.h
index 88895bb..553bd717 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -99,6 +99,9 @@ typedef enum var_types
     /* ZeroableUnsignedInteger.  *VAR is an unsigned int.  Zero really
        means zero.  */
     var_zuinteger,
+    /* ZeroableUnsignedInteger with unlimited value.  *VAR is an unsigned
+       int, but its range is [0, INT_MAX].  -1 stands for unlimited.  */
+    var_zuinteger_unlimited,
     /* Enumerated type.  Can only have one of the specified values.
        *VAR is a char pointer to the name of the element that we
        find.  */
@@ -354,6 +357,18 @@ extern void add_setshow_zuinteger_cmd (char *name,
 				       struct cmd_list_element **set_list,
 				       struct cmd_list_element **show_list);
 
+extern void
+  add_setshow_zuinteger_unlimited_cmd (char *name,
+				       enum command_class class,
+				       unsigned 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 *);
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 5cc5b48..2ccfecd 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6706,6 +6706,8 @@ the @code{list} command.  You can change this using @code{set listsize}:
 @item set listsize @var{count}
 Make the @code{list} command display @var{count} source lines (unless
 the @code{list} argument explicitly specifies some other number).
+Setting @var{count} to -1 means there's no limit and 0 means suppress
+lines display.
 
 @kindex show listsize
 @item show listsize
diff --git a/gdb/source.c b/gdb/source.c
index 0ff0782..31e104f 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1965,12 +1965,12 @@ The matching line number is also stored as the value of \"$_\"."));
       add_com_alias ("?", "reverse-search", class_files, 0);
     }
 
-  add_setshow_integer_cmd ("listsize", class_support, &lines_to_list, _("\
+  add_setshow_zuinteger_unlimited_cmd ("listsize", class_support,
+				       &lines_to_list, _("\
 Set number of source lines gdb will list by default."), _("\
 Show number of source lines gdb will list by default."), NULL,
-			    NULL,
-			    show_lines_to_list,
-			    &setlist, &showlist);
+				       NULL, show_lines_to_list,
+				       &setlist, &showlist);
 
   add_cmd ("substitute-path", class_files, set_substitute_path_command,
            _("\
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 6b5b207..9acb1c3 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -62,7 +62,7 @@ proc set_listsize { arg } {
     if [gdb_test "set listsize $arg" ".*" "setting listsize to $arg #$set_listsize_count"] {
 	return 0;
     }
-    if { $arg <= 0 } {
+    if { $arg < 0 } {
 	set arg "unlimited";
     }
 
-- 
1.7.7.6


  parent reply	other threads:[~2012-08-13 15:28 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 12:52 [PATCH] Handle var_uinteger/var_zuinteger and case var_integer/var_zinteger together Yao Qi
2012-07-24 12:51 ` [committed]: " Yao Qi
2012-07-27 17:40 ` Khoo Yit Phang
2012-07-29 14:25   ` Yao Qi
2012-08-01 13:56   ` [RFC 0/3] New var_types var_zuinteger_unlimited Yao Qi
2012-08-01 13:56     ` [PATCH 3/3] use zuinteger_unlimited for heuristic-fence-post Yao Qi
2012-08-01 13:56     ` [PATCH 2/3] use zuinteger_unlimited for some remote commands Yao Qi
2012-08-01 13:56     ` [PATCH 1/3] var_zuinteger_unlimited and 'set listsize' Yao Qi
2012-08-01 16:14       ` Eli Zaretskii
2012-08-02  8:34       ` Doug Evans
2012-08-02 12:53         ` Yao Qi
2012-08-13 15:28   ` [RFC 0/3] Get rid of var_integer in CLI Yao Qi
2012-08-13 15:28     ` [PATCH 3/3] comments update Yao Qi
2012-09-14 18:13       ` Tom Tromey
2012-08-13 15:28     ` Yao Qi [this message]
2012-08-13 17:54       ` [PATCH 2/3] var_integer -> var_zuinteger_unlimited Eli Zaretskii
2012-09-14 18:12       ` Tom Tromey
2012-09-17  8:43         ` [committed]: " Yao Qi
2012-08-13 15:28     ` [PATCH 1/3] var_integer -> var_uinteger Yao Qi
2012-08-23 18:20       ` dje
2012-08-24  6:56         ` Yao Qi
2012-08-24 17:06           ` dje
2012-08-27 10:10             ` Yao Qi
2012-08-27 22:14               ` dje
2012-08-28 14:09                 ` [committed]: " Yao Qi
2013-03-25 22:55                   ` Change "set history size" back to signed (Re: [committed]: [PATCH 1/3] var_integer -> var_uinteger) Pedro Alves
2013-03-26 16:48                     ` Yao Qi
2013-03-26 17:48                       ` Pedro Alves
2013-03-27  8:54                         ` Yao Qi
2013-03-27 17:34                           ` Pedro Alves
2012-08-22 14:30     ` [ping] : [RFC 0/3] Get rid of var_integer in CLI Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1344871663-915-3-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox