diff options
author | Yao Qi <yao.qi@linaro.org> | 2016-11-08 16:02:42 +0000 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2016-11-08 16:02:42 +0000 |
commit | e8b24d9ff5b9419fc079f5fe975fac6f499f8bfb (patch) | |
tree | 92c0daff1395bbf458aa6d7412f0d49ad3ef34d8 /gdb/ada-valprint.c | |
parent | cc977dc7d53ef4546592a4f02a2e06a621beae6f (diff) | |
download | gdb-e8b24d9ff5b9419fc079f5fe975fac6f499f8bfb.zip gdb-e8b24d9ff5b9419fc079f5fe975fac6f499f8bfb.tar.gz gdb-e8b24d9ff5b9419fc079f5fe975fac6f499f8bfb.tar.bz2 |
Remove parameter valaddr from la_val_print
Nowadays, we pass both val and return value of
value_contents_for_printing (val) to la_val_print. The latter is
unnecessary. This patch removes the second parameter of la_val_print,
and get valaddr in each language's implementation by calling
value_contents_for_printing. Since value_contents_for_printing calls
value_fetch_lazy, I also make VAL non-const.
Note that
- I don't clean up the valaddr usages in each language's routines,
- I don't remove valaddr from apply_ext_lang_val_pretty_printer, and
extension language ops apply_val_pretty_printer.
They can be done in followup patches.
gdb:
2016-11-08 Yao Qi <yao.qi@linaro.org>
* ada-lang.h (ada_val_print): Remove second parameter. Remove
const from "struct value *".
* ada-valprint.c (print_field_values): Remove const from
"struct value *".
(val_print_packed_array_elements): Likewise.
(print_variant_part): Likewise.
(ada_val_print_string): Likewise.
(ada_val_print_gnat_array): Likewise.
(ada_val_print_ptr): Likewise.
(ada_val_print_num): Likewise.
(ada_val_print_enum): Likewise.
(ada_val_print_flt): Likewise.
(ada_val_print_union): Likewise.
(ada_val_print_struct_union): Likewise.
(ada_val_print_ref): Likewise.
(ada_val_print_1): Remove second parameter. Remove const from
"struct value *".
(ada_val_print): Likewise.
* c-lang.h (c_val_print): Likewise.
* c-valprint.c (c_val_print_array): Remove const from
"struct value *".
(c_val_print_ptr): Likewise.
(c_val_print_struct): Likewise.
(c_val_print_union): Likewise.
(c_val_print_int): Likewise.
(c_val_print_memberptr): Likewise.
(c_val_print): Remove second parameter. Remove const from
"struct value *". All callers updated.
* cp-valprint.c (cp_print_value): Remove const from
"struct value *".
(cp_print_value_fields): Likewise.
(c_val_print_value): Likewise.
* d-lang.h (d_val_print): Remove second parameter. Remove const
from "struct value *".
* d-valprint.c (dynamic_array_type): Likewise.
(d_val_print): Likewise.
* f-lang.h (f_val_print): Likewise.
* f-valprint.c (f_val_print): Likewise.
* go-lang.h (go_val_print): Likewise.
* go-valprint.c (print_go_string): Likewise.
(go_val_print): Likewise.
* language.c (unk_lang_val_print): Likewise.
* language.h (struct language_defn) <la_val_print>: Likewise.
Update comments.
(LA_VAL_PRINT): Remove.
* m2-lang.h (m2_val_print): Remove const from
"struct value *".
* m2-valprint.c (m2_print_array_contents): Likewise.
(m2_val_print): Likewise.
* p-lang.h (pascal_val_print): Remove second parameter. Remove
const from "struct value *".
(pascal_object_print_value_fields): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_value_fields): Likewise.
(pascal_object_print_value): Likewise.
* rust-lang.c (rust_get_disr_info): Likewise.
(val_print_struct): Likewise.
(rust_val_print): Likewise.
* valprint.c (generic_val_print_array): Likewise.
(generic_val_print_ptr): Likewise.
(generic_val_print_memberptr): Likewise.
(generic_val_print_ref): Likewise.
(generic_val_print_enum): Likewise.
(generic_val_print_flags): Likewise.
(generic_val_print_func): 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.
(generic_val_print): Likewise.
(val_print): Likewise.
(common_val_print): Likewise.
(val_print_type_code_flags): Likewise.
(val_print_scalar_formatted): Likewise.
(val_print_array_elements): Likewise.
* valprint.h (val_print_array_elements): Update declaration.
(val_print_scalar_formatted): Likewise.
(generic_val_print): Likewise.
* value.h (val_print): Likewise.
Diffstat (limited to 'gdb/ada-valprint.c')
-rw-r--r-- | gdb/ada-valprint.c | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index bae4e4f..b771382 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -35,7 +35,7 @@ static int print_field_values (struct type *, const gdb_byte *, int, struct ui_file *, int, - const struct value *, + struct value *, const struct value_print_options *, int, struct type *, int, const struct language_defn *); @@ -122,7 +122,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, int offset, int bitoffset, struct ui_file *stream, int recurse, - const struct value *val, + struct value *val, const struct value_print_options *options) { unsigned int i; @@ -196,7 +196,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, struct value_print_options opts = *options; opts.deref_ref = 0; - val_print (elttype, value_contents_for_printing (v0), + val_print (elttype, value_embedded_offset (v0), 0, stream, recurse + 1, v0, &opts, current_language); annotate_elt_rep (i - i0); @@ -227,7 +227,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, maybe_print_array_index (index_type, j + low, stream, options); } - val_print (elttype, value_contents_for_printing (v0), + val_print (elttype, value_embedded_offset (v0), 0, stream, recurse + 1, v0, &opts, current_language); annotate_elt (); @@ -534,7 +534,7 @@ static int print_variant_part (struct type *type, int field_num, const gdb_byte *valaddr, int offset, struct ui_file *stream, int recurse, - const struct value *val, + struct value *val, const struct value_print_options *options, int comma_needed, struct type *outer_type, int outer_offset, @@ -574,7 +574,7 @@ print_variant_part (struct type *type, int field_num, static int print_field_values (struct type *type, const gdb_byte *valaddr, int offset, struct ui_file *stream, int recurse, - const struct value *val, + struct value *val, const struct value_print_options *options, int comma_needed, struct type *outer_type, int outer_offset, @@ -634,8 +634,6 @@ print_field_values (struct type *type, const gdb_byte *valaddr, if (TYPE_FIELD_PACKED (type, i)) { - struct value *v; - /* Bitfields require special handling, especially due to byte order problems. */ if (HAVE_CPLUS_STRUCT (type) && TYPE_FIELD_IGNORE (type, i)) @@ -644,6 +642,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr, } else { + struct value *v; int bit_pos = TYPE_FIELD_BITPOS (type, i); int bit_size = TYPE_FIELD_BITSIZE (type, i); struct value_print_options opts; @@ -657,7 +656,6 @@ print_field_values (struct type *type, const gdb_byte *valaddr, opts = *options; opts.deref_ref = 0; val_print (TYPE_FIELD_TYPE (type, i), - value_contents_for_printing (v), value_embedded_offset (v), 0, stream, recurse + 1, v, &opts, language); @@ -668,7 +666,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr, struct value_print_options opts = *options; opts.deref_ref = 0; - val_print (TYPE_FIELD_TYPE (type, i), valaddr, + val_print (TYPE_FIELD_TYPE (type, i), (offset + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT), 0, stream, recurse + 1, val, &opts, language); } @@ -685,7 +683,7 @@ static void ada_val_print_string (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, int recurse, - const struct value *original_value, + struct value *original_value, const struct value_print_options *options) { enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); @@ -733,7 +731,7 @@ static void ada_val_print_gnat_array (struct type *type, const gdb_byte *valaddr, int offset, CORE_ADDR address, struct ui_file *stream, int recurse, - const struct value *original_value, + struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { @@ -755,7 +753,7 @@ ada_val_print_gnat_array (struct type *type, const gdb_byte *valaddr, fprintf_filtered (stream, "0x0"); } else - val_print (value_type (val), value_contents_for_printing (val), + val_print (value_type (val), value_embedded_offset (val), value_address (val), stream, recurse, val, options, language); value_free_to_mark (mark); @@ -768,11 +766,11 @@ static void ada_val_print_ptr (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, int recurse, - const struct value *original_value, + struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { - val_print (type, valaddr, offset, address, stream, recurse, + val_print (type, offset, address, stream, recurse, original_value, options, language_def (language_c)); if (ada_is_tag_type (type)) @@ -795,7 +793,7 @@ static void ada_val_print_num (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, int recurse, - const struct value *original_value, + struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { @@ -821,12 +819,12 @@ ada_val_print_num (struct type *type, const gdb_byte *valaddr, = value_from_contents_and_address (type, valaddr + offset, 0); struct value *v = value_cast (target_type, v1); - val_print (target_type, value_contents_for_printing (v), + val_print (target_type, value_embedded_offset (v), 0, stream, recurse + 1, v, options, language); } else - val_print (TYPE_TARGET_TYPE (type), valaddr, offset, + val_print (TYPE_TARGET_TYPE (type), offset, address, stream, recurse, original_value, options, language); return; @@ -841,7 +839,7 @@ ada_val_print_num (struct type *type, const gdb_byte *valaddr, struct value_print_options opts = *options; opts.format = format; - val_print_scalar_formatted (type, valaddr, offset_aligned, + val_print_scalar_formatted (type, offset_aligned, original_value, &opts, 0, stream); } else if (ada_is_system_address_type (type)) @@ -885,7 +883,7 @@ static void ada_val_print_enum (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, int recurse, - const struct value *original_value, + struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { @@ -895,7 +893,7 @@ ada_val_print_enum (struct type *type, const gdb_byte *valaddr, if (options->format) { - val_print_scalar_formatted (type, valaddr, offset_aligned, + val_print_scalar_formatted (type, offset_aligned, original_value, options, 0, stream); return; } @@ -929,13 +927,13 @@ static void ada_val_print_flt (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, int recurse, - const struct value *original_value, + struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { if (options->format) { - val_print (type, valaddr, offset, address, stream, recurse, + val_print (type, offset, address, stream, recurse, original_value, options, language_def (language_c)); return; } @@ -950,7 +948,7 @@ static void ada_val_print_struct_union (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, - int recurse, const struct value *original_value, + int recurse, struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { @@ -981,7 +979,7 @@ static void ada_val_print_array (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, int recurse, - const struct value *original_value, + struct value *original_value, const struct value_print_options *options) { /* For an array of characters, print with string syntax. */ @@ -1001,7 +999,7 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr, 0, stream, recurse, original_value, options); else - val_print_array_elements (type, valaddr, offset_aligned, address, + val_print_array_elements (type, offset_aligned, address, stream, recurse, original_value, options, 0); fprintf_filtered (stream, ")"); @@ -1014,7 +1012,7 @@ static void ada_val_print_ref (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, int recurse, - const struct value *original_value, + struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { @@ -1064,7 +1062,6 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr, ada_ensure_varsize_limit (value_type (deref_val)); val_print (value_type (deref_val), - value_contents_for_printing (deref_val), value_embedded_offset (deref_val), value_address (deref_val), stream, recurse + 1, deref_val, options, language); @@ -1074,14 +1071,15 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr, does not catch evaluation errors (leaving that to ada_val_print). */ static void -ada_val_print_1 (struct type *type, const gdb_byte *valaddr, +ada_val_print_1 (struct type *type, int offset, CORE_ADDR address, struct ui_file *stream, int recurse, - const struct value *original_value, + struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { int offset_aligned; + const gdb_byte *valaddr = value_contents_for_printing (original_value); type = ada_check_typedef (type); @@ -1103,7 +1101,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr, switch (TYPE_CODE (type)) { default: - val_print (type, valaddr, offset, address, stream, recurse, + val_print (type, offset, address, stream, recurse, original_value, options, language_def (language_c)); break; @@ -1157,17 +1155,17 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr, function; they are identical. */ void -ada_val_print (struct type *type, const gdb_byte *valaddr, +ada_val_print (struct type *type, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, - const struct value *val, + struct value *val, const struct value_print_options *options) { /* XXX: this catches QUIT/ctrl-c as well. Isn't that busted? */ TRY { - ada_val_print_1 (type, valaddr, embedded_offset, address, + ada_val_print_1 (type, embedded_offset, address, stream, recurse, val, options, current_language); } @@ -1222,7 +1220,7 @@ ada_value_print (struct value *val0, struct ui_file *stream, opts = *options; opts.deref_ref = 1; - val_print (type, value_contents_for_printing (val), + val_print (type, value_embedded_offset (val), address, stream, 0, val, &opts, current_language); } |