value_lazy for memory lvals.
* findvar.c (value_of_register_lazy): New function.
(locate_var_value): Only check value_lazy for memory lvals.
* valarith.c (value_subscripted_rvalue): Likewise.
* valops.c (value_fetch_lazy): Handle both memory and register
lvals.
(search_struct_field, value_slice): Only check value_lazy for memory
lvals.
* value.c (struct value): Update comment for lazy.
(value_primitive_field): Only check value_lazy for memory lvals.
* value.h (value_lazy): Update comment.
(value_of_register_lazy): Declare.
+2008-04-30 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * ada-lang.c (ada_value_primitive_packed_val): Only check
+ value_lazy for memory lvals.
+ * findvar.c (value_of_register_lazy): New function.
+ (locate_var_value): Only check value_lazy for memory lvals.
+ * valarith.c (value_subscripted_rvalue): Likewise.
+ * valops.c (value_fetch_lazy): Handle both memory and register
+ lvals.
+ (search_struct_field, value_slice): Only check value_lazy for memory
+ lvals.
+ * value.c (struct value): Update comment for lazy.
+ (value_primitive_field): Only check value_lazy for memory lvals.
+ * value.h (value_lazy): Update comment.
+ (value_of_register_lazy): Declare.
+
2008-04-30 Daniel Jacobowitz <dan@codesourcery.com>
* corefile.c (reopen_exec_file): Close any open files.
v = allocate_value (type);
bytes = (unsigned char *) (valaddr + offset);
}
- else if (value_lazy (obj))
+ else if (VALUE_LVAL (obj) == lval_memory && value_lazy (obj))
{
v = value_at (type,
VALUE_ADDRESS (obj) + value_offset (obj) + offset);
return reg_val;
}
+/* Return a `value' with the contents of (virtual or cooked) register
+ REGNUM as found in the specified FRAME. The register's type is
+ determined by register_type(). The value is not fetched. */
+
+struct value *
+value_of_register_lazy (struct frame_info *frame, int regnum)
+{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct value *reg_val;
+
+ gdb_assert (regnum < (gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch)));
+
+ /* We should have a valid (i.e. non-sentinel) frame. */
+ gdb_assert (frame_id_p (get_frame_id (frame)));
+
+ reg_val = allocate_value (register_type (gdbarch, regnum));
+ VALUE_LVAL (reg_val) = lval_register;
+ VALUE_REGNUM (reg_val) = regnum;
+ VALUE_FRAME_ID (reg_val) = get_frame_id (frame);
+ set_value_lazy (reg_val, 1);
+ return reg_val;
+}
+
/* Given a pointer of type TYPE in target form in BUF, return the
address it represents. */
CORE_ADDR
if (lazy_value == 0)
error (_("Address of \"%s\" is unknown."), SYMBOL_PRINT_NAME (var));
- if (value_lazy (lazy_value)
+ if ((VALUE_LVAL (lazy_value) == lval_memory && value_lazy (lazy_value))
|| TYPE_CODE (type) == TYPE_CODE_FUNC)
{
struct value *val;
error (_("no such vector element"));
v = allocate_value (elt_type);
- if (value_lazy (array))
+ if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
set_value_lazy (v, 1);
else
memcpy (value_contents_writeable (v),
int
value_fetch_lazy (struct value *val)
{
- CORE_ADDR addr = VALUE_ADDRESS (val) + value_offset (val);
- int length = TYPE_LENGTH (value_enclosing_type (val));
+ if (VALUE_LVAL (val) == lval_memory)
+ {
+ CORE_ADDR addr = VALUE_ADDRESS (val) + value_offset (val);
+ int length = TYPE_LENGTH (value_enclosing_type (val));
+
+ struct type *type = value_type (val);
+ if (length)
+ read_memory (addr, value_contents_all_raw (val), length);
+ }
+ else if (VALUE_LVAL (val) == lval_register)
+ {
+ struct frame_info *frame = frame_find_by_id (VALUE_FRAME_ID (val));
+ int regnum = VALUE_REGNUM (val);
+ struct type *type = check_typedef (value_type (val));
- struct type *type = value_type (val);
- if (length)
- read_memory (addr, value_contents_all_raw (val), length);
+ gdb_assert (frame != NULL);
+
+ /* Convertible register routines are used for multi-register
+ values and for interpretation in different types (e.g. float
+ or int from a double register). Lazy register values should
+ have the register's natural type, so they do not apply. */
+ gdb_assert (!gdbarch_convert_register_p (get_frame_arch (frame), regnum,
+ type));
+
+ /* Get the data. */
+ if (!get_frame_register_bytes (frame, regnum, value_offset (val),
+ TYPE_LENGTH (value_type (val)),
+ value_contents_raw (val)))
+ set_value_optimized_out (val, 1);
+ }
+ else
+ internal_error (__FILE__, __LINE__, "Unexpected lazy value type.");
set_value_lazy (val, 0);
return 0;
VALUE_ADDRESS (v2) = VALUE_ADDRESS (arg1);
VALUE_FRAME_ID (v2) = VALUE_FRAME_ID (arg1);
set_value_offset (v2, value_offset (arg1) + boffset);
- if (value_lazy (arg1))
+ if (VALUE_LVAL (arg1) == lval_memory && value_lazy (arg1))
set_value_lazy (v2, 1);
else
memcpy (value_contents_raw (v2),
TYPE_CODE (slice_type) = TYPE_CODE (array_type);
slice = allocate_value (slice_type);
- if (value_lazy (array))
+ if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
set_value_lazy (slice, 1);
else
memcpy (value_contents_writeable (slice),
short regnum;
/* If zero, contents of this value are in the contents field. If
- nonzero, contents are in inferior memory at address in the
- location.address field plus the offset field (and the lval field
- should be lval_memory).
+ nonzero, contents are in inferior. If the lval field is lval_memory,
+ the contents are in inferior memory at location.address plus offset.
+ The lval field may also be lval_register.
WARNING: This field is used by the code which handles watchpoints
(see breakpoint.c) to decide whether a particular value can be
bases, etc. */
v = allocate_value (value_enclosing_type (arg1));
v->type = type;
- if (value_lazy (arg1))
+ if (VALUE_LVAL (arg1) == lval_memory && value_lazy (arg1))
set_value_lazy (v, 1);
else
memcpy (value_contents_all_raw (v), value_contents_all_raw (arg1),
/* Plain old data member */
offset += TYPE_FIELD_BITPOS (arg_type, fieldno) / 8;
v = allocate_value (type);
- if (value_lazy (arg1))
+ if (VALUE_LVAL (arg1) == lval_memory && value_lazy (arg1))
set_value_lazy (v, 1);
else
memcpy (value_contents_raw (v),
extern void set_value_embedded_offset (struct value *value, int val);
/* If zero, contents of this value are in the contents field. If
- nonzero, contents are in inferior memory at address in the
- location.address field plus the offset field (and the lval field
- should be lval_memory).
+ nonzero, contents are in inferior. If the lval field is lval_memory,
+ the contents are in inferior memory at location.address plus offset.
+ The lval field may also be lval_register.
WARNING: This field is used by the code which handles watchpoints
(see breakpoint.c) to decide whether a particular value can be
extern struct value *value_of_register (int regnum, struct frame_info *frame);
+struct value *value_of_register_lazy (struct frame_info *frame, int regnum);
+
extern int symbol_read_needs_frame (struct symbol *);
extern struct value *read_var_value (struct symbol *var,