+2015-07-28 Simon Marchi <simon.marchi@ericsson.com>
+
+ * c-valprint.c (c_val_print_array): Consider addressable memory
+ unit size.
+ (c_val_print_ptr): Likewise.
+ (c_val_print_int): Likewise.
+ * findvar.c (read_frame_register_value): Likewise.
+ * valarith.c (find_size_for_pointer_math): Likewise.
+ (value_ptrdiff): Likewise.
+ (value_subscripted_rvalue): Likewise.
+ * valops.c (read_value_memory): Likewise (and rename variables).
+ (value_assign): Likewise.
+ (value_repeat): Likewise.
+ (value_array): Likewise.
+ (value_slice): Likewise.
+ * valprint.c (generic_val_print_ptr): Likewise.
+ (generic_val_print_enum): Likewise.
+ (generic_val_print_bool): Likewise.
+ (generic_val_print_int): Likewise.
+ (generic_val_print_char): Likewise.
+ (generic_val_print_float): Likewise.
+ (generic_val_print_decfloat): Likewise.
+ (generic_val_print_complex): Likewise.
+ (val_print_scalar_formatted): Likewise.
+ (val_print_array_elements): Likewise.
+ * value.c (set_value_parent): Likewise.
+ (value_contents_copy_raw): Likewise.
+ (set_internalvar_component): Likewise.
+ (value_primitive_field): Likewise.
+ (value_fetch_lazy): Likewise.
+ * value.h (read_value_memory): Update comment.
+
2015-07-28 Simon Marchi <simon.marchi@ericsson.com>
* value.c (get_value_arch): New function.
{
struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
struct type *elttype = check_typedef (unresolved_elttype);
+ struct gdbarch *arch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (arch);
if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0)
{
for (temp_len = 0;
(temp_len < len
&& temp_len < options->print_max
- && extract_unsigned_integer (valaddr + embedded_offset
+ && extract_unsigned_integer (valaddr
+ + embedded_offset * unit_size
+ temp_len * eltlen,
eltlen, byte_order) != 0);
++temp_len)
if (temp_len == options->print_max && temp_len < len)
{
ULONGEST val
- = extract_unsigned_integer (valaddr + embedded_offset
+ = extract_unsigned_integer (valaddr
+ + embedded_offset * unit_size
+ temp_len * eltlen,
eltlen, byte_order);
if (val != 0)
}
LA_PRINT_STRING (stream, unresolved_elttype,
- valaddr + embedded_offset, len,
+ valaddr + embedded_offset * unit_size, len,
NULL, force_ellipses, options);
i = len;
}
const struct value *original_value,
const struct value_print_options *options)
{
+ struct gdbarch *arch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (arch);
+
if (options->format && options->format != 's')
{
val_print_scalar_formatted (type, valaddr, embedded_offset,
{
struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
struct type *elttype = check_typedef (unresolved_elttype);
- CORE_ADDR addr = unpack_pointer (type, valaddr + embedded_offset);
+ CORE_ADDR addr = unpack_pointer (type,
+ valaddr + embedded_offset * unit_size);
print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr,
embedded_offset, addr, stream, recurse, options);
struct ui_file *stream, const struct value *original_value,
const struct value_print_options *options)
{
+ struct gdbarch *arch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (arch);
+
if (options->format || options->output_format)
{
struct value_print_options opts = *options;
}
else
{
- val_print_type_code_int (type, valaddr + embedded_offset,
+ val_print_type_code_int (type, valaddr + embedded_offset * unit_size,
stream);
/* C and C++ has no single byte int type, char is used
instead. Since we don't know whether the value is really
if (c_textual_element_type (unresolved_type, options->format))
{
fputs_filtered (" ", stream);
- LA_PRINT_CHAR (unpack_long (type, valaddr + embedded_offset),
+ LA_PRINT_CHAR (unpack_long (type,
+ valaddr + embedded_offset * unit_size),
unresolved_type, stream);
}
}
int offset = 0;
int reg_offset = value_offset (value);
int regnum = VALUE_REGNUM (value);
- int len = TYPE_LENGTH (check_typedef (value_type (value)));
+ int len = type_length_units (check_typedef (value_type (value)));
gdb_assert (VALUE_LVAL (value) == lval_register);
while (len > 0)
{
struct value *regval = get_frame_register_value (frame, regnum);
- int reg_len = TYPE_LENGTH (value_type (regval)) - reg_offset;
+ int reg_len = type_length_units (value_type (regval)) - reg_offset;
/* If the register length is larger than the number of bytes
remaining to copy, then only copy the appropriate bytes. */
gdb_assert (TYPE_CODE (ptr_type) == TYPE_CODE_PTR);
ptr_target = check_typedef (TYPE_TARGET_TYPE (ptr_type));
- sz = TYPE_LENGTH (ptr_target);
+ sz = type_length_units (ptr_target);
if (sz == 0)
{
if (TYPE_CODE (ptr_type) == TYPE_CODE_VOID)
"second argument is neither\n"
"an integer nor a pointer of the same type."));
- sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
+ sz = type_length_units (check_typedef (TYPE_TARGET_TYPE (type1)));
if (sz == 0)
{
warning (_("Type size unknown, assuming 1. "
{
struct type *array_type = check_typedef (value_type (array));
struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
- unsigned int elt_size = TYPE_LENGTH (elt_type);
+ unsigned int elt_size = type_length_units (elt_type);
unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
struct value *v;
if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
- && elt_offs >= TYPE_LENGTH (array_type)))
+ && elt_offs >= type_length_units (array_type)))
error (_("no such vector element"));
if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
int stack, CORE_ADDR memaddr,
gdb_byte *buffer, size_t length)
{
- ULONGEST xfered = 0;
+ ULONGEST xfered_total = 0;
+ struct gdbarch *arch = get_value_arch (val);
+ int unit_size = gdbarch_addressable_memory_unit_size (arch);
- while (xfered < length)
+ while (xfered_total < length)
{
enum target_xfer_status status;
- ULONGEST xfered_len;
+ ULONGEST xfered_partial;
status = target_xfer_partial (current_target.beneath,
TARGET_OBJECT_MEMORY, NULL,
- buffer + xfered, NULL,
- memaddr + xfered, length - xfered,
- &xfered_len);
+ buffer + xfered_total * unit_size, NULL,
+ memaddr + xfered_total,
+ length - xfered_total,
+ &xfered_partial);
if (status == TARGET_XFER_OK)
/* nothing */;
else if (status == TARGET_XFER_UNAVAILABLE)
- mark_value_bytes_unavailable (val, embedded_offset + xfered,
- xfered_len);
+ mark_value_bytes_unavailable (val, embedded_offset + xfered_total,
+ xfered_partial);
else if (status == TARGET_XFER_EOF)
- memory_error (TARGET_XFER_E_IO, memaddr + xfered);
+ memory_error (TARGET_XFER_E_IO, memaddr + xfered_total);
else
- memory_error (status, memaddr + xfered);
+ memory_error (status, memaddr + xfered_total);
- xfered += xfered_len;
+ xfered_total += xfered_partial;
QUIT;
}
}
else
{
changed_addr = value_address (toval);
- changed_len = TYPE_LENGTH (type);
+ changed_len = type_length_units (type);
dest_buffer = value_contents (fromval);
}
read_value_memory (val, 0, value_stack (val), value_address (val),
value_contents_all_raw (val),
- TYPE_LENGTH (value_enclosing_type (val)));
+ type_length_units (value_enclosing_type (val)));
return val;
}
{
error (_("bad array bounds (%d, %d)"), lowbound, highbound);
}
- typelength = TYPE_LENGTH (value_enclosing_type (elemvec[0]));
+ typelength = type_length_units (value_enclosing_type (elemvec[0]));
for (idx = 1; idx < nelem; idx++)
{
- if (TYPE_LENGTH (value_enclosing_type (elemvec[idx])) != typelength)
+ if (type_length_units (value_enclosing_type (elemvec[idx]))
+ != typelength)
{
error (_("array elements must all be the same size"));
}
{
slice = allocate_value (slice_type);
value_contents_copy (slice, 0, array, offset,
- TYPE_LENGTH (slice_type));
+ type_length_units (slice_type));
}
set_value_component_location (slice, array);
const struct value *original_value,
const struct value_print_options *options)
{
+ struct gdbarch *gdbarch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+
if (options->format && options->format != 's')
{
val_print_scalar_formatted (type, valaddr, embedded_offset,
{
struct type *unresolved_elttype = TYPE_TARGET_TYPE(type);
struct type *elttype = check_typedef (unresolved_elttype);
- CORE_ADDR addr = unpack_pointer (type, valaddr + embedded_offset);
+ CORE_ADDR addr = unpack_pointer (type,
+ valaddr + embedded_offset * unit_size);
print_unpacked_pointer (type, elttype, addr, stream, options);
}
unsigned int i;
unsigned int len;
LONGEST val;
+ struct gdbarch *gdbarch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
if (options->format)
{
return;
}
len = TYPE_NFIELDS (type);
- val = unpack_long (type, valaddr + embedded_offset);
+ val = unpack_long (type, valaddr + embedded_offset * unit_size);
for (i = 0; i < len; i++)
{
QUIT;
const struct generic_val_print_decorations *decorations)
{
LONGEST val;
+ struct gdbarch *gdbarch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
if (options->format || options->output_format)
{
}
else
{
- val = unpack_long (type, valaddr + embedded_offset);
+ val = unpack_long (type, valaddr + embedded_offset * unit_size);
if (val == 0)
fputs_filtered (decorations->false_name, stream);
else if (val == 1)
const struct value *original_value,
const struct value_print_options *options)
{
+ struct gdbarch *gdbarch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+
if (options->format || options->output_format)
{
struct value_print_options opts = *options;
original_value, &opts, 0, stream);
}
else
- val_print_type_code_int (type, valaddr + embedded_offset, stream);
+ val_print_type_code_int (type, valaddr + embedded_offset * unit_size,
+ stream);
}
/* generic_val_print helper for TYPE_CODE_CHAR. */
const struct value_print_options *options)
{
LONGEST val;
+ struct gdbarch *gdbarch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
if (options->format || options->output_format)
{
}
else
{
- val = unpack_long (type, valaddr + embedded_offset);
+ val = unpack_long (type, valaddr + embedded_offset * unit_size);
if (TYPE_UNSIGNED (type))
fprintf_filtered (stream, "%u", (unsigned int) val);
else
const struct value *original_value,
const struct value_print_options *options)
{
+ struct gdbarch *gdbarch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+
if (options->format)
{
val_print_scalar_formatted (type, valaddr, embedded_offset,
}
else
{
- print_floating (valaddr + embedded_offset, type, stream);
+ print_floating (valaddr + embedded_offset * unit_size, type, stream);
}
}
const struct value *original_value,
const struct value_print_options *options)
{
+ struct gdbarch *gdbarch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+
if (options->format)
val_print_scalar_formatted (type, valaddr, embedded_offset, original_value,
options, 0, stream);
else
- print_decimal_floating (valaddr + embedded_offset, type, stream);
+ print_decimal_floating (valaddr + embedded_offset * unit_size, type,
+ stream);
}
/* generic_val_print helper for TYPE_CODE_COMPLEX. */
const struct generic_val_print_decorations
*decorations)
{
+ struct gdbarch *gdbarch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+
fprintf_filtered (stream, "%s", decorations->complex_prefix);
if (options->format)
val_print_scalar_formatted (TYPE_TARGET_TYPE (type), valaddr,
embedded_offset, original_value, options, 0,
stream);
else
- print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type),
- stream);
+ print_floating (valaddr + embedded_offset * unit_size,
+ TYPE_TARGET_TYPE (type), stream);
fprintf_filtered (stream, "%s", decorations->complex_infix);
if (options->format)
val_print_scalar_formatted (TYPE_TARGET_TYPE (type), valaddr,
embedded_offset
- + TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
+ + type_length_units (TYPE_TARGET_TYPE (type)),
original_value, options, 0, stream);
else
- print_floating (valaddr + embedded_offset
+ print_floating (valaddr + embedded_offset * unit_size
+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
TYPE_TARGET_TYPE (type), stream);
fprintf_filtered (stream, "%s", decorations->complex_suffix);
int size,
struct ui_file *stream)
{
+ struct gdbarch *arch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (arch);
+
gdb_assert (val != NULL);
gdb_assert (valaddr == value_contents_for_printing_const (val));
else if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))
val_print_unavailable (stream);
else
- print_scalar_formatted (valaddr + embedded_offset, type,
+ print_scalar_formatted (valaddr + embedded_offset * unit_size, type,
options, size, stream);
}
LONGEST low_pos, high_pos;
elttype = TYPE_TARGET_TYPE (type);
- eltlen = TYPE_LENGTH (check_typedef (elttype));
+ eltlen = type_length_units (check_typedef (elttype));
index_type = TYPE_INDEX_TYPE (type);
if (get_array_bounds (type, &low_bound, &high_bound))
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 *
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
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
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,
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;
{
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);
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))
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));
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)
{
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)
{
const struct value *val2, int offset2,
int length);
-/* Read LENGTH bytes of memory starting at MEMADDR into BUFFER, which
- is (or will be copied to) VAL's contents buffer offset by
+/* Read LENGTH addressable memory units starting at MEMADDR into BUFFER,
+ which is (or will be copied to) VAL's contents buffer offset by
EMBEDDED_OFFSET (that is, to &VAL->contents[EMBEDDED_OFFSET]).
Marks value contents ranges as unavailable if the corresponding
memory is likewise unavailable. STACK indicates whether the memory