Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfa] Make get_number_or_range accept value history references
@ 2011-02-24 19:12 Michael Snyder
  2011-02-25 11:59 ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2011-02-24 19:12 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 147 bytes --]


I was under the impression that get_number would accept eg. "$1".
Turns out it doesn't.
This patch rectifies that, and adds tests to break.exp.



[-- Attachment #2: dollar.txt --]
[-- Type: text/plain, Size: 7980 bytes --]

2011-02-24  Michael Snyder  <msnyder@vmware.com>

	* value.c (value_from_history_ref): New function.
	* value.h (value_from_history_ref): Export.
	* cli/cli-utils.c (get_number_trailer): Use value_from_history_ref
	to parse value history references.

2011-02-24  Michael Snyder  <msnyder@vmware.com>

	* gdb.base/break.exp: Add tests for delete breakpoints using
	convenience variables and value history references.

Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.138
diff -u -p -u -p -r1.138 value.c
--- value.c	16 Feb 2011 11:55:59 -0000	1.138
+++ value.c	24 Feb 2011 19:00:20 -0000
@@ -41,7 +41,7 @@
 #include "cli/cli-decode.h"
 #include "exceptions.h"
 #include "python/python.h"
-
+#include <ctype.h>
 #include "tracepoint.h"
 
 /* Prototypes for exported functions.  */
@@ -2992,6 +2992,30 @@ value_from_decfloat (struct type *type, 
 }
 
 struct value *
+value_from_history_ref (char *h, char **endp)
+{
+  int index;
+
+  if (h[0] == '$')
+    {
+      if (isdigit (h[1]) || h[1] == '\0' || h[1] == ' ' || h[1] == '\t')
+	/* single-dollar history value */
+	index = strtol (&h[1], endp, 10);
+      else if (h[1] == '$' 
+	       && (isdigit (h[2]) || h[2] == '\0'
+		   || h[2] == ' ' || h[2] == '\t'))
+	/* double-dollar history value */
+	index = -strtol (&h[2], endp, 10);
+      else
+	/* not a history value */
+	return NULL;
+
+      return access_value_history (index);
+    }
+  return NULL;
+}
+
+struct value *
 coerce_ref (struct value *arg)
 {
   struct type *value_type_arg_tmp = check_typedef (value_type (arg));
Index: value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.176
diff -u -p -u -p -r1.176 value.h
--- value.h	16 Feb 2011 10:13:53 -0000	1.176
+++ value.h	24 Feb 2011 19:00:20 -0000
@@ -471,6 +471,7 @@ extern struct value *value_from_pointer 
 extern struct value *value_from_double (struct type *type, DOUBLEST num);
 extern struct value *value_from_decfloat (struct type *type,
 					  const gdb_byte *decbytes);
+extern struct value *value_from_history_ref (char *, char **);
 
 extern struct value *value_at (struct type *type, CORE_ADDR addr);
 extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
Index: cli/cli-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-utils.c,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 cli-utils.c
--- cli/cli-utils.c	22 Feb 2011 18:45:05 -0000	1.10
+++ cli/cli-utils.c	24 Feb 2011 19:00:20 -0000
@@ -21,6 +21,7 @@
 #include "cli/cli-utils.h"
 #include "gdb_string.h"
 #include "value.h"
+#include "gdb_assert.h"
 
 #include <ctype.h>
 
@@ -41,24 +42,37 @@ get_number_trailer (char **pp, int trail
 
   if (*p == '$')
     {
-      /* Make a copy of the name, so we can null-terminate it
-         to pass to lookup_internalvar().  */
-      char *varname;
-      char *start = ++p;
-      LONGEST val;
-
-      while (isalnum (*p) || *p == '_')
-	p++;
-      varname = (char *) alloca (p - start + 1);
-      strncpy (varname, start, p - start);
-      varname[p - start] = '\0';
-      if (get_internalvar_integer (lookup_internalvar (varname), &val))
-	retval = (int) val;
+      if (isalpha (p[1]) || p[1] == '_')
+	{
+	  /* Internal variable.  Make a copy of the name, so we can
+	     null-terminate it to pass to lookup_internalvar().  */
+	  char *varname;
+	  char *start = ++p;
+	  LONGEST val;
+
+	  while (isalnum (*p) || *p == '_')
+	    p++;
+	  varname = (char *) alloca (p - start + 1);
+	  strncpy (varname, start, p - start);
+	  varname[p - start] = '\0';
+	  if (get_internalvar_integer (lookup_internalvar (varname), &val))
+	    retval = (int) val;
+	  else
+	    {
+	      printf_filtered (_("Convenience variable must "
+				 "have integer value.\n"));
+	      retval = 0;
+	    }
+	}
       else
 	{
-	  printf_filtered (_("Convenience variable must "
-			     "have integer value.\n"));
-	  retval = 0;
+	  /* Value history token.  */
+	  struct value *val = value_from_history_ref (p, &p);
+
+	  gdb_assert (val);
+	  if (TYPE_CODE (value_type (val)) != TYPE_CODE_INT)
+	    error (_("History value must have integer type."));
+	  retval = value_as_long (val);
 	}
     }
   else
Index: testsuite/gdb.base/break.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/break.exp,v
retrieving revision 1.46
diff -u -p -u -p -r1.46 break.exp
--- testsuite/gdb.base/break.exp	24 Feb 2011 18:37:14 -0000	1.46
+++ testsuite/gdb.base/break.exp	24 Feb 2011 19:00:20 -0000
@@ -236,6 +236,124 @@ gdb_test_multiple "info break 3-5" "info
     }
 }
 
+#
+# Test disable/enable with arguments
+#
+
+# Test with value history
+
+gdb_test "print 1" "" ""
+gdb_test "print 2" "" ""
+gdb_test "print 3" "" ""
+gdb_test "print 4" "" ""
+gdb_test "print 5" "" ""
+
+gdb_test_no_output "disable \$2 \$\$" "disable using history values"
+
+set see1 0
+set see2 0
+set see3 0
+set see4 0
+set see5 0
+set see6 0
+
+gdb_test_multiple "info break" "check disable with history values" {
+    -re "1\[\t \]+breakpoint *keep y.* in main at .*:$main_line\[^\r\n\]*" {
+	set see1 1
+	exp_continue
+    }
+    -re "2\[\t \]+breakpoint *keep n\[^\r\n\]* in marker2 at \[^\r\n\]*" {
+	set see2 1
+	exp_continue
+    }
+    -re "3\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location7\[^\r\n\]*" {
+	set see3 1
+	exp_continue
+    }
+    -re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	set see4 1
+	exp_continue
+    }
+    -re "5\[\t \]+breakpoint *keep n\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	set see5 1
+	exp_continue
+    }
+    -re "6\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location2\[^\r\n\]*" {
+	set see6 1
+	exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+	if { $see1 && $see2 && $see3 && $see4 && $see5 && $see6 } then {
+	    pass "check disable with history values"
+	} else {
+	    fail "check disable with history values"
+	}
+    }
+}
+
+gdb_test "enable" "" ""
+gdb_test "set \$foo = 3" "" ""
+gdb_test "set \$bar = 6" "" ""
+gdb_test_no_output "disable \$foo \$bar" "disable with convenience values"
+
+set see1 0
+set see2 0
+set see3 0
+set see4 0
+set see5 0
+set see6 0
+
+gdb_test_multiple "info break" "check disable with convenience values" {
+    -re "1\[\t \]+breakpoint *keep y.* in main at .*:$main_line\[^\r\n\]*" {
+	set see1 1
+	exp_continue
+    }
+    -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in marker2 at \[^\r\n\]*" {
+	set see2 1
+	exp_continue
+    }
+    -re "3\[\t \]+breakpoint *keep n\[^\r\n\]*$bp_location7\[^\r\n\]*" {
+	set see3 1
+	exp_continue
+    }
+    -re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	set see4 1
+	exp_continue
+    }
+    -re "5\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	set see5 1
+	exp_continue
+    }
+    -re "6\[\t \]+breakpoint *keep n\[^\r\n\]*$bp_location2\[^\r\n\]*" {
+	set see6 1
+	exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+	if { $see1 && $see2 && $see3 && $see4 && $see5 && $see6 } then {
+	    pass "check disable with convenience values"
+	} else {
+	    fail "check disable with convenience values"
+	}
+    }
+}
+
+# test with bad values
+
+gdb_test "enable" "" ""
+gdb_test "disable 10" "No breakpoint number 10." \
+    "disable non-existent breakpoint 10"
+
+gdb_test "set \$baz 1.234"
+gdb_test "disable \$baz" \
+    "Convenience variable must have integer value.*" \
+    "disable with non-integer convenience var"
+gdb_test "disable \$grbx" \
+    "Convenience variable must have integer value.*" \
+    "disable with non-existent convenience var"
+gdb_test "disable \$10" \
+    "History has not yet reached .10." \
+    "disable with non-existent history value"
+
 # FIXME: The rest of this test doesn't work with anything that can't
 # handle arguments.
 # Huh? There doesn't *appear* to be anything that passes arguments

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa] Make get_number_or_range accept value history references
  2011-02-24 19:12 [rfa] Make get_number_or_range accept value history references Michael Snyder
@ 2011-02-25 11:59 ` Pedro Alves
  2011-02-25 19:20   ` Michael Snyder
  2011-02-25 22:10   ` Michael Snyder
  0 siblings, 2 replies; 6+ messages in thread
From: Pedro Alves @ 2011-02-25 11:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Michael Snyder

On Thursday 24 February 2011 19:11:02, Michael Snyder wrote:
> +      if (isdigit (h[1]) || h[1] == '\0' || h[1] == ' ' || h[1] == '\t')
> +       /* single-dollar history value */
> +       index = strtol (&h[1], endp, 10);

Is this correct for the ' '  and '\t' cases?  It looks
like it will accept "$ 3" as history value 3, but
it should parsed as "$" -- the last history value.

You're also not checking if the string is all
digits, so $123asdf is being accepted as $123, while
the language parsers treat that as an internal
variable.  Maybe you should take a look at write_dollar_variable,
and factor out or borrow code from there to avoid these
discrepancies?

> +      else if (h[1] == '$' 
> +              && (isdigit (h[2]) || h[2] == '\0'
> +                  || h[2] == ' ' || h[2] == '\t'))
> +       /* double-dollar history value */
> +       index = -strtol (&h[2], endp, 10);

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa] Make get_number_or_range accept value history references
  2011-02-25 11:59 ` Pedro Alves
@ 2011-02-25 19:20   ` Michael Snyder
  2011-02-25 22:10   ` Michael Snyder
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Snyder @ 2011-02-25 19:20 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves wrote:
> On Thursday 24 February 2011 19:11:02, Michael Snyder wrote:
>> +      if (isdigit (h[1]) || h[1] == '\0' || h[1] == ' ' || h[1] == '\t')
>> +       /* single-dollar history value */
>> +       index = strtol (&h[1], endp, 10);
> 
> Is this correct for the ' '  and '\t' cases?  It looks
> like it will accept "$ 3" as history value 3, but
> it should parsed as "$" -- the last history value.
> 
> You're also not checking if the string is all
> digits, so $123asdf is being accepted as $123, while
> the language parsers treat that as an internal
> variable.  Maybe you should take a look at write_dollar_variable,
> and factor out or borrow code from there to avoid these
> discrepancies?

It's worse than that.  I have to think about all the characters that a
user might type here, if they didn't know better.  Ugh.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa] Make get_number_or_range accept value history references
  2011-02-25 11:59 ` Pedro Alves
  2011-02-25 19:20   ` Michael Snyder
@ 2011-02-25 22:10   ` Michael Snyder
  2011-02-26 11:54     ` Pedro Alves
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2011-02-25 22:10 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 980 bytes --]

Pedro Alves wrote:
> On Thursday 24 February 2011 19:11:02, Michael Snyder wrote:
>> +      if (isdigit (h[1]) || h[1] == '\0' || h[1] == ' ' || h[1] == '\t')
>> +       /* single-dollar history value */
>> +       index = strtol (&h[1], endp, 10);
> 
> Is this correct for the ' '  and '\t' cases?  It looks
> like it will accept "$ 3" as history value 3, but
> it should parsed as "$" -- the last history value.
> 
> You're also not checking if the string is all
> digits, so $123asdf is being accepted as $123, while
> the language parsers treat that as an internal
> variable.  Maybe you should take a look at write_dollar_variable,
> and factor out or borrow code from there to avoid these
> discrepancies?
> 
>> +      else if (h[1] == '$' 
>> +              && (isdigit (h[2]) || h[2] == '\0'
>> +                  || h[2] == ' ' || h[2] == '\t'))
>> +       /* double-dollar history value */
>> +       index = -strtol (&h[2], endp, 10);
> 

OK, a major re-write!   ;-)



[-- Attachment #2: history.txt --]
[-- Type: text/plain, Size: 9988 bytes --]

2011-02-24  Michael Snyder  <msnyder@vmware.com>
 
	* value.c (value_from_history_ref): New function.
	* value.h (value_from_history_ref): Export.
	* cli/cli-utils.c (get_number_trailer): Use value_from_history_ref
	to parse value history references.
	* cli/cli-utils.h (get_number_trailer): Update comment.

2011-02-24  Michael Snyder  <msnyder@vmware.com>
 
	* gdb.base/break.exp: Add tests for delete breakpoints using
	convenience variables and value history references.
 
Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.138
diff -u -p -u -p -r1.138 value.c
--- value.c	16 Feb 2011 11:55:59 -0000	1.138
+++ value.c	25 Feb 2011 21:43:23 -0000
@@ -41,7 +41,7 @@
 #include "cli/cli-decode.h"
 #include "exceptions.h"
 #include "python/python.h"
-
+#include <ctype.h>
 #include "tracepoint.h"
 
 /* Prototypes for exported functions.  */
@@ -2991,6 +2991,59 @@ value_from_decfloat (struct type *type, 
   return val;
 }
 
+/* Extract a value from the history file.  Input will be of the form
+   $digits or $$digits.  See block comment above 'write_dollar_variable'
+   for details.  */
+
+struct value *
+value_from_history_ref (char *h, char **endp)
+{
+  int index, len;
+
+  if (h[0] == '$')
+    len = 1;
+  else
+    return NULL;
+
+  if (h[1] == '$')
+    len = 2;
+
+  /* Find length of numeral string.  */
+  for (; isdigit (h[len]); len++)
+    ;
+
+  /* Make sure numeral string is not part of an identifier.  */
+  if (h[len] == '_' || isalpha (h[len]))
+    return NULL;
+
+  /* Now collect the index value.  */
+  if (h[1] == '$')
+    {
+      if (len == 2)
+	{
+	  /* For some bizarre reason, "$$" is equivalent to "$$1", 
+	     rather than to "$$0" as it ought to be!  */
+	  index = -1;
+	  *endp += len;
+	}
+      else
+	index = -strtol (&h[2], endp, 10);
+    }
+  else
+    {
+      if (len == 1)
+	{
+	  /* "$" is equivalent to "$0".  */
+	  index = 0;
+	  *endp += len;
+	}
+      else
+	index = strtol (&h[1], endp, 10);
+    }
+
+  return access_value_history (index);
+}
+
 struct value *
 coerce_ref (struct value *arg)
 {
Index: value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.176
diff -u -p -u -p -r1.176 value.h
--- value.h	16 Feb 2011 10:13:53 -0000	1.176
+++ value.h	25 Feb 2011 21:43:23 -0000
@@ -471,6 +471,7 @@ extern struct value *value_from_pointer 
 extern struct value *value_from_double (struct type *type, DOUBLEST num);
 extern struct value *value_from_decfloat (struct type *type,
 					  const gdb_byte *decbytes);
+extern struct value *value_from_history_ref (char *, char **);
 
 extern struct value *value_at (struct type *type, CORE_ADDR addr);
 extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
Index: cli/cli-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-utils.c,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 cli-utils.c
--- cli/cli-utils.c	22 Feb 2011 18:45:05 -0000	1.10
+++ cli/cli-utils.c	25 Feb 2011 21:43:23 -0000
@@ -21,14 +21,15 @@
 #include "cli/cli-utils.h"
 #include "gdb_string.h"
 #include "value.h"
+#include "gdb_assert.h"
 
 #include <ctype.h>
 
 /* *PP is a string denoting a number.  Get the number of the.  Advance
    *PP after the string and any trailing whitespace.
 
-   Currently the string can either be a number or "$" followed by the
-   name of a convenience variable.
+   Currently the string can either be a number, or "$" followed by the
+   name of a convenience variable, or ("$" or "$$") followed by digits.
 
    TRAILER is a character which can be found after the number; most
    commonly this is `-'.  If you don't want a trailer, use \0.  */
@@ -41,24 +42,39 @@ get_number_trailer (char **pp, int trail
 
   if (*p == '$')
     {
-      /* Make a copy of the name, so we can null-terminate it
-         to pass to lookup_internalvar().  */
-      char *varname;
-      char *start = ++p;
-      LONGEST val;
-
-      while (isalnum (*p) || *p == '_')
-	p++;
-      varname = (char *) alloca (p - start + 1);
-      strncpy (varname, start, p - start);
-      varname[p - start] = '\0';
-      if (get_internalvar_integer (lookup_internalvar (varname), &val))
-	retval = (int) val;
-      else
+      struct value *val = value_from_history_ref (p, &p);
+
+      if (val)	/* Value history reference */
 	{
-	  printf_filtered (_("Convenience variable must "
-			     "have integer value.\n"));
-	  retval = 0;
+	  if (TYPE_CODE (value_type (val)) == TYPE_CODE_INT)
+	    retval = value_as_long (val);
+	  else
+	    {
+	      printf_filtered (_("History value must have integer type."));
+	      retval = 0;
+	    }
+	}
+      else	/* Convenience variable */
+	{
+	  /* Internal variable.  Make a copy of the name, so we can
+	     null-terminate it to pass to lookup_internalvar().  */
+	  char *varname;
+	  char *start = ++p;
+	  LONGEST val;
+
+	  while (isalnum (*p) || *p == '_')
+	    p++;
+	  varname = (char *) alloca (p - start + 1);
+	  strncpy (varname, start, p - start);
+	  varname[p - start] = '\0';
+	  if (get_internalvar_integer (lookup_internalvar (varname), &val))
+	    retval = (int) val;
+	  else
+	    {
+	      printf_filtered (_("Convenience variable must "
+				 "have integer value.\n"));
+	      retval = 0;
+	    }
 	}
     }
   else
Index: cli/cli-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-utils.h,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 cli-utils.h
--- cli/cli-utils.h	21 Feb 2011 23:40:46 -0000	1.10
+++ cli/cli-utils.h	25 Feb 2011 21:43:23 -0000
@@ -23,8 +23,8 @@
 /* *PP is a string denoting a number.  Get the number of the.  Advance
    *PP after the string and any trailing whitespace.
 
-   Currently the string can either be a number or "$" followed by the
-   name of a convenience variable.  */
+   Currently the string can either be a number,  or "$" followed by the
+   name of a convenience variable, or ("$" or "$$") followed by digits.  */
 
 extern int get_number (char **);
 
Index: testsuite/gdb.base/break.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/break.exp,v
retrieving revision 1.46
diff -u -p -u -p -r1.46 break.exp
--- testsuite/gdb.base/break.exp	24 Feb 2011 18:37:14 -0000	1.46
+++ testsuite/gdb.base/break.exp	25 Feb 2011 21:43:23 -0000
@@ -236,6 +236,129 @@ gdb_test_multiple "info break 3-5" "info
     }
 }
 
+#
+# Test disable/enable with arguments
+#
+
+# Test with value history
+
+gdb_test "print 1" "" ""
+gdb_test "print 2" "" ""
+gdb_test "print 3" "" ""
+gdb_test "print 4" "" ""
+gdb_test "print 5" "" ""
+gdb_test "print 6" "" ""
+
+# $2 is 2 and $$ is 5
+gdb_test_no_output "disable \$2 \$\$" "disable using history values"
+
+set see1 0
+set see2 0
+set see3 0
+set see4 0
+set see5 0
+set see6 0
+
+gdb_test_multiple "info break" "check disable with history values" {
+    -re "1\[\t \]+breakpoint *keep y.* in main at .*:$main_line\[^\r\n\]*" {
+	set see1 1
+	exp_continue
+    }
+    -re "2\[\t \]+breakpoint *keep n\[^\r\n\]* in marker2 at \[^\r\n\]*" {
+	set see2 1
+	exp_continue
+    }
+    -re "3\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location7\[^\r\n\]*" {
+	set see3 1
+	exp_continue
+    }
+    -re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	set see4 1
+	exp_continue
+    }
+    -re "5\[\t \]+breakpoint *keep n\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	set see5 1
+	exp_continue
+    }
+    -re "6\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location2\[^\r\n\]*" {
+	set see6 1
+	exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+	if { $see1 && $see2 && $see3 && $see4 && $see5 && $see6 } then {
+	    pass "check disable with history values"
+	} else {
+	    fail "check disable with history values"
+	}
+    }
+}
+
+gdb_test "enable" "" ""
+gdb_test "set \$foo = 3" "" ""
+gdb_test "set \$bar = 6" "" ""
+gdb_test_no_output "disable \$foo \$bar" "disable with convenience values"
+
+set see1 0
+set see2 0
+set see3 0
+set see4 0
+set see5 0
+set see6 0
+
+gdb_test_multiple "info break" "check disable with convenience values" {
+    -re "1\[\t \]+breakpoint *keep y.* in main at .*:$main_line\[^\r\n\]*" {
+	set see1 1
+	exp_continue
+    }
+    -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in marker2 at \[^\r\n\]*" {
+	set see2 1
+	exp_continue
+    }
+    -re "3\[\t \]+breakpoint *keep n\[^\r\n\]*$bp_location7\[^\r\n\]*" {
+	set see3 1
+	exp_continue
+    }
+    -re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	set see4 1
+	exp_continue
+    }
+    -re "5\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	set see5 1
+	exp_continue
+    }
+    -re "6\[\t \]+breakpoint *keep n\[^\r\n\]*$bp_location2\[^\r\n\]*" {
+	set see6 1
+	exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+	if { $see1 && $see2 && $see3 && $see4 && $see5 && $see6 } then {
+	    pass "check disable with convenience values"
+	} else {
+	    fail "check disable with convenience values"
+	}
+    }
+}
+
+# test with bad values
+
+gdb_test "enable" "" ""
+gdb_test "disable 10" "No breakpoint number 10." \
+    "disable non-existent breakpoint 10"
+
+gdb_test "set \$baz 1.234"
+gdb_test "disable \$baz" \
+    "Convenience variable must have integer value.*" \
+    "disable with non-integer convenience var"
+gdb_test "disable \$grbx" \
+    "Convenience variable must have integer value.*" \
+    "disable with non-existent convenience var"
+gdb_test "disable \$10" \
+    "History has not yet reached .10." \
+    "disable with non-existent history value"
+gdb_test "disable \$1foo" \
+    "Convenience variable must have integer value.*" \
+    "disable with badly formed history value"
+
 # FIXME: The rest of this test doesn't work with anything that can't
 # handle arguments.
 # Huh? There doesn't *appear* to be anything that passes arguments

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa] Make get_number_or_range accept value history references
  2011-02-25 22:10   ` Michael Snyder
@ 2011-02-26 11:54     ` Pedro Alves
  2011-02-27 21:03       ` Michael Snyder
  0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2011-02-26 11:54 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches

On Friday 25 February 2011 21:45:39, Michael Snyder wrote:

> OK, a major re-write!   ;-)

Thanks.

I now noticed linespec.c:decode_dollar also does
the same thing, another candidate for refactoring/reuse.

What does the _ref mean in value_from_history_ref?

> +gdb_test "disable \$1foo" \
> +    "Convenience variable must have integer value.*" \
> +    "disable with badly formed history value"

This is not a badly formed history value.  It's a user
convenience variable.  I'd make the test check that
such convenience variables work as intended.

Otherwise looked fine.  Thanks again.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa] Make get_number_or_range accept value history references
  2011-02-26 11:54     ` Pedro Alves
@ 2011-02-27 21:03       ` Michael Snyder
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Snyder @ 2011-02-27 21:03 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves wrote:
> On Friday 25 February 2011 21:45:39, Michael Snyder wrote:
> 
>> OK, a major re-write!   ;-)
> 
> Thanks.
> 
> I now noticed linespec.c:decode_dollar also does
> the same thing, another candidate for refactoring/reuse.

I'll look at it as a separate pass.

> What does the _ref mean in value_from_history_ref?

History reference.

>> +gdb_test "disable \$1foo" \
>> +    "Convenience variable must have integer value.*" \
>> +    "disable with badly formed history value"
> 
> This is not a badly formed history value.  It's a user
> convenience variable.  I'd make the test check that
> such convenience variables work as intended.

I did add such a test.

> Otherwise looked fine.  Thanks again.


Committed.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-02-27 20:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-24 19:12 [rfa] Make get_number_or_range accept value history references Michael Snyder
2011-02-25 11:59 ` Pedro Alves
2011-02-25 19:20   ` Michael Snyder
2011-02-25 22:10   ` Michael Snyder
2011-02-26 11:54     ` Pedro Alves
2011-02-27 21:03       ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox