#include "cli/cli-decode.h"
#include "exceptions.h"
#include "python/python.h"
-
+#include <ctype.h>
#include "tracepoint.h"
/* Prototypes for exported functions. */
for them to use. */
struct
{
- struct lval_funcs *funcs; /* Functions to call. */
- void *closure; /* Closure for those functions to use. */
+ /* Functions to call. */
+ const struct lval_funcs *funcs;
+
+ /* Closure for those functions to use. */
+ void *closure;
} computed;
} location;
struct value *
allocate_computed_value (struct type *type,
- struct lval_funcs *funcs,
+ const struct lval_funcs *funcs,
void *closure)
{
struct value *v = allocate_value_lazy (type);
return v;
}
+/* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */
+
+struct value *
+allocate_optimized_out_value (struct type *type)
+{
+ struct value *retval = allocate_value_lazy (type);
+
+ set_value_optimized_out (retval, 1);
+
+ return retval;
+}
+
/* Accessor methods. */
struct value *
value->pointed_to_offset = val;
}
-struct lval_funcs *
+const struct lval_funcs *
value_computed_funcs (struct value *v)
{
gdb_assert (VALUE_LVAL (v) == lval_computed);
if (VALUE_LVAL (val) == lval_computed)
{
- struct lval_funcs *funcs = val->location.computed.funcs;
+ const struct lval_funcs *funcs = val->location.computed.funcs;
if (funcs->free_closure)
funcs->free_closure (val);
value_incref (val->parent);
if (VALUE_LVAL (val) == lval_computed)
{
- struct lval_funcs *funcs = val->location.computed.funcs;
+ const struct lval_funcs *funcs = val->location.computed.funcs;
if (funcs->copy_closure)
val->location.computed.closure = funcs->copy_closure (val);
component->location = whole->location;
if (whole->lval == lval_computed)
{
- struct lval_funcs *funcs = whole->location.computed.funcs;
+ const struct lval_funcs *funcs = whole->location.computed.funcs;
if (funcs->copy_closure)
component->location.computed.closure = funcs->copy_closure (whole);
break;
case FIELD_LOC_KIND_PHYSNAME:
{
- char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
+ const char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
/* TYPE_FIELD_NAME (type, fieldno); */
struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0);
{
struct value *v;
struct type *ftype = TYPE_FN_FIELD_TYPE (f, j);
- char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
+ const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
struct symbol *sym;
struct minimal_symbol *msym;
return v;
}
+/* Create a value of type TYPE holding the contents CONTENTS.
+ The new value is `not_lval'. */
+
+struct value *
+value_from_contents (struct type *type, const gdb_byte *contents)
+{
+ struct value *result;
+
+ result = allocate_value (type);
+ memcpy (value_contents_raw (result), contents, TYPE_LENGTH (type));
+ return result;
+}
+
struct value *
value_from_double (struct type *type, DOUBLEST num)
{
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)
{