aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog16
-rw-r--r--gdb/ada-lang.c2
-rw-r--r--gdb/findvar.c26
-rw-r--r--gdb/valarith.c2
-rw-r--r--gdb/valops.c40
-rw-r--r--gdb/value.c10
-rw-r--r--gdb/value.h8
7 files changed, 86 insertions, 18 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 36f5670..7dbdef0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,21 @@
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.
2008-04-29 Joel Brobecker <brobecker@adacore.com>
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 01f8bbd..d6441c4 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2039,7 +2039,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
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);
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 4e1f6d1..69fb6fb 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -281,6 +281,30 @@ value_of_register (int regnum, struct frame_info *frame)
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
@@ -695,7 +719,7 @@ locate_var_value (struct symbol *var, struct frame_info *frame)
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;
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 7e6b66e..34bacaa 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -270,7 +270,7 @@ value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound
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),
diff --git a/gdb/valops.c b/gdb/valops.c
index b11a088..7f9868c 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -611,12 +611,38 @@ value_at_lazy (struct type *type, CORE_ADDR addr)
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;
@@ -1464,7 +1490,7 @@ search_struct_field (char *name, struct value *arg1, int offset,
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),
@@ -2859,7 +2885,7 @@ value_slice (struct value *array, int lowbound, int length)
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),
diff --git a/gdb/value.c b/gdb/value.c
index 2cb989d..52d0030 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -137,9 +137,9 @@ struct value
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
@@ -1353,7 +1353,7 @@ value_primitive_field (struct value *arg1, int offset,
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),
@@ -1367,7 +1367,7 @@ value_primitive_field (struct value *arg1, int offset,
/* 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),
diff --git a/gdb/value.h b/gdb/value.h
index 731b6be..f75f7dd 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -135,9 +135,9 @@ extern int value_embedded_offset (struct value *value);
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
@@ -301,6 +301,8 @@ extern struct value *value_of_variable (struct symbol *var, struct block *b);
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,