Remove val_print_type_code_int
authorTom Tromey <tom@tromey.com>
Mon, 22 May 2017 22:55:18 +0000 (16:55 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 12 Jun 2017 21:04:58 +0000 (15:04 -0600)
Now that print_scalar_formatted is more capable, there's no need for
val_print_type_code_int.  This patch removes it in favor of
val_print_scalar_formatted.

2017-06-12  Tom Tromey  <tom@tromey.com>

* valprint.h (val_print_type_code_int): Remove.
* valprint.c (generic_val_print_int): Always call
val_print_scalar_formatted.
(val_print_type_code_int): Remove.
* printcmd.c (print_scalar_formatted): Handle options->format==0.
* f-valprint.c (f_val_print): Use val_print_scalar_formatted.
* c-valprint.c (c_val_print_int): Use val_print_scalar_formatted.
* ada-valprint.c (ada_val_print_num): Use
val_print_scalar_formatted.

gdb/ChangeLog
gdb/ada-valprint.c
gdb/c-valprint.c
gdb/f-valprint.c
gdb/valprint.c
gdb/valprint.h

index ec006f51e75f8f28dd03d96284b2e4770a8b2ba3..29568194c117f22810504e29f23cfecd141f5256 100644 (file)
@@ -1,3 +1,15 @@
+2017-06-12  Tom Tromey  <tom@tromey.com>
+
+       * valprint.h (val_print_type_code_int): Remove.
+       * valprint.c (generic_val_print_int): Always call
+       val_print_scalar_formatted.
+       (val_print_type_code_int): Remove.
+       * printcmd.c (print_scalar_formatted): Handle options->format==0.
+       * f-valprint.c (f_val_print): Use val_print_scalar_formatted.
+       * c-valprint.c (c_val_print_int): Use val_print_scalar_formatted.
+       * ada-valprint.c (ada_val_print_num): Use
+       val_print_scalar_formatted.
+
 2017-06-12  Tom Tromey  <tom@tromey.com>
 
        * printcmd.c (print_scalar_formatted): Unify the two switches.
index d2489a2b2e8ff63e174c42872d43cb0f7ae06f73..8095eede72192c1d29795e7d4cdd2fe7be3b1ce4 100644 (file)
@@ -859,7 +859,8 @@ ada_val_print_num (struct type *type, const gdb_byte *valaddr,
        }
       else
        {
-         val_print_type_code_int (type, valaddr + offset_aligned, stream);
+         val_print_scalar_formatted (type, offset_aligned,
+                                     original_value, options, 0, stream);
          if (ada_is_character_type (type))
            {
              LONGEST c;
index ab1de5cf9e8fd21fbe1a599c73d5935f62185563..653fed657a979f7ffaae615c27a4ff0a983b1140 100644 (file)
@@ -454,8 +454,8 @@ c_val_print_int (struct type *type, struct type *unresolved_type,
     }
   else
     {
-      val_print_type_code_int (type, valaddr + embedded_offset * unit_size,
-                              stream);
+      val_print_scalar_formatted (type, embedded_offset,
+                                 original_value, options, 0, stream);
       /* C and C++ has no single byte int type, char is used
         instead.  Since we don't know whether the value is really
         intended to be used as an integer or a character, print
index a51740631deac3312022256a2269970993db9695..4234447bbb6a9c40c7cec9f346317acf9a1d95b1 100644 (file)
@@ -311,7 +311,8 @@ f_val_print (struct type *type, int embedded_offset,
        }
       else
        {
-         val_print_type_code_int (type, valaddr + embedded_offset, stream);
+         val_print_scalar_formatted (type, embedded_offset,
+                                     original_value, options, 0, stream);
          /* C and C++ has no single byte int type, char is used instead.
             Since we don't know whether the value is really intended to
             be used as an integer or a character, print the character
index 2420fb5c96cde28edf34e1326d0ee134241c5f14..e627e859929d0533f6ece993ac36699629c37a8a 100644 (file)
@@ -781,25 +781,12 @@ generic_val_print_int (struct type *type,
                       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 || options->output_format)
-    {
-      struct value_print_options opts = *options;
-
-      opts.format = (options->format ? options->format
-                    : options->output_format);
-      val_print_scalar_formatted (type, embedded_offset,
-                                 original_value, &opts, 0, stream);
-    }
-  else
-    {
-      const gdb_byte *valaddr = value_contents_for_printing (original_value);
+  struct value_print_options opts = *options;
 
-      val_print_type_code_int (type, valaddr + embedded_offset * unit_size,
-                              stream);
-    }
+  opts.format = (options->format ? options->format
+                : options->output_format);
+  val_print_scalar_formatted (type, embedded_offset,
+                             original_value, &opts, 0, stream);
 }
 
 /* generic_val_print helper for TYPE_CODE_CHAR.  */
@@ -1237,43 +1224,6 @@ value_print (struct value *val, struct ui_file *stream,
   LA_VALUE_PRINT (val, stream, options);
 }
 
-/* Called by various <lang>_val_print routines to print
-   TYPE_CODE_INT's.  TYPE is the type.  VALADDR is the address of the
-   value.  STREAM is where to print the value.  */
-
-void
-val_print_type_code_int (struct type *type, const gdb_byte *valaddr,
-                        struct ui_file *stream)
-{
-  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
-
-  if (TYPE_LENGTH (type) > sizeof (LONGEST))
-    {
-      LONGEST val;
-
-      if (TYPE_UNSIGNED (type)
-         && extract_long_unsigned_integer (valaddr, TYPE_LENGTH (type),
-                                           byte_order, &val))
-       {
-         print_longest (stream, 'u', 0, val);
-       }
-      else
-       {
-         /* Signed, or we couldn't turn an unsigned value into a
-            LONGEST.  For signed values, one could assume two's
-            complement (a reasonable assumption, I think) and do
-            better than this.  */
-         print_hex_chars (stream, (unsigned char *) valaddr,
-                          TYPE_LENGTH (type), byte_order, false);
-       }
-    }
-  else
-    {
-      print_longest (stream, TYPE_UNSIGNED (type) ? 'u' : 'd', 0,
-                    unpack_long (type, valaddr));
-    }
-}
-
 static void
 val_print_type_code_flags (struct type *type, const gdb_byte *valaddr,
                           struct ui_file *stream)
index f71d4ab9eab359fda2bb3adb0eed56a53f95c0b1..302626d9d6a64e0402fa3b8e86f36371acfe804b 100644 (file)
@@ -121,9 +121,6 @@ extern void val_print_array_elements (struct type *, LONGEST,
                                      const struct value_print_options *,
                                      unsigned int);
 
-extern void val_print_type_code_int (struct type *, const gdb_byte *,
-                                    struct ui_file *);
-
 extern void val_print_scalar_formatted (struct type *,
                                        LONGEST,
                                        struct value *,