aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2016-11-08 16:02:42 +0000
committerYao Qi <yao.qi@linaro.org>2016-11-08 16:02:42 +0000
commite8b24d9ff5b9419fc079f5fe975fac6f499f8bfb (patch)
tree92c0daff1395bbf458aa6d7412f0d49ad3ef34d8
parentUse get_frame_register_value instead of deprecated_frame_register_read (diff)
downloadbinutils-gdb-e8b24d9ff5b9419fc079f5fe975fac6f499f8bfb.tar.gz
binutils-gdb-e8b24d9ff5b9419fc079f5fe975fac6f499f8bfb.tar.bz2
binutils-gdb-e8b24d9ff5b9419fc079f5fe975fac6f499f8bfb.zip
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.
-rw-r--r--gdb/ChangeLog84
-rw-r--r--gdb/ada-lang.h4
-rw-r--r--gdb/ada-valprint.c68
-rw-r--r--gdb/c-lang.h8
-rw-r--r--gdb/c-valprint.c33
-rw-r--r--gdb/cp-valprint.c13
-rw-r--r--gdb/d-lang.h4
-rw-r--r--gdb/d-valprint.c14
-rw-r--r--gdb/f-lang.h4
-rw-r--r--gdb/f-valprint.c13
-rw-r--r--gdb/go-lang.h4
-rw-r--r--gdb/go-valprint.c14
-rw-r--r--gdb/infcmd.c3
-rw-r--r--gdb/language.c4
-rw-r--r--gdb/language.h9
-rw-r--r--gdb/m2-lang.h4
-rw-r--r--gdb/m2-valprint.c19
-rw-r--r--gdb/mi/mi-main.c1
-rw-r--r--gdb/mips-tdep.c1
-rw-r--r--gdb/mt-tdep.c1
-rw-r--r--gdb/p-lang.h6
-rw-r--r--gdb/p-valprint.c19
-rw-r--r--gdb/printcmd.c1
-rw-r--r--gdb/rust-lang.c28
-rw-r--r--gdb/sh64-tdep.c4
-rw-r--r--gdb/valprint.c190
-rw-r--r--gdb/valprint.h12
-rw-r--r--gdb/value.h4
28 files changed, 334 insertions, 235 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 227431fc0a4..7d48cada98b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,89 @@
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.
+
+2016-11-08 Yao Qi <yao.qi@linaro.org>
+
* mt-tdep.c (mt_registers_info): Call
get_frame_register_value instead of
deprecated_frame_register_read.
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 189d696f607..1a538afa0b4 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -168,9 +168,9 @@ extern void ada_print_type (struct type *, const char *, struct ui_file *, int,
extern void ada_print_typedef (struct type *type, struct symbol *new_symbol,
struct ui_file *stream);
-extern void ada_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
+extern void ada_val_print (struct type *, int, CORE_ADDR,
struct ui_file *, int,
- const struct value *,
+ struct value *,
const struct value_print_options *);
extern void ada_value_print (struct value *, struct ui_file *,
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index bae4e4f881d..b771382ebb0 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);
}
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 8378d4ff368..25cd93cb984 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -76,10 +76,10 @@ extern void c_print_typedef (struct type *,
struct symbol *,
struct ui_file *);
-extern void c_val_print (struct type *, const gdb_byte *,
+extern void c_val_print (struct type *,
int, CORE_ADDR,
struct ui_file *, int,
- const struct value *,
+ struct value *,
const struct value_print_options *);
extern void c_value_print (struct value *, struct ui_file *,
@@ -125,14 +125,14 @@ extern void cp_print_class_member (const gdb_byte *, struct type *,
extern void cp_print_value_fields (struct type *, struct type *,
const gdb_byte *, LONGEST, CORE_ADDR,
struct ui_file *, int,
- const struct value *,
+ struct value *,
const struct value_print_options *,
struct type **, int);
extern void cp_print_value_fields_rtti (struct type *,
const gdb_byte *, LONGEST, CORE_ADDR,
struct ui_file *, int,
- const struct value *,
+ struct value *,
const struct value_print_options *,
struct type **, int);
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 2cb418d4310..a90da884db8 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -233,7 +233,7 @@ static void
c_val_print_array (struct type *type, const gdb_byte *valaddr,
int embedded_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)
{
struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
@@ -325,7 +325,7 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr,
{
i = 0;
}
- val_print_array_elements (type, valaddr, embedded_offset,
+ val_print_array_elements (type, embedded_offset,
address, stream,
recurse, original_value, options, i);
fprintf_filtered (stream, "}");
@@ -345,7 +345,7 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr,
static void
c_val_print_ptr (struct type *type, const gdb_byte *valaddr,
int embedded_offset, struct ui_file *stream, int recurse,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *arch = get_type_arch (type);
@@ -353,7 +353,7 @@ c_val_print_ptr (struct type *type, const gdb_byte *valaddr,
if (options->format && options->format != 's')
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
}
else if (options->vtblprint && cp_is_vtbl_ptr_type (type))
@@ -386,7 +386,7 @@ static void
c_val_print_struct (struct type *type, const gdb_byte *valaddr,
int embedded_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)
{
if (options->vtblprint && cp_is_vtbl_ptr_type (type))
@@ -418,7 +418,7 @@ static void
c_val_print_union (struct type *type, const gdb_byte *valaddr,
int embedded_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)
{
if (recurse && !options->unionprint)
@@ -437,7 +437,7 @@ c_val_print_union (struct type *type, const gdb_byte *valaddr,
static void
c_val_print_int (struct type *type, struct type *unresolved_type,
const gdb_byte *valaddr, int embedded_offset,
- struct ui_file *stream, const struct value *original_value,
+ struct ui_file *stream, struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *arch = get_type_arch (type);
@@ -449,7 +449,7 @@ c_val_print_int (struct type *type, struct type *unresolved_type,
opts.format = (options->format ? options->format
: options->output_format);
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, &opts, 0, stream);
}
else
@@ -476,7 +476,7 @@ static void
c_val_print_memberptr (struct type *type, const gdb_byte *valaddr,
int embedded_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)
{
if (!options->format)
@@ -485,7 +485,7 @@ c_val_print_memberptr (struct type *type, const gdb_byte *valaddr,
}
else
{
- generic_val_print (type, valaddr, embedded_offset, address, stream,
+ generic_val_print (type, embedded_offset, address, stream,
recurse, original_value, options, &c_decorations);
}
}
@@ -494,13 +494,14 @@ c_val_print_memberptr (struct type *type, const gdb_byte *valaddr,
function; they are identical. */
void
-c_val_print (struct type *type, const gdb_byte *valaddr,
+c_val_print (struct type *type,
int embedded_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)
{
struct type *unresolved_type = type;
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
type = check_typedef (type);
switch (TYPE_CODE (type))
@@ -554,7 +555,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
case TYPE_CODE_COMPLEX:
case TYPE_CODE_CHAR:
default:
- generic_val_print (type, valaddr, embedded_offset, address,
+ generic_val_print (type, embedded_offset, address,
stream, recurse, original_value, options,
&c_decorations);
break;
@@ -669,7 +670,7 @@ c_value_print (struct value *val, struct ui_file *stream,
/* Print out object: enclosing type is same as real_type if
full. */
val_print (value_enclosing_type (val),
- value_contents_for_printing (val), 0,
+ 0,
value_address (val), stream, 0,
val, &opts, current_language);
return;
@@ -682,7 +683,7 @@ c_value_print (struct value *val, struct ui_file *stream,
fprintf_filtered (stream, "(%s ?) ",
TYPE_NAME (value_enclosing_type (val)));
val_print (value_enclosing_type (val),
- value_contents_for_printing (val), 0,
+ 0,
value_address (val), stream, 0,
val, &opts, current_language);
return;
@@ -690,7 +691,7 @@ c_value_print (struct value *val, struct ui_file *stream,
/* Otherwise, we end up at the return outside this "if". */
}
- val_print (val_type, value_contents_for_printing (val),
+ val_print (val_type,
value_embedded_offset (val),
value_address (val),
stream, 0,
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 5fb2561798e..82e505ada8f 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -82,7 +82,7 @@ static void cp_print_static_field (struct type *, struct value *,
static void cp_print_value (struct type *, struct type *,
const gdb_byte *, LONGEST,
CORE_ADDR, struct ui_file *,
- int, const struct value *,
+ int, struct value *,
const struct value_print_options *,
struct type **);
@@ -156,7 +156,7 @@ void
cp_print_value_fields (struct type *type, struct type *real_type,
const gdb_byte *valaddr, LONGEST offset,
CORE_ADDR address, struct ui_file *stream,
- int recurse, const struct value *val,
+ int recurse, struct value *val,
const struct value_print_options *options,
struct type **dont_print_vb,
int dont_print_statmem)
@@ -353,7 +353,6 @@ cp_print_value_fields (struct type *type, struct type *real_type,
opts.deref_ref = 0;
val_print (TYPE_FIELD_TYPE (type, i),
- valaddr,
offset + TYPE_FIELD_BITPOS (type, i) / 8,
address,
stream, recurse + 1, val, &opts,
@@ -420,7 +419,7 @@ cp_print_value_fields_rtti (struct type *type,
const gdb_byte *valaddr, LONGEST offset,
CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
struct type **dont_print_vb,
int dont_print_statmem)
@@ -462,7 +461,7 @@ static void
cp_print_value (struct type *type, struct type *real_type,
const gdb_byte *valaddr, LONGEST offset,
CORE_ADDR address, struct ui_file *stream,
- int recurse, const struct value *val,
+ int recurse, struct value *val,
const struct value_print_options *options,
struct type **dont_print_vb)
{
@@ -489,7 +488,7 @@ cp_print_value (struct type *type, struct type *real_type,
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
const char *basename = TYPE_NAME (baseclass);
const gdb_byte *base_valaddr = NULL;
- const struct value *base_val = NULL;
+ struct value *base_val = NULL;
if (BASETYPE_VIA_VIRTUAL (type, i))
{
@@ -708,7 +707,7 @@ cp_print_static_field (struct type *type,
opts = *options;
opts.deref_ref = 0;
- val_print (type, value_contents_for_printing (val),
+ val_print (type,
value_embedded_offset (val),
value_address (val),
stream, recurse, val,
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index 74be7a5f61f..52f4e6abc6d 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -80,10 +80,10 @@ extern struct block_symbol d_lookup_nested_symbol (struct type *, const char *,
/* Defined in d-valprint.c */
-extern void d_val_print (struct type *type, const gdb_byte *valaddr,
+extern void d_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);
#endif /* !defined (D_LANG_H) */
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index 620688bd4a8..109b54f114b 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -28,10 +28,10 @@
TYPE is a dynamic array, non-zero otherwise. */
static int
-dynamic_array_type (struct type *type, const gdb_byte *valaddr,
+dynamic_array_type (struct type *type,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options)
{
if (TYPE_NFIELDS (type) == 2
@@ -48,6 +48,7 @@ dynamic_array_type (struct type *type, const gdb_byte *valaddr,
struct type *ptr_type;
struct value *ival;
int length;
+ const gdb_byte *valaddr = value_contents_for_printing (val);
length = unpack_field_as_long (type, valaddr + embedded_offset, 0);
@@ -63,7 +64,6 @@ dynamic_array_type (struct type *type, const gdb_byte *valaddr,
true_type = value_type (ival);
d_val_print (true_type,
- value_contents_for_printing (ival),
value_embedded_offset (ival), addr,
stream, recurse + 1, ival, options);
return 0;
@@ -73,9 +73,9 @@ dynamic_array_type (struct type *type, const gdb_byte *valaddr,
/* Implements the la_val_print routine for language D. */
void
-d_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
+d_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)
{
int ret;
@@ -84,12 +84,12 @@ d_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
switch (TYPE_CODE (type))
{
case TYPE_CODE_STRUCT:
- ret = dynamic_array_type (type, valaddr, embedded_offset, address,
+ ret = dynamic_array_type (type, embedded_offset, address,
stream, recurse, val, options);
if (ret == 0)
break;
default:
- c_val_print (type, valaddr, embedded_offset, address, stream,
+ c_val_print (type, embedded_offset, address, stream,
recurse, val, options);
}
}
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index 827785a0d17..a0861054567 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -30,9 +30,9 @@ extern void f_yyerror (char *); /* Defined in f-exp.y */
extern void f_print_type (struct type *, const char *, struct ui_file *, int,
int, const struct type_print_options *);
-extern void f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
+extern void f_val_print (struct type *, int, CORE_ADDR,
struct ui_file *, int,
- const struct value *,
+ struct value *,
const struct value_print_options *);
/* Language-specific data structures */
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index e1a677e9dd5..a39c80171c2 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -152,7 +152,6 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
struct value *elt = value_subscript ((struct value *)val, i);
val_print (value_type (elt),
- value_contents_for_printing (elt),
value_embedded_offset (elt),
value_address (elt), stream, recurse,
elt, options, current_language);
@@ -211,9 +210,9 @@ static const struct generic_val_print_decorations f_decorations =
function; they are identical. */
void
-f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
+f_val_print (struct type *type, int embedded_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)
{
struct gdbarch *gdbarch = get_type_arch (type);
@@ -222,6 +221,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
struct type *elttype;
CORE_ADDR addr;
int index;
+ const gdb_byte *valaddr =value_contents_for_printing (original_value);
type = check_typedef (type);
switch (TYPE_CODE (type))
@@ -256,7 +256,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
case TYPE_CODE_PTR:
if (options->format && options->format != 's')
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
break;
}
@@ -306,7 +306,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
opts.format = (options->format ? options->format
: options->output_format);
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, &opts, 0, stream);
}
else
@@ -355,7 +355,6 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
}
val_print (value_type (field),
- value_contents_for_printing (field),
value_embedded_offset (field),
value_address (field), stream, recurse + 1,
field, options, current_language);
@@ -378,7 +377,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
case TYPE_CODE_BOOL:
case TYPE_CODE_CHAR:
default:
- generic_val_print (type, valaddr, embedded_offset, address,
+ generic_val_print (type, embedded_offset, address,
stream, recurse, original_value, options,
&f_decorations);
break;
diff --git a/gdb/go-lang.h b/gdb/go-lang.h
index 5eb298e543e..fa96f53ac42 100644
--- a/gdb/go-lang.h
+++ b/gdb/go-lang.h
@@ -84,10 +84,10 @@ extern void go_print_type (struct type *type, const char *varstring,
/* Defined in go-valprint.c. */
-extern void go_val_print (struct type *type, const gdb_byte *valaddr,
+extern void go_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);
#endif /* !defined (GO_LANG_H) */
diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c
index 34ed8e09074..ad954c1a7c7 100644
--- a/gdb/go-valprint.c
+++ b/gdb/go-valprint.c
@@ -36,10 +36,10 @@
gdb_assert (go_classify_struct_type (type) == GO_TYPE_STRING). */
static void
-print_go_string (struct type *type, const gdb_byte *valaddr,
+print_go_string (struct type *type,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
@@ -51,8 +51,8 @@ print_go_string (struct type *type, const gdb_byte *valaddr,
unpack_value_field_as_pointer. Do this until we can get
unpack_value_field_as_pointer. */
LONGEST addr;
+ const gdb_byte *valaddr = value_contents_for_printing (val);
- gdb_assert (valaddr == value_contents_for_printing_const (val));
if (! unpack_value_field_as_long (type, valaddr, embedded_offset, 0,
val, &addr))
@@ -86,9 +86,9 @@ print_go_string (struct type *type, const gdb_byte *valaddr,
/* Implements the la_val_print routine for language Go. */
void
-go_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
+go_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)
{
type = check_typedef (type);
@@ -104,7 +104,7 @@ go_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
case GO_TYPE_STRING:
if (! options->raw)
{
- print_go_string (type, valaddr, embedded_offset, address,
+ print_go_string (type, embedded_offset, address,
stream, recurse, val, options);
return;
}
@@ -116,7 +116,7 @@ go_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
/* Fall through. */
default:
- c_val_print (type, valaddr, embedded_offset, address, stream,
+ c_val_print (type, embedded_offset, address, stream,
recurse, val, options);
break;
}
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index c603c01b4c2..2440c0c78fe 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2315,7 +2315,6 @@ default_print_one_register_info (struct ui_file *file,
opts.deref_ref = 1;
val_print (regtype,
- value_contents_for_printing (val),
value_embedded_offset (val), 0,
file, 0, val, &opts, current_language);
@@ -2334,7 +2333,6 @@ default_print_one_register_info (struct ui_file *file,
get_formatted_print_options (&opts, 'x');
opts.deref_ref = 1;
val_print (regtype,
- value_contents_for_printing (val),
value_embedded_offset (val), 0,
file, 0, val, &opts, current_language);
/* If not a vector register, print it also according to its
@@ -2345,7 +2343,6 @@ default_print_one_register_info (struct ui_file *file,
opts.deref_ref = 1;
fprintf_filtered (file, "\t");
val_print (regtype,
- value_contents_for_printing (val),
value_embedded_offset (val), 0,
file, 0, val, &opts, current_language);
}
diff --git a/gdb/language.c b/gdb/language.c
index 2869d75eedb..b6f22ebe4ac 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -780,10 +780,10 @@ unk_lang_print_type (struct type *type, const char *varstring,
}
static void
-unk_lang_val_print (struct type *type, const gdb_byte *valaddr,
+unk_lang_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)
{
error (_("internal error - unimplemented "
diff --git a/gdb/language.h b/gdb/language.h
index 758f265cd45..5e4fe4c6e03 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -219,9 +219,6 @@ struct language_defn
TYPE is the type of the sub-object to be printed.
- CONTENTS holds the bits of the value. This holds the entire
- enclosing object.
-
EMBEDDED_OFFSET is the offset into the outermost object of the
sub-object represented by TYPE. This is the object which this
call should print. Note that the enclosing type is not
@@ -237,10 +234,9 @@ struct language_defn
printing. */
void (*la_val_print) (struct type *type,
- const gdb_byte *contents,
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);
/* Print a top-level value using syntax appropriate for this language. */
@@ -515,9 +511,6 @@ extern enum language set_language (enum language);
#define LA_PRINT_TYPEDEF(type,new_symbol,stream) \
(current_language->la_print_typedef(type,new_symbol,stream))
-#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,val,recurse,options) \
- (current_language->la_val_print(type,valaddr,offset,addr,stream, \
- val,recurse,options))
#define LA_VALUE_PRINT(val,stream,options) \
(current_language->la_value_print(val,stream,options))
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index b749b215559..b35a0ca97d8 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -34,9 +34,9 @@ extern void m2_print_typedef (struct type *, struct symbol *,
extern int m2_is_long_set (struct type *type);
extern int m2_is_unbounded_array (struct type *type);
-extern void m2_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
+extern void m2_val_print (struct type *, int, CORE_ADDR,
struct ui_file *, int,
- const struct value *,
+ struct value *,
const struct value_print_options *);
extern int get_long_set_bounds (struct type *type, LONGEST *low,
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index a53aa84bd30..f43a2d2afe8 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -37,7 +37,7 @@ static void
m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
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,
int len);
@@ -262,7 +262,7 @@ static void
m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
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,
int len)
{
@@ -282,7 +282,7 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
else
{
fprintf_filtered (stream, "{");
- val_print_array_elements (type, valaddr, embedded_offset,
+ val_print_array_elements (type, embedded_offset,
address, stream, recurse, val,
options, 0);
fprintf_filtered (stream, "}");
@@ -308,15 +308,16 @@ static const struct generic_val_print_decorations m2_decorations =
function; they are identical. */
void
-m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
+m2_val_print (struct type *type, int embedded_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)
{
struct gdbarch *gdbarch = get_type_arch (type);
unsigned len;
struct type *elttype;
CORE_ADDR addr;
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
type = check_typedef (type);
switch (TYPE_CODE (type))
@@ -356,7 +357,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
else
{
fprintf_filtered (stream, "{");
- val_print_array_elements (type, valaddr, embedded_offset,
+ val_print_array_elements (type, embedded_offset,
address, stream,
recurse, original_value,
options, 0);
@@ -373,7 +374,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
print_variable_at_address (type, valaddr + embedded_offset,
stream, recurse, options);
else if (options->format && options->format != 's')
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
else
{
@@ -469,7 +470,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
case TYPE_CODE_RANGE:
if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type)))
{
- m2_val_print (TYPE_TARGET_TYPE (type), valaddr, embedded_offset,
+ m2_val_print (TYPE_TARGET_TYPE (type), embedded_offset,
address, stream, recurse, original_value, options);
break;
}
@@ -494,7 +495,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
case TYPE_CODE_BOOL:
case TYPE_CODE_CHAR:
default:
- generic_val_print (type, valaddr, embedded_offset, address,
+ generic_val_print (type, embedded_offset, address,
stream, recurse, original_value, options,
&m2_decorations);
break;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index abbd31f60e4..31b413e38c8 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1290,7 +1290,6 @@ output_register (struct frame_info *frame, int regnum, int format,
get_formatted_print_options (&opts, format);
opts.deref_ref = 1;
val_print (value_type (val),
- value_contents_for_printing (val),
value_embedded_offset (val), 0,
stb, 0, val, &opts, current_language);
ui_out_field_stream (uiout, "value", stb);
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index c2c88a67070..c0c644298f4 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -6356,7 +6356,6 @@ mips_print_register (struct ui_file *file, struct frame_info *frame,
get_formatted_print_options (&opts, 'x');
val_print_scalar_formatted (value_type (val),
- value_contents_for_printing (val),
value_embedded_offset (val),
val,
&opts, 0, file);
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index c08e80567ea..e958cc4663e 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -726,7 +726,6 @@ mt_registers_info (struct gdbarch *gdbarch,
get_no_prettyformat_print_options (&opts);
opts.deref_ref = 1;
val_print (register_type (gdbarch, regnum),
- value_contents_for_printing (val),
0, 0, file, 0, val,
&opts, current_language);
fputs_filtered ("\n", file);
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index 287c0f421ca..5d3a685d288 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -36,9 +36,9 @@ extern void pascal_print_type (struct type *, const char *, struct ui_file *,
extern void pascal_print_typedef (struct type *, struct symbol *,
struct ui_file *);
-extern void pascal_val_print (struct type *, const gdb_byte *, int,
+extern void pascal_val_print (struct type *, int,
CORE_ADDR, struct ui_file *, int,
- const struct value *,
+ struct value *,
const struct value_print_options *);
extern void pascal_value_print (struct value *, struct ui_file *,
@@ -75,7 +75,7 @@ extern void pascal_object_print_value_fields (struct type *, const gdb_byte *,
LONGEST,
CORE_ADDR, struct ui_file *,
int,
- const struct value *,
+ struct value *,
const struct value_print_options *,
struct type **, int);
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index f639e29b625..82abe60c929 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -58,10 +58,10 @@ static const struct generic_val_print_decorations p_decorations =
function; they are identical. */
void
-pascal_val_print (struct type *type, const gdb_byte *valaddr,
+pascal_val_print (struct type *type,
int embedded_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)
{
struct gdbarch *gdbarch = get_type_arch (type);
@@ -75,6 +75,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
struct type *char_type;
CORE_ADDR addr;
int want_space = 0;
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
type = check_typedef (type);
switch (TYPE_CODE (type))
@@ -132,7 +133,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, embedded_offset,
address, stream, recurse,
original_value, options, i);
fprintf_filtered (stream, "}");
@@ -146,7 +147,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
case TYPE_CODE_PTR:
if (options->format && options->format != 's')
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
break;
}
@@ -287,7 +288,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
case TYPE_CODE_UNDEF:
case TYPE_CODE_BOOL:
case TYPE_CODE_CHAR:
- generic_val_print (type, valaddr, embedded_offset, address,
+ generic_val_print (type, embedded_offset, address,
stream, recurse, original_value, options,
&p_decorations);
break;
@@ -471,7 +472,7 @@ static void pascal_object_print_static_field (struct value *,
static void pascal_object_print_value (struct type *, const gdb_byte *,
LONGEST,
CORE_ADDR, struct ui_file *, int,
- const struct value *,
+ struct value *,
const struct value_print_options *,
struct type **);
@@ -531,7 +532,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
LONGEST offset,
CORE_ADDR address, struct ui_file *stream,
int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
struct type **dont_print_vb,
int dont_print_statmem)
@@ -670,7 +671,7 @@ 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, offset + TYPE_FIELD_BITPOS (type, i) / 8,
+ offset + TYPE_FIELD_BITPOS (type, i) / 8,
address, stream, recurse + 1, val, &opts,
current_language);
}
@@ -703,7 +704,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
LONGEST offset,
CORE_ADDR address, struct ui_file *stream,
int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
struct type **dont_print_vb)
{
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 23de57cb213..8f865d2f5de 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -322,7 +322,6 @@ print_formatted (struct value *val, int size,
/* User specified format, so don't look to the type to tell us
what to do. */
val_print_scalar_formatted (type,
- value_contents_for_printing (val),
value_embedded_offset (val),
val,
options, size, stream);
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 31bbd24c118..295dae11ac5 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -120,7 +120,7 @@ rust_union_is_untagged (struct type *type)
static struct disr_info
rust_get_disr_info (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
- const struct value *val)
+ struct value *val)
{
int i;
struct disr_info ret;
@@ -235,7 +235,7 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr,
cleanup = make_cleanup_ui_file_delete (temp_file);
/* The first value of the first field (or any field)
is the discriminant value. */
- c_val_print (TYPE_FIELD_TYPE (disr_type, 0), valaddr,
+ c_val_print (TYPE_FIELD_TYPE (disr_type, 0),
(embedded_offset + TYPE_FIELD_BITPOS (type, 0) / 8
+ TYPE_FIELD_BITPOS (disr_type, 0) / 8),
address, temp_file,
@@ -479,9 +479,9 @@ rust_printstr (struct ui_file *stream, struct type *type,
/* rust_print_type branch for structs and untagged unions. */
static void
-val_print_struct (struct type *type, const gdb_byte *valaddr,
- int embedded_offset, CORE_ADDR address, struct ui_file *stream,
- int recurse, const struct value *val,
+val_print_struct (struct type *type, int embedded_offset,
+ CORE_ADDR address, struct ui_file *stream,
+ int recurse, struct value *val,
const struct value_print_options *options)
{
int i;
@@ -536,7 +536,6 @@ val_print_struct (struct type *type, const gdb_byte *valaddr,
}
val_print (TYPE_FIELD_TYPE (type, i),
- valaddr,
embedded_offset + TYPE_FIELD_BITPOS (type, i) / 8,
address,
stream, recurse + 1, val, &opts,
@@ -572,11 +571,13 @@ static const struct generic_val_print_decorations rust_decorations =
/* la_val_print implementation for Rust. */
static void
-rust_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
+rust_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)
{
+ const gdb_byte *valaddr = value_contents_for_printing (val);
+
type = check_typedef (type);
switch (TYPE_CODE (type))
{
@@ -613,7 +614,7 @@ rust_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
case TYPE_CODE_METHODPTR:
case TYPE_CODE_MEMBERPTR:
- c_val_print (type, valaddr, embedded_offset, address, stream,
+ c_val_print (type, embedded_offset, address, stream,
recurse, val, options);
break;
@@ -672,7 +673,7 @@ rust_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
fields. */
if (rust_union_is_untagged (type))
{
- val_print_struct (type, valaddr, embedded_offset, address, stream,
+ val_print_struct (type, embedded_offset, address, stream,
recurse, val, options);
break;
}
@@ -728,7 +729,6 @@ rust_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
TYPE_FIELD_NAME (variant_type, j));
val_print (TYPE_FIELD_TYPE (variant_type, j),
- valaddr,
(embedded_offset
+ TYPE_FIELD_BITPOS (type, disr.field_no) / 8
+ TYPE_FIELD_BITPOS (variant_type, j) / 8),
@@ -745,14 +745,14 @@ rust_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
break;
case TYPE_CODE_STRUCT:
- val_print_struct (type, valaddr, embedded_offset, address, stream,
- recurse, val, options);
+ val_print_struct (type, embedded_offset, address, stream,
+ recurse, val, options);
break;
default:
generic_print:
/* Nothing special yet. */
- generic_val_print (type, valaddr, embedded_offset, address, stream,
+ generic_val_print (type, embedded_offset, address, stream,
recurse, val, options, &rust_decorations);
}
}
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 9054e20f475..bd2d4f7bcf4 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -2048,13 +2048,13 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
get_formatted_print_options (&opts, 'x');
opts.deref_ref = 1;
val_print (register_type (gdbarch, regnum),
- value_contents_for_printing (val), 0, 0,
+ 0, 0,
file, 0, val, &opts, current_language);
fprintf_filtered (file, "\t");
get_formatted_print_options (&opts, 0);
opts.deref_ref = 1;
val_print (register_type (gdbarch, regnum),
- value_contents_for_printing (val), 0, 0,
+ 0, 0,
file, 0, val, &opts, current_language);
fprintf_filtered (file, "\n");
}
diff --git a/gdb/valprint.c b/gdb/valprint.c
index ca30a7f945c..b18ece371c5 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -421,10 +421,10 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
/* generic_val_print helper for TYPE_CODE_ARRAY. */
static void
-generic_val_print_array (struct type *type, const gdb_byte *valaddr,
+generic_val_print_array (struct type *type,
int embedded_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
generic_val_print_decorations *decorations)
@@ -445,7 +445,7 @@ generic_val_print_array (struct type *type, const gdb_byte *valaddr,
}
fputs_filtered (decorations->array_start, stream);
- val_print_array_elements (type, valaddr, embedded_offset,
+ val_print_array_elements (type, embedded_offset,
address, stream,
recurse, original_value, options, 0);
fputs_filtered (decorations->array_end, stream);
@@ -462,9 +462,9 @@ generic_val_print_array (struct type *type, const gdb_byte *valaddr,
/* generic_val_print helper for TYPE_CODE_PTR. */
static void
-generic_val_print_ptr (struct type *type, const gdb_byte *valaddr,
+generic_val_print_ptr (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
@@ -472,13 +472,14 @@ generic_val_print_ptr (struct type *type, const gdb_byte *valaddr,
if (options->format && options->format != 's')
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
}
else
{
struct type *unresolved_elttype = TYPE_TARGET_TYPE(type);
struct type *elttype = check_typedef (unresolved_elttype);
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
CORE_ADDR addr = unpack_pointer (type,
valaddr + embedded_offset * unit_size);
@@ -490,12 +491,12 @@ generic_val_print_ptr (struct type *type, const gdb_byte *valaddr,
/* generic_val_print helper for TYPE_CODE_MEMBERPTR. */
static void
-generic_val_print_memberptr (struct type *type, const gdb_byte *valaddr,
+generic_val_print_memberptr (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
}
@@ -538,9 +539,9 @@ get_value_addr_contents (struct value *deref_val)
/* generic_val_print helper for TYPE_CODE_REF. */
static void
-generic_val_print_ref (struct type *type, const gdb_byte *valaddr,
+generic_val_print_ref (struct type *type,
int embedded_offset, struct ui_file *stream, int recurse,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
@@ -552,6 +553,7 @@ generic_val_print_ref (struct type *type, const gdb_byte *valaddr,
const int must_coerce_ref = ((options->addressprint && value_is_synthetic)
|| options->deref_ref);
const int type_is_defined = TYPE_CODE (elttype) != TYPE_CODE_UNDEF;
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
if (must_coerce_ref && type_is_defined)
{
@@ -663,9 +665,9 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
/* generic_val_print helper for TYPE_CODE_ENUM. */
static void
-generic_val_print_enum (struct type *type, const gdb_byte *valaddr,
+generic_val_print_enum (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
LONGEST val;
@@ -674,45 +676,53 @@ generic_val_print_enum (struct type *type, const gdb_byte *valaddr,
if (options->format)
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
- return;
}
- val = unpack_long (type, valaddr + embedded_offset * unit_size);
+ else
+ {
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
+ val = unpack_long (type, valaddr + embedded_offset * unit_size);
- generic_val_print_enum_1 (type, val, stream);
+ generic_val_print_enum_1 (type, val, stream);
+ }
}
/* generic_val_print helper for TYPE_CODE_FLAGS. */
static void
-generic_val_print_flags (struct type *type, const gdb_byte *valaddr,
+generic_val_print_flags (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
if (options->format)
- val_print_scalar_formatted (type, valaddr, embedded_offset, original_value,
+ val_print_scalar_formatted (type, embedded_offset, original_value,
options, 0, stream);
else
- val_print_type_code_flags (type, valaddr + embedded_offset, stream);
+ {
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
+ val_print_type_code_flags (type, valaddr + embedded_offset, stream);
+ }
}
/* generic_val_print helper for TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
static void
-generic_val_print_func (struct type *type, const gdb_byte *valaddr,
+generic_val_print_func (struct type *type,
int embedded_offset, CORE_ADDR address,
struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
if (options->format)
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
}
else
@@ -731,9 +741,9 @@ generic_val_print_func (struct type *type, const gdb_byte *valaddr,
/* generic_val_print helper for TYPE_CODE_BOOL. */
static void
-generic_val_print_bool (struct type *type, const gdb_byte *valaddr,
+generic_val_print_bool (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options,
const struct generic_val_print_decorations *decorations)
{
@@ -746,11 +756,13 @@ generic_val_print_bool (struct type *type, const gdb_byte *valaddr,
struct value_print_options opts = *options;
opts.format = (options->format ? options->format
: options->output_format);
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, &opts, 0, stream);
}
else
{
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
val = unpack_long (type, valaddr + embedded_offset * unit_size);
if (val == 0)
fputs_filtered (decorations->false_name, stream);
@@ -764,9 +776,9 @@ generic_val_print_bool (struct type *type, const gdb_byte *valaddr,
/* generic_val_print helper for TYPE_CODE_INT. */
static void
-generic_val_print_int (struct type *type, const gdb_byte *valaddr,
+generic_val_print_int (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
@@ -778,21 +790,25 @@ generic_val_print_int (struct type *type, const gdb_byte *valaddr,
opts.format = (options->format ? options->format
: options->output_format);
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, &opts, 0, stream);
}
else
- val_print_type_code_int (type, valaddr + embedded_offset * unit_size,
- stream);
+ {
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
+ val_print_type_code_int (type, valaddr + embedded_offset * unit_size,
+ stream);
+ }
}
/* generic_val_print helper for TYPE_CODE_CHAR. */
static void
generic_val_print_char (struct type *type, struct type *unresolved_type,
- const gdb_byte *valaddr, int embedded_offset,
+ int embedded_offset,
struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
LONGEST val;
@@ -805,11 +821,13 @@ generic_val_print_char (struct type *type, struct type *unresolved_type,
opts.format = (options->format ? options->format
: options->output_format);
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, &opts, 0, stream);
}
else
{
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
val = unpack_long (type, valaddr + embedded_offset * unit_size);
if (TYPE_UNSIGNED (type))
fprintf_filtered (stream, "%u", (unsigned int) val);
@@ -823,9 +841,9 @@ generic_val_print_char (struct type *type, struct type *unresolved_type,
/* generic_val_print helper for TYPE_CODE_FLT. */
static void
-generic_val_print_float (struct type *type, const gdb_byte *valaddr,
+generic_val_print_float (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
@@ -833,11 +851,13 @@ generic_val_print_float (struct type *type, const gdb_byte *valaddr,
if (options->format)
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
}
else
{
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
print_floating (valaddr + embedded_offset * unit_size, type, stream);
}
}
@@ -845,38 +865,43 @@ generic_val_print_float (struct type *type, const gdb_byte *valaddr,
/* generic_val_print helper for TYPE_CODE_DECFLOAT. */
static void
-generic_val_print_decfloat (struct type *type, const gdb_byte *valaddr,
+generic_val_print_decfloat (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
if (options->format)
- val_print_scalar_formatted (type, valaddr, embedded_offset, original_value,
+ val_print_scalar_formatted (type, embedded_offset, original_value,
options, 0, stream);
else
- print_decimal_floating (valaddr + embedded_offset * unit_size, type,
- stream);
+ {
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
+ print_decimal_floating (valaddr + embedded_offset * unit_size, type,
+ stream);
+ }
}
/* generic_val_print helper for TYPE_CODE_COMPLEX. */
static void
-generic_val_print_complex (struct type *type, const gdb_byte *valaddr,
+generic_val_print_complex (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options,
const struct generic_val_print_decorations
*decorations)
{
struct gdbarch *gdbarch = get_type_arch (type);
int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
fprintf_filtered (stream, "%s", decorations->complex_prefix);
if (options->format)
- val_print_scalar_formatted (TYPE_TARGET_TYPE (type), valaddr,
+ val_print_scalar_formatted (TYPE_TARGET_TYPE (type),
embedded_offset, original_value, options, 0,
stream);
else
@@ -884,7 +909,7 @@ generic_val_print_complex (struct type *type, const gdb_byte *valaddr,
TYPE_TARGET_TYPE (type), stream);
fprintf_filtered (stream, "%s", decorations->complex_infix);
if (options->format)
- val_print_scalar_formatted (TYPE_TARGET_TYPE (type), valaddr,
+ val_print_scalar_formatted (TYPE_TARGET_TYPE (type),
embedded_offset
+ type_length_units (TYPE_TARGET_TYPE (type)),
original_value, options, 0, stream);
@@ -907,10 +932,10 @@ generic_val_print_complex (struct type *type, const gdb_byte *valaddr,
output in some small, language-specific ways. */
void
-generic_val_print (struct type *type, const gdb_byte *valaddr,
+generic_val_print (struct type *type,
int embedded_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 generic_val_print_decorations *decorations)
{
@@ -920,43 +945,43 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
- generic_val_print_array (type, valaddr, embedded_offset, address, stream,
+ generic_val_print_array (type, embedded_offset, address, stream,
recurse, original_value, options, decorations);
break;
case TYPE_CODE_MEMBERPTR:
- generic_val_print_memberptr (type, valaddr, embedded_offset, stream,
+ generic_val_print_memberptr (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_PTR:
- generic_val_print_ptr (type, valaddr, embedded_offset, stream,
+ generic_val_print_ptr (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_REF:
- generic_val_print_ref (type, valaddr, embedded_offset, stream, recurse,
+ generic_val_print_ref (type, embedded_offset, stream, recurse,
original_value, options);
break;
case TYPE_CODE_ENUM:
- generic_val_print_enum (type, valaddr, embedded_offset, stream,
+ generic_val_print_enum (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_FLAGS:
- generic_val_print_flags (type, valaddr, embedded_offset, stream,
+ generic_val_print_flags (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_FUNC:
case TYPE_CODE_METHOD:
- generic_val_print_func (type, valaddr, embedded_offset, address, stream,
+ generic_val_print_func (type, embedded_offset, address, stream,
original_value, options);
break;
case TYPE_CODE_BOOL:
- generic_val_print_bool (type, valaddr, embedded_offset, stream,
+ generic_val_print_bool (type, embedded_offset, stream,
original_value, options, decorations);
break;
@@ -972,22 +997,22 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
/* FALLTHROUGH */
case TYPE_CODE_INT:
- generic_val_print_int (type, valaddr, embedded_offset, stream,
+ generic_val_print_int (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_CHAR:
- generic_val_print_char (type, unresolved_type, valaddr, embedded_offset,
+ generic_val_print_char (type, unresolved_type, embedded_offset,
stream, original_value, options);
break;
case TYPE_CODE_FLT:
- generic_val_print_float (type, valaddr, embedded_offset, stream,
+ generic_val_print_float (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_DECFLOAT:
- generic_val_print_decfloat (type, valaddr, embedded_offset, stream,
+ generic_val_print_decfloat (type, embedded_offset, stream,
original_value, options);
break;
@@ -1007,7 +1032,7 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
break;
case TYPE_CODE_COMPLEX:
- generic_val_print_complex (type, valaddr, embedded_offset, stream,
+ generic_val_print_complex (type, embedded_offset, stream,
original_value, options, decorations);
break;
@@ -1022,15 +1047,14 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
}
/* Print using the given LANGUAGE the data of type TYPE located at
- VALADDR + EMBEDDED_OFFSET (within GDB), which came from the
- inferior at address ADDRESS + EMBEDDED_OFFSET, onto stdio stream
- STREAM according to OPTIONS. VAL is the whole object that came
- from ADDRESS. VALADDR must point to the head of VAL's contents
- buffer.
+ VAL's contents buffer + EMBEDDED_OFFSET (within GDB), which came
+ from the inferior at address ADDRESS + EMBEDDED_OFFSET, onto
+ stdio stream STREAM according to OPTIONS. VAL is the whole object
+ that came from ADDRESS.
The language printers will pass down an adjusted EMBEDDED_OFFSET to
further helper subroutines as subfields of TYPE are printed. In
- such cases, VALADDR is passed down unadjusted, as well as VAL, so
+ such cases, VAL is passed down unadjusted, so
that VAL can be queried for metadata about the contents data being
printed, using EMBEDDED_OFFSET as an offset into VAL's contents
buffer. For example: "has this field been optimized out", or "I'm
@@ -1042,9 +1066,9 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
RECURSE. */
void
-val_print (struct type *type, const gdb_byte *valaddr, LONGEST embedded_offset,
+val_print (struct type *type, LONGEST embedded_offset,
CORE_ADDR address, struct ui_file *stream, int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
const struct language_defn *language)
{
@@ -1074,6 +1098,8 @@ val_print (struct type *type, const gdb_byte *valaddr, LONGEST embedded_offset,
if (!options->raw)
{
+ const gdb_byte *valaddr = value_contents_for_printing (val);
+
ret = apply_ext_lang_val_pretty_printer (type, valaddr, embedded_offset,
address, stream, recurse,
val, options, language);
@@ -1091,7 +1117,7 @@ val_print (struct type *type, const gdb_byte *valaddr, LONGEST embedded_offset,
TRY
{
- language->la_val_print (type, valaddr, embedded_offset, address,
+ language->la_val_print (type, embedded_offset, address,
stream, recurse, val,
&local_opts);
}
@@ -1177,7 +1203,7 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse,
get a fixed representation of our value. */
val = ada_to_fixed_value (val);
- 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);
@@ -1303,8 +1329,8 @@ val_print_type_code_flags (struct type *type, const gdb_byte *valaddr,
void
val_print_scalar_formatted (struct type *type,
- const gdb_byte *valaddr, LONGEST embedded_offset,
- const struct value *val,
+ LONGEST embedded_offset,
+ struct value *val,
const struct value_print_options *options,
int size,
struct ui_file *stream)
@@ -1313,7 +1339,6 @@ val_print_scalar_formatted (struct type *type,
int unit_size = gdbarch_addressable_memory_unit_size (arch);
gdb_assert (val != NULL);
- gdb_assert (valaddr == value_contents_for_printing_const (val));
/* If we get here with a string format, try again without it. Go
all the way back to the language printers, which may call us
@@ -1323,11 +1348,16 @@ val_print_scalar_formatted (struct type *type,
struct value_print_options opts = *options;
opts.format = 0;
opts.deref_ref = 0;
- val_print (type, valaddr, embedded_offset, 0, stream, 0, val, &opts,
+ val_print (type, embedded_offset, 0, stream, 0, val, &opts,
current_language);
return;
}
+ /* value_contents_for_printing fetches all VAL's contents. They are
+ needed to check whether VAL is optimized-out or unavailable
+ below. */
+ const gdb_byte *valaddr = value_contents_for_printing (val);
+
/* A scalar object that does not have all bits available can't be
printed, because all bits contribute to its representation. */
if (value_bits_any_optimized_out (val,
@@ -1965,10 +1995,10 @@ maybe_print_array_index (struct type *index_type, LONGEST index,
void
val_print_array_elements (struct type *type,
- const gdb_byte *valaddr, LONGEST embedded_offset,
+ LONGEST embedded_offset,
CORE_ADDR address, struct ui_file *stream,
int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
unsigned int i)
{
@@ -2066,7 +2096,7 @@ val_print_array_elements (struct type *type,
if (reps > options->repeat_count_threshold)
{
- val_print (elttype, valaddr, embedded_offset + i * eltlen,
+ val_print (elttype, embedded_offset + i * eltlen,
address, stream, recurse + 1, val, options,
current_language);
annotate_elt_rep (reps);
@@ -2078,7 +2108,7 @@ val_print_array_elements (struct type *type,
}
else
{
- val_print (elttype, valaddr, embedded_offset + i * eltlen,
+ val_print (elttype, embedded_offset + i * eltlen,
address,
stream, recurse + 1, val, options, current_language);
annotate_elt ();
diff --git a/gdb/valprint.h b/gdb/valprint.h
index a0f7391a69d..8b640f97ede 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -115,9 +115,9 @@ extern void maybe_print_array_index (struct type *index_type, LONGEST index,
struct ui_file *stream,
const struct value_print_options *);
-extern void val_print_array_elements (struct type *, const gdb_byte *, LONGEST,
+extern void val_print_array_elements (struct type *, LONGEST,
CORE_ADDR, struct ui_file *, int,
- const struct value *,
+ struct value *,
const struct value_print_options *,
unsigned int);
@@ -125,8 +125,8 @@ extern void val_print_type_code_int (struct type *, const gdb_byte *,
struct ui_file *);
extern void val_print_scalar_formatted (struct type *,
- const gdb_byte *, LONGEST,
- const struct value *,
+ LONGEST,
+ struct value *,
const struct value_print_options *,
int,
struct ui_file *);
@@ -193,10 +193,10 @@ struct generic_val_print_decorations
};
-extern void generic_val_print (struct type *type, const gdb_byte *valaddr,
+extern void generic_val_print (struct type *type,
int embedded_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 generic_val_print_decorations *);
diff --git a/gdb/value.h b/gdb/value.h
index 440bc2dda9f..f9625085e23 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1016,10 +1016,10 @@ extern void value_print_array_elements (struct value *val,
extern struct value *value_release_to_mark (const struct value *mark);
-extern void val_print (struct type *type, const gdb_byte *valaddr,
+extern void val_print (struct type *type,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
const struct language_defn *language);