diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2015-07-28 11:01:50 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2015-07-28 11:01:50 -0400 |
commit | 3ae385afe150f2e001a1cc8fb14f4ba0ab94cdf2 (patch) | |
tree | 0984430c0197e8fb667866605cac82e050fd8ce5 /gdb/valops.c | |
parent | e512cdbdffafefa63baeb835ba6636fcef56e17d (diff) | |
download | gdb-3ae385afe150f2e001a1cc8fb14f4ba0ab94cdf2.zip gdb-3ae385afe150f2e001a1cc8fb14f4ba0ab94cdf2.tar.gz gdb-3ae385afe150f2e001a1cc8fb14f4ba0ab94cdf2.tar.bz2 |
Consider addressable memory unit size in various value functions
This patch updates various value handling functions to make them
consider the addressable memory unit size of the current architecture.
This allows to correctly extract and print values on architectures whose
addressable memory unit is not 8 bits.
The patch doesn't cover all the code that would ideally need to be
adjusted, only the code paths that we happen to use, plus a few obvious
ones. Specifically, those areas are not covered by this patch:
- Management of unavailable bits
- Bitfields
- C++ stuff
Regression-tested on x86-64 Ubuntu 14.04. I saw no related test result
change.
gdb/ChangeLog:
* 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.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r-- | gdb/valops.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/gdb/valops.c b/gdb/valops.c index d68e9f3..dac0274 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -958,30 +958,33 @@ read_value_memory (struct value *val, int embedded_offset, 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; } } @@ -1089,7 +1092,7 @@ value_assign (struct value *toval, struct value *fromval) else { changed_addr = value_address (toval); - changed_len = TYPE_LENGTH (type); + changed_len = type_length_units (type); dest_buffer = value_contents (fromval); } @@ -1280,7 +1283,7 @@ value_repeat (struct value *arg1, int count) 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; } @@ -1606,10 +1609,11 @@ value_array (int lowbound, int highbound, struct value **elemvec) { 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")); } @@ -3812,7 +3816,7 @@ value_slice (struct value *array, int lowbound, int length) { 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); |