aboutsummaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
authorJerome Guitton <guitton@adacore.com>2008-11-26 16:27:28 +0000
committerJerome Guitton <guitton@adacore.com>2008-11-26 16:27:28 +0000
commit3e3d7139eef55bf54263b7385858bcdd2b239415 (patch)
tree525918de5f68b51df4098fbe0da15d42233cecad /gdb/valops.c
parent508e676df1a21a34a1b53b004bed87a3358d776b (diff)
downloadgdb-3e3d7139eef55bf54263b7385858bcdd2b239415.zip
gdb-3e3d7139eef55bf54263b7385858bcdd2b239415.tar.gz
gdb-3e3d7139eef55bf54263b7385858bcdd2b239415.tar.bz2
* value.h (allocate_value_lazy): New function declaration.
(value_free): Remove macro, make it a function. * value.c (value): Move actual content outside of the memory space of the struct; add a pointer to this actual content. (allocate_value_lazy, allocate_value_contents): New function. (allocate_value): Reimplement using these two new functions. (value_contents_raw, value_contents_all_raw): If no memory has been allocated yet for the actual content, allocate it. (value_contents_all): Resync with struct value's changes. (value_free): New function. (value_copy, value_primitive_field): Use new function allocate_value_lazy to allocate lazy values. (value_change_enclosing_type): Resync with struct value's changes. As the value is not reallocated, remove the special handling for the value chain (now obsolete). * valops.c (value_at_lazy): Use new function allocate_value_lazy. (value_fetch_lazy): Allocate value content. Use allocate_value_lazy to allocate lazy values. (value_slice): Use allocate_value_lazy to allocate lazy values.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index 0c539c1..05e5351 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -608,11 +608,10 @@ value_at_lazy (struct type *type, CORE_ADDR addr)
if (TYPE_CODE (check_typedef (type)) == TYPE_CODE_VOID)
error (_("Attempt to dereference a generic pointer."));
- val = allocate_value (type);
+ val = allocate_value_lazy (type);
VALUE_LVAL (val) = lval_memory;
VALUE_ADDRESS (val) = addr;
- set_value_lazy (val, 1);
return val;
}
@@ -634,6 +633,8 @@ value_at_lazy (struct type *type, CORE_ADDR addr)
int
value_fetch_lazy (struct value *val)
{
+ gdb_assert (value_lazy (val));
+ allocate_value_contents (val);
if (VALUE_LVAL (val) == lval_memory)
{
CORE_ADDR addr = VALUE_ADDRESS (val) + value_offset (val);
@@ -1535,7 +1536,7 @@ search_struct_field (char *name, struct value *arg1, int offset,
if (BASETYPE_VIA_VIRTUAL (type, i))
{
int boffset;
- struct value *v2 = allocate_value (basetype);
+ struct value *v2;
boffset = baseclass_offset (type, i,
value_contents (arg1) + offset,
@@ -1553,6 +1554,7 @@ search_struct_field (char *name, struct value *arg1, int offset,
{
CORE_ADDR base_addr;
+ v2 = allocate_value (basetype);
base_addr =
VALUE_ADDRESS (arg1) + value_offset (arg1) + boffset;
if (target_read_memory (base_addr,
@@ -1564,16 +1566,19 @@ search_struct_field (char *name, struct value *arg1, int offset,
}
else
{
+ if (VALUE_LVAL (arg1) == lval_memory && value_lazy (arg1))
+ v2 = allocate_value_lazy (basetype);
+ else
+ {
+ v2 = allocate_value (basetype);
+ memcpy (value_contents_raw (v2),
+ value_contents_raw (arg1) + boffset,
+ TYPE_LENGTH (basetype));
+ }
VALUE_LVAL (v2) = VALUE_LVAL (arg1);
VALUE_ADDRESS (v2) = VALUE_ADDRESS (arg1);
VALUE_FRAME_ID (v2) = VALUE_FRAME_ID (arg1);
set_value_offset (v2, value_offset (arg1) + boffset);
- if (VALUE_LVAL (arg1) == lval_memory && value_lazy (arg1))
- set_value_lazy (v2, 1);
- else
- memcpy (value_contents_raw (v2),
- value_contents_raw (arg1) + boffset,
- TYPE_LENGTH (basetype));
}
if (found_baseclass)
@@ -2969,13 +2974,15 @@ value_slice (struct value *array, int lowbound, int length)
slice_range_type);
TYPE_CODE (slice_type) = TYPE_CODE (array_type);
- slice = allocate_value (slice_type);
if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
- set_value_lazy (slice, 1);
+ slice = allocate_value_lazy (slice_type);
else
- memcpy (value_contents_writeable (slice),
- value_contents (array) + offset,
- TYPE_LENGTH (slice_type));
+ {
+ slice = allocate_value (slice_type);
+ memcpy (value_contents_writeable (slice),
+ value_contents (array) + offset,
+ TYPE_LENGTH (slice_type));
+ }
if (VALUE_LVAL (array) == lval_internalvar)
VALUE_LVAL (slice) = lval_internalvar_component;