aboutsummaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index 5e5c4ed..b64cb21 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -565,6 +565,32 @@ value_one (struct type *type, enum lval_type lv)
return val;
}
+/* Helper function for value_at, value_at_lazy, and value_at_lazy_stack. */
+
+static struct value *
+get_value_at (struct type *type, CORE_ADDR addr, int lazy)
+{
+ struct value *val;
+
+ if (TYPE_CODE (check_typedef (type)) == TYPE_CODE_VOID)
+ error (_("Attempt to dereference a generic pointer."));
+
+ if (lazy)
+ {
+ val = allocate_value_lazy (type);
+ }
+ else
+ {
+ val = allocate_value (type);
+ read_memory (addr, value_contents_all_raw (val), TYPE_LENGTH (type));
+ }
+
+ VALUE_LVAL (val) = lval_memory;
+ set_value_address (val, addr);
+
+ return val;
+}
+
/* Return a value with type TYPE located at ADDR.
Call value_at only if the data needs to be fetched immediately;
@@ -580,19 +606,7 @@ value_one (struct type *type, enum lval_type lv)
struct value *
value_at (struct type *type, CORE_ADDR addr)
{
- struct value *val;
-
- if (TYPE_CODE (check_typedef (type)) == TYPE_CODE_VOID)
- error (_("Attempt to dereference a generic pointer."));
-
- val = allocate_value (type);
-
- read_memory (addr, value_contents_all_raw (val), TYPE_LENGTH (type));
-
- VALUE_LVAL (val) = lval_memory;
- set_value_address (val, addr);
-
- return val;
+ return get_value_at (type, addr, 0);
}
/* Return a lazy value with type TYPE located at ADDR (cf. value_at). */
@@ -600,17 +614,7 @@ value_at (struct type *type, CORE_ADDR addr)
struct value *
value_at_lazy (struct type *type, CORE_ADDR addr)
{
- struct value *val;
-
- if (TYPE_CODE (check_typedef (type)) == TYPE_CODE_VOID)
- error (_("Attempt to dereference a generic pointer."));
-
- val = allocate_value_lazy (type);
-
- VALUE_LVAL (val) = lval_memory;
- set_value_address (val, addr);
-
- return val;
+ return get_value_at (type, addr, 1);
}
/* Called only from the value_contents and value_contents_all()
@@ -656,7 +660,12 @@ value_fetch_lazy (struct value *val)
int length = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
if (length)
- read_memory (addr, value_contents_all_raw (val), length);
+ {
+ if (value_stack (val))
+ read_stack (addr, value_contents_all_raw (val), length);
+ else
+ read_memory (addr, value_contents_all_raw (val), length);
+ }
}
else if (VALUE_LVAL (val) == lval_register)
{