Simplify generic_val_print_float
authorTom Tromey <tom@tromey.com>
Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 14 Mar 2020 00:03:41 +0000 (18:03 -0600)
This changes generic_val_print_float not to call
val_print_scalar_formatted.  This lets generic_value_print then use
value_print_scalar_formatted instead.

gdb/ChangeLog
2020-03-13  Tom Tromey  <tom@tromey.com>

* valprint.c (generic_val_print_float): Don't call
val_print_scalar_formatted.
(generic_val_print, generic_value_print): Update.

gdb/ChangeLog
gdb/valprint.c

index ccf0d1e421dc37ae2849d19f32db35acafab8c9f..c2b0550420fc4b699b5c0ff2b8d8dece2edcbcf0 100644 (file)
@@ -1,3 +1,9 @@
+2020-03-13  Tom Tromey  <tom@tromey.com>
+
+       * valprint.c (generic_val_print_float): Don't call
+       val_print_scalar_formatted.
+       (generic_val_print, generic_value_print): Update.
+
 2020-03-13  Tom Tromey  <tom@tromey.com>
 
        * valprint.c (generic_value_print_char): New function
index 8c2d1aa1955f1dc602bbcea24c3f832f5108567b..f759e0aacb3696897e0ad3d311aa6d17d4e4250f 100644 (file)
@@ -924,17 +924,11 @@ generic_val_print_float (struct type *type,
   struct gdbarch *gdbarch = get_type_arch (type);
   int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
 
-  if (options->format)
-    {
-      val_print_scalar_formatted (type, embedded_offset,
-                                 original_value, options, 0, stream);
-    }
-  else
-    {
-      const gdb_byte *valaddr = value_contents_for_printing (original_value);
+  gdb_assert (!options->format);
 
-      print_floating (valaddr + embedded_offset * unit_size, type, stream);
-    }
+  const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
+  print_floating (valaddr + embedded_offset * unit_size, type, stream);
 }
 
 /* generic_val_print helper for TYPE_CODE_COMPLEX.  */
@@ -1073,8 +1067,12 @@ generic_val_print (struct type *type,
 
     case TYPE_CODE_FLT:
     case TYPE_CODE_DECFLOAT:
-      generic_val_print_float (type, embedded_offset, stream,
-                              original_value, options);
+      if (options->format)
+       val_print_scalar_formatted (type, embedded_offset,
+                                   original_value, options, 0, stream);
+      else
+       generic_val_print_float (type, embedded_offset, stream,
+                                original_value, options);
       break;
 
     case TYPE_CODE_VOID:
@@ -1185,8 +1183,11 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
 
     case TYPE_CODE_FLT:
     case TYPE_CODE_DECFLOAT:
-      generic_val_print_float (type, 0, stream,
-                              val, options);
+      if (options->format)
+       value_print_scalar_formatted (val, options, 0, stream);
+      else
+       generic_val_print_float (type, 0, stream,
+                                val, options);
       break;
 
     case TYPE_CODE_VOID: