aboutsummaryrefslogtreecommitdiff
path: root/gdb/value.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/value.c')
-rw-r--r--gdb/value.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/gdb/value.c b/gdb/value.c
index 0d540d5..2f0b2cc 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1091,8 +1091,11 @@ set_value_parent (struct value *value, struct value *parent)
gdb_byte *
value_contents_raw (struct value *value)
{
+ struct gdbarch *arch = get_value_arch (value);
+ int unit_size = gdbarch_addressable_memory_unit_size (arch);
+
allocate_value_contents (value);
- return value->contents + value->embedded_offset;
+ return value->contents + value->embedded_offset * unit_size;
}
gdb_byte *
@@ -1242,7 +1245,7 @@ value_ranges_copy_adjusted (struct value *dst, int dst_bit_offset,
bit_length);
}
-/* Copy LENGTH bytes of SRC value's (all) contents
+/* Copy LENGTH target addressable memory units of SRC value's (all) contents
(value_contents_all) starting at SRC_OFFSET, into DST value's (all)
contents, starting at DST_OFFSET. If unavailable contents are
being copied from SRC, the corresponding DST contents are marked
@@ -1257,8 +1260,9 @@ value_contents_copy_raw (struct value *dst, int dst_offset,
struct value *src, int src_offset, int length)
{
range_s *r;
- int i;
int src_bit_offset, dst_bit_offset, bit_length;
+ struct gdbarch *arch = get_value_arch (src);
+ int unit_size = gdbarch_addressable_memory_unit_size (arch);
/* A lazy DST would make that this copy operation useless, since as
soon as DST's contents were un-lazied (by a later value_contents
@@ -1275,14 +1279,14 @@ value_contents_copy_raw (struct value *dst, int dst_offset,
TARGET_CHAR_BIT * length));
/* Copy the data. */
- memcpy (value_contents_all_raw (dst) + dst_offset,
- value_contents_all_raw (src) + src_offset,
- length);
+ memcpy (value_contents_all_raw (dst) + dst_offset * unit_size,
+ value_contents_all_raw (src) + src_offset * unit_size,
+ length * unit_size);
/* Copy the meta-data, adjusted. */
- src_bit_offset = src_offset * TARGET_CHAR_BIT;
- dst_bit_offset = dst_offset * TARGET_CHAR_BIT;
- bit_length = length * TARGET_CHAR_BIT;
+ src_bit_offset = src_offset * unit_size * HOST_CHAR_BIT;
+ dst_bit_offset = dst_offset * unit_size * HOST_CHAR_BIT;
+ bit_length = length * unit_size * HOST_CHAR_BIT;
value_ranges_copy_adjusted (dst, dst_bit_offset,
src, src_bit_offset,
@@ -2279,17 +2283,21 @@ set_internalvar_component (struct internalvar *var, int offset, int bitpos,
int bitsize, struct value *newval)
{
gdb_byte *addr;
+ struct gdbarch *arch;
+ int unit_size;
switch (var->kind)
{
case INTERNALVAR_VALUE:
addr = value_contents_writeable (var->u.value);
+ arch = get_value_arch (var->u.value);
+ unit_size = gdbarch_addressable_memory_unit_size (arch);
if (bitsize)
modify_field (value_type (var->u.value), addr + offset,
value_as_long (newval), bitpos, bitsize);
else
- memcpy (addr + offset, value_contents (newval),
+ memcpy (addr + offset * unit_size, value_contents (newval),
TYPE_LENGTH (value_type (newval)));
break;
@@ -3000,6 +3008,8 @@ value_primitive_field (struct value *arg1, int offset,
{
struct value *v;
struct type *type;
+ struct gdbarch *arch = get_value_arch (arg1);
+ int unit_size = gdbarch_addressable_memory_unit_size (arch);
arg_type = check_typedef (arg_type);
type = TYPE_FIELD_TYPE (arg_type, fieldno);
@@ -3078,7 +3088,8 @@ value_primitive_field (struct value *arg1, int offset,
else
{
/* Plain old data member */
- offset += TYPE_FIELD_BITPOS (arg_type, fieldno) / 8;
+ offset += (TYPE_FIELD_BITPOS (arg_type, fieldno)
+ / (HOST_CHAR_BIT * unit_size));
/* Lazy register values with offsets are not supported. */
if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1))
@@ -3091,7 +3102,7 @@ value_primitive_field (struct value *arg1, int offset,
v = allocate_value (type);
value_contents_copy_raw (v, value_embedded_offset (v),
arg1, value_embedded_offset (arg1) + offset,
- TYPE_LENGTH (type));
+ type_length_units (type));
}
v->offset = (value_offset (arg1) + offset
+ value_embedded_offset (arg1));
@@ -3833,7 +3844,7 @@ value_fetch_lazy (struct value *val)
if (TYPE_LENGTH (type))
read_value_memory (val, 0, value_stack (val),
addr, value_contents_all_raw (val),
- TYPE_LENGTH (type));
+ type_length_units (type));
}
else if (VALUE_LVAL (val) == lval_register)
{
@@ -3892,7 +3903,7 @@ value_fetch_lazy (struct value *val)
set_value_lazy (val, 0);
value_contents_copy (val, value_embedded_offset (val),
new_val, value_embedded_offset (new_val),
- TYPE_LENGTH (type));
+ type_length_units (type));
if (frame_debug)
{