Remove parameter valaddr from la_val_print
authorYao Qi <yao.qi@linaro.org>
Tue, 8 Nov 2016 16:02:42 +0000 (16:02 +0000)
committerYao Qi <yao.qi@linaro.org>
Tue, 8 Nov 2016 16:02:42 +0000 (16:02 +0000)
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.

28 files changed:
gdb/ChangeLog
gdb/ada-lang.h
gdb/ada-valprint.c
gdb/c-lang.h
gdb/c-valprint.c
gdb/cp-valprint.c
gdb/d-lang.h
gdb/d-valprint.c
gdb/f-lang.h
gdb/f-valprint.c
gdb/go-lang.h
gdb/go-valprint.c
gdb/infcmd.c
gdb/language.c
gdb/language.h
gdb/m2-lang.h
gdb/m2-valprint.c
gdb/mi/mi-main.c
gdb/mips-tdep.c
gdb/mt-tdep.c
gdb/p-lang.h
gdb/p-valprint.c
gdb/printcmd.c
gdb/rust-lang.c
gdb/sh64-tdep.c
gdb/valprint.c
gdb/valprint.h
gdb/value.h

index 227431fc0a4d694de2cff055f6d74d695dd05165..7d48cada98b50890cd1f762c3db7dd65b51f743a 100644 (file)
@@ -1,3 +1,87 @@
+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
index 189d696f607711db3e42c35b2e23d72e1a111996..1a538afa0b49ca74d470eb4da5b5c50976fbb5c4 100644 (file)
@@ -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 *,
index bae4e4f881deb0e17b44b5dc4c23d29c0727c7e4..b771382ebb07ec82d5a1a2ecb7018ace77a4ba7d 100644 (file)
@@ -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);
 }
index 8378d4ff36836ab1d9638562ae902841e77ef96e..25cd93cb984472e3206c3b610a769f156acd0fe6 100644 (file)
@@ -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);
 
index 2cb418d4310ef3dbbf8c89476e60e170413d8525..a90da884db84f3dca4ee92cacb9032aa999204d6 100644 (file)
@@ -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,
index 5fb2561798e4b4b67f23b3ff76c3268036618c65..82e505ada8f91dfad7dd2364cac036a4e5f0f2ac 100644 (file)
@@ -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,
index 74be7a5f61f09162192b15ff88292be014b9d378..52f4e6abc6d9f9a53085848ec5700a5307005002 100644 (file)
@@ -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) */
index 620688bd4a818c678bede0cc26e0172017b36e46..109b54f114b381cf14bbf0f8ea73f6c39b25aa11 100644 (file)
    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);
     }
 }
index 827785a0d1768e0351f08e53fc0f1a7b0bdb5432..a0861054567322ae7c13dac5e9b69f0044123f2c 100644 (file)
@@ -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 */
index e1a677e9dd5e70e46ae102c7cc1c0de1b2d7a49c..a39c80171c2cbda7273576f083a154c5922579bc 100644 (file)
@@ -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;
index 5eb298e543e694d103389a30fd63979b3876d23b..fa96f53ac42899385600fd3fe7f45346768df7a1 100644 (file)
@@ -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) */
index 34ed8e09074e58453e40c5146ab540b41c49d743..ad954c1a7c769a70b15c6bde8a8c2e0ccefaca33 100644 (file)
    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;
     }
index c603c01b4c28edd477e5420c95dec1d3f153ff1c..2440c0c78fe0b181a9405416698f8e375e0b25af 100644 (file)
@@ -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);
        }
index 2869d75eedb5e25a4e1556962a31cff6d69eb2db..b6f22ebe4ac57a490541d8ea0cd0830e9c593664 100644 (file)
@@ -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 "
index 758f265cd45e55b64ef46922e8a678cae3ce3eac..5e4fe4c6e03b109dee3698c1e170bc3783d801be 100644 (file)
@@ -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))
 
index b749b21555928d766bcb5cc5831f1b5a1c9e3679..b35a0ca97d86bafd35d025cc87d15ebe7dd4e6eb 100644 (file)
@@ -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,
index a53aa84bd303d4eda10c97dc838734f39669acdd..f43a2d2afe84fb893b63b1cbc2e940eede773e34 100644 (file)
@@ -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;
index abbd31f60e4d0455878b9c54b85dea18e1482835..31b413e38c829f4d5197c821bc53a3eadcbc28fe 100644 (file)
@@ -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);
index c2c88a67070f4badb1f30792790f467d7a4603ac..c0c644298f4c0caa36f6bd9e7ee1a44f86280b62 100644 (file)
@@ -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);
index c08e80567eacb3cd732d92cddb96eb66b8254595..e958cc4663e927d6a0966e07d38b1d4458a4f1a0 100644 (file)
@@ -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);
index 287c0f421cadca10a89a1ac3d068b8d5f6af7231..5d3a685d2881e16fd47f2438252f364b75b4b89e 100644 (file)
@@ -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);
 
index f639e29b6258668f8c8d56e856bd421037e54e95..82abe60c92992f7920f15552e6d60128a41b1160 100644 (file)
@@ -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)
 {
index 23de57cb2137b3ea87d0da603259b6be4e68064a..8f865d2f5de1a725d609b89369a37fbec8dd5aee 100644 (file)
@@ -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);
index 31bbd24c118eccadde3e4f4b74b25724c4ac35b8..295dae11ac5db97a8595d669363eb399370725d0 100644 (file)
@@ -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);
     }
 }
index 9054e20f475a773bbd4cce15c12e144e36d6de6c..bd2d4f7bcf4f740716f5fc5f40ace4d5c3e988d8 100644 (file)
@@ -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");
 }
index ca30a7f945c3dc055964f069ca0f3f68db5baaca..b18ece371c5ea62446aa83782ffd78c316049823 100644 (file)
@@ -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 ();
index a0f7391a69db26843ecc4053f75446a9ee53acd8..8b640f97ede5c68170543af8922dcdead2f97f07 100644 (file)
@@ -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 *);
 
index 440bc2dda9f2ea80192296266c057914aadcabf5..f9625085e23d8b9afc9ebedaa84e5e26481ef0b9 100644 (file)
@@ -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);