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.
This commit is contained in:
Michael Snyder
2011-02-27 20:57:16 +00:00
parent af62414197
commit 3bd0f5efd1
8 changed files with 240 additions and 34 deletions

View File

@@ -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, const gdb_byte *dec)
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)
{