aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-valprint.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2015-07-28 11:01:50 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2015-07-28 11:01:50 -0400
commit3ae385afe150f2e001a1cc8fb14f4ba0ab94cdf2 (patch)
tree0984430c0197e8fb667866605cac82e050fd8ce5 /gdb/c-valprint.c
parente512cdbdffafefa63baeb835ba6636fcef56e17d (diff)
downloadgdb-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/c-valprint.c')
-rw-r--r--gdb/c-valprint.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 2009e95..0cf2d7d 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -236,6 +236,8 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr,
{
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)
{
@@ -276,7 +278,8 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr,
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)
@@ -288,7 +291,8 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr,
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)
@@ -299,7 +303,7 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr,
}
LA_PRINT_STRING (stream, unresolved_elttype,
- valaddr + embedded_offset, len,
+ valaddr + embedded_offset * unit_size, len,
NULL, force_ellipses, options);
i = len;
}
@@ -342,6 +346,9 @@ c_val_print_ptr (struct type *type, const gdb_byte *valaddr,
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,
@@ -363,7 +370,8 @@ c_val_print_ptr (struct type *type, const gdb_byte *valaddr,
{
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);
@@ -430,6 +438,9 @@ c_val_print_int (struct type *type, struct type *unresolved_type,
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;
@@ -441,7 +452,7 @@ c_val_print_int (struct type *type, struct type *unresolved_type,
}
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
@@ -450,7 +461,8 @@ c_val_print_int (struct type *type, struct type *unresolved_type,
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);
}
}