summaryrefslogtreecommitdiff
path: root/gdb/p-valprint.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@codesourcery.com>2011-01-24 18:54:13 +0000
committerPedro Alves <pedro@codesourcery.com>2011-01-24 18:54:13 +0000
commitbc164ebe2a8cc9ee4f3831ffece97ddc9aa73439 (patch)
tree496bb7540c84a55d76b7206fbb8792a0cebe0f0c /gdb/p-valprint.c
parentb8ab6989f1a3bf5ee737b1ff6752772474c46dcd (diff)
downloadgdb-bc164ebe2a8cc9ee4f3831ffece97ddc9aa73439.tar.gz
2011-01-24 Pedro Alves <pedro@codesourcery.com>
Don't lose embedded_offset in printing routines throughout. gdb/ * valprint.h (val_print_array_elements): Change prototype. * valprint.c (val_print_array_elements): Add `embedded_offset' parameter, and adjust to pass it down to val_print, while passing `valaddr' or `address' unmodified. Take embedded_offset into account when checking repetitions. * c-valprint.c (c_val_print): Pass embedded_offset to val_print_array_elements instead of adjusting `valaddr' and `address'. * m2-valprint.c (m2_print_array_contents, m2_val_print): Pass embedded_offset to val_print_array_elements instead of adjusting `valaddr'. * p-lang.h (pascal_object_print_value_fields): Adjust prototype. * p-valprint.c (pascal_val_print): Pass embedded_offset to val_print_array_elements and pascal_object_print_value_fields instead of adjusting `valaddr'. (pascal_object_print_value_fields): Add `offset' parameter, and adjust to use it. (pascal_object_print_value): Add `offset' parameter, and adjust to use it. (pascal_object_print_static_field): Use value_contents_for_printing/value_embedded_offset, rather than value_contents. * ada-valprint.c (val_print_packed_array_elements): Add `offset' parameter, and adjust to use it. Use value_contents_for_printing/value_embedded_offset, rather than value_contents. (ada_val_print): Rename `valaddr0' parameter to `valaddr'. (ada_val_print_array): Add `offset' parameter, and adjust to use it. (ada_val_print_1): Rename `valaddr0' parameter to `valaddr', and `embedded_offset' to `offset'. Don't re-adjust `valaddr'. Instead work with offsets. Use value_contents_for_printing/value_embedded_offset, rather than value_contents. Change `defer_val_int' local type to CORE_ADDR, and use value_from_pointer to extract a target pointer, rather than value_from_longest. (print_variant_part): Add `offset' parameter. Replace `outer_valaddr' parameter by a new `outer_offset' parameter. Don't re-adjust `valaddr'. Instead pass down adjusted offsets. (ada_value_print): Use value_contents_for_printing/value_embedded_offset, rather than value_contents. (print_record): Add `offset' parameter, and adjust to pass it down. (print_field_values): Add `offset' parameter. Replace `outer_valaddr' parameter by a new `outer_offset' parameter. Don't re-adjust `valaddr'. Instead pass down adjusted offsets. Use value_contents_for_printing/value_embedded_offset, rather than value_contents. * d-valprint.c (dynamic_array_type): Use value_contents_for_printing/value_embedded_offset, rather than value_contents. * jv-valprint.c (java_print_value_fields): Add `offset' parameter. Don't re-adjust `valaddr'. Instead pass down adjusted offsets. (java_print_value_fields): Take `offset' into account. Don't re-adjust `valaddr'. Instead pass down adjusted offsets. (java_val_print): Take `embedded_offset' into account. Pass it to java_print_value_fields. * f-valprint.c (f77_print_array_1): Add `embedded_offset' parameter. Don't re-adjust `valaddr' or `address'. Instead pass down adjusted offsets. (f77_print_array): Add `embedded_offset' parameter. Pass it down. (f_val_print): Take `embedded_offset' into account. gdb/testsuite/ * gdb.base/printcmds.c (some_struct): New struct and instance. * gdb.base/printcmds.exp (test_print_repeats_embedded_array): New procedure. <global scope>: Call it.
Diffstat (limited to 'gdb/p-valprint.c')
-rw-r--r--gdb/p-valprint.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index e993c05c3f2..34decb97f08 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -125,7 +125,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
{
i = 0;
}
- val_print_array_elements (type, valaddr + embedded_offset,
+ val_print_array_elements (type, valaddr, embedded_offset,
address, stream, recurse,
original_value, options, i);
fprintf_filtered (stream, "}");
@@ -327,7 +327,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
len, NULL, 0, options);
}
else
- pascal_object_print_value_fields (type, valaddr + embedded_offset,
+ pascal_object_print_value_fields (type, valaddr, embedded_offset,
address, stream, recurse,
original_value, options,
NULL, 0);
@@ -629,6 +629,7 @@ static void pascal_object_print_static_field (struct value *,
const struct value_print_options *);
static void pascal_object_print_value (struct type *, const gdb_byte *,
+ int,
CORE_ADDR, struct ui_file *, int,
const struct value *,
const struct value_print_options *,
@@ -687,6 +688,7 @@ pascal_object_is_vtbl_member (struct type *type)
void
pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
+ int offset,
CORE_ADDR address, struct ui_file *stream,
int recurse,
const struct value *val,
@@ -706,8 +708,9 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
/* Print out baseclasses such that we don't print
duplicates of virtual baseclasses. */
if (n_baseclasses > 0)
- pascal_object_print_value (type, valaddr, address, stream,
- recurse + 1, val, options, dont_print_vb);
+ pascal_object_print_value (type, valaddr, offset, address,
+ stream, recurse + 1, val,
+ options, dont_print_vb);
if (!len && n_baseclasses == 1)
fprintf_filtered (stream, "<No data fields>");
@@ -814,7 +817,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
struct value_print_options opts = *options;
v = value_from_longest (TYPE_FIELD_TYPE (type, i),
- unpack_field_as_long (type, valaddr, i));
+ unpack_field_as_long (type,
+ valaddr + offset, i));
opts.deref_ref = 0;
common_val_print (v, stream, recurse + 1, &opts,
@@ -833,8 +837,9 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
v4.17 specific. */
struct value *v;
- v = value_from_longest (TYPE_FIELD_TYPE (type, i),
- unpack_field_as_long (type, valaddr, i));
+ v = value_from_longest
+ (TYPE_FIELD_TYPE (type, i),
+ unpack_field_as_long (type, valaddr + offset, i));
if (v == NULL)
fputs_filtered ("<optimized out>", stream);
@@ -852,9 +857,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
address + TYPE_FIELD_BITPOS (type, i) / 8, 0,
stream, format, 0, recurse + 1, pretty); */
val_print (TYPE_FIELD_TYPE (type, i),
- valaddr, TYPE_FIELD_BITPOS (type, i) / 8,
- address + TYPE_FIELD_BITPOS (type, i) / 8,
- stream, recurse + 1, val, &opts,
+ valaddr, offset + TYPE_FIELD_BITPOS (type, i) / 8,
+ address, stream, recurse + 1, val, &opts,
current_language);
}
}
@@ -883,6 +887,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
static void
pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
+ int offset,
CORE_ADDR address, struct ui_file *stream,
int recurse,
const struct value *val,
@@ -909,6 +914,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
char *basename = type_name_no_tag (baseclass);
const gdb_byte *base_valaddr;
+ int thisoffset;
if (BASETYPE_VIA_VIRTUAL (type, i))
{
@@ -925,7 +931,9 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
}
- boffset = baseclass_offset (type, i, valaddr, address);
+ thisoffset = offset;
+
+ boffset = baseclass_offset (type, i, valaddr + offset, address + offset);
if (options->pretty)
{
@@ -952,16 +960,19 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
if (target_read_memory (address + boffset, buf,
TYPE_LENGTH (baseclass)) != 0)
boffset = -1;
+ address = address + boffset;
+ thisoffset = 0;
+ boffset = 0;
}
else
- base_valaddr = valaddr + boffset;
+ base_valaddr = valaddr;
if (boffset == -1)
fprintf_filtered (stream, "<invalid address>");
else
pascal_object_print_value_fields (baseclass, base_valaddr,
- address + boffset, stream,
- recurse, val, options,
+ thisoffset + boffset, address,
+ stream, recurse, val, options,
(struct type **) obstack_base (&dont_print_vb_obstack),
0);
fputs_filtered (", ", stream);
@@ -1025,9 +1036,12 @@ pascal_object_print_static_field (struct value *val,
sizeof (CORE_ADDR));
CHECK_TYPEDEF (type);
- pascal_object_print_value_fields (type, value_contents (val), addr,
- stream, recurse, NULL, options,
- NULL, 1);
+ pascal_object_print_value_fields (type,
+ value_contents_for_printing (val),
+ value_embedded_offset (val),
+ addr,
+ stream, recurse,
+ val, options, NULL, 1);
return;
}