diff mbox

[37/55] Simplify generic_val_print_float

Message ID 20191208182958.10181-38-tom@tromey.com
State New
Headers show

Commit Message

Tom Tromey Dec. 8, 2019, 6:29 p.m. UTC
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
2019-12-08  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.

Change-Id: I00b73411232adf768c11d0d5271218644a6e390f
---
 gdb/ChangeLog  |  6 ++++++
 gdb/valprint.c | 29 +++++++++++++++--------------
 2 files changed, 21 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 4e65115cf97..630b6567cd0 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -898,17 +898,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.  */
@@ -1047,8 +1041,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:
@@ -1159,8 +1157,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: