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/valarith.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/valarith.c')
-rw-r--r-- | gdb/valarith.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c index 0162c10..3e349f2 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -54,7 +54,7 @@ find_size_for_pointer_math (struct type *ptr_type) 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) @@ -121,7 +121,7 @@ value_ptrdiff (struct value *arg1, struct value *arg2) "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. " @@ -192,12 +192,12 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound) { 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)) |