diff options
author | Michael Snyder <msnyder@vmware.com> | 2011-02-27 20:57:16 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2011-02-27 20:57:16 +0000 |
commit | 3bd0f5efd1910d53733ff9962deee99d7e45d1de (patch) | |
tree | f3f77fd22027a884f5bc951c09d9988eae80f4a3 /gdb/value.c | |
parent | af62414197efc46568bd459473b4a22da42d2132 (diff) | |
download | gdb-3bd0f5efd1910d53733ff9962deee99d7e45d1de.zip gdb-3bd0f5efd1910d53733ff9962deee99d7e45d1de.tar.gz gdb-3bd0f5efd1910d53733ff9962deee99d7e45d1de.tar.bz2 |
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.
Diffstat (limited to 'gdb/value.c')
-rw-r--r-- | gdb/value.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/gdb/value.c b/gdb/value.c index 011b5e7..2acb1df 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -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) { |