[33/55] Simplify generic_val_print_func

Message ID 20191208182958.10181-34-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Dec. 8, 2019, 6:29 p.m. UTC
  This removes the call to val_print_scalar_formatted from
generic_val_print_func, allowing generic_value_print to call the
value-based variant instead.

gdb/ChangeLog
2019-12-08  Tom Tromey  <tom@tromey.com>

	* valprint.c (generic_val_print_func): Simplify.
	(generic_val_print, generic_value_print): Update.

Change-Id: Id93d45b00c4be05e52e1ade15a7e33df206ac7f0
---
 gdb/ChangeLog  |  5 +++++
 gdb/valprint.c | 41 +++++++++++++++++++++--------------------
 2 files changed, 26 insertions(+), 20 deletions(-)
  

Patch

diff --git a/gdb/valprint.c b/gdb/valprint.c
index c6de058fa23..5c25f98faf8 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -716,22 +716,16 @@  generic_val_print_func (struct type *type,
 {
   struct gdbarch *gdbarch = get_type_arch (type);
 
-  if (options->format)
-    {
-      val_print_scalar_formatted (type, embedded_offset,
-				  original_value, options, 0, stream);
-    }
-  else
-    {
-      /* FIXME, we should consider, at least for ANSI C language,
-         eliminating the distinction made between FUNCs and POINTERs
-         to FUNCs.  */
-      fprintf_filtered (stream, "{");
-      type_print (type, "", stream, -1);
-      fprintf_filtered (stream, "} ");
-      /* Try to print what function it points to, and its address.  */
-      print_address_demangle (options, gdbarch, address, stream, demangle);
-    }
+  gdb_assert (!options->format);
+
+  /* FIXME, we should consider, at least for ANSI C language,
+     eliminating the distinction made between FUNCs and POINTERs to
+     FUNCs.  */
+  fprintf_filtered (stream, "{");
+  type_print (type, "", stream, -1);
+  fprintf_filtered (stream, "} ");
+  /* Try to print what function it points to, and its address.  */
+  print_address_demangle (options, gdbarch, address, stream, demangle);
 }
 
 /* generic_val_print helper for TYPE_CODE_BOOL.  */
@@ -945,8 +939,12 @@  generic_val_print (struct type *type,
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
-      generic_val_print_func (type, embedded_offset, address, stream,
-			      original_value, options);
+      if (options->format)
+	val_print_scalar_formatted (type, embedded_offset,
+				    original_value, options, 0, stream);
+      else
+	generic_val_print_func (type, embedded_offset, address, stream,
+				original_value, options);
       break;
 
     case TYPE_CODE_BOOL:
@@ -1058,8 +1056,11 @@  generic_value_print (struct value *val, struct ui_file *stream, int recurse,
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
-      generic_val_print_func (type, 0, value_address (val), stream,
-			      val, options);
+      if (options->format)
+	value_print_scalar_formatted (val, options, 0, stream);
+      else
+	generic_val_print_func (type, 0, value_address (val), stream,
+				val, options);
       break;
 
     case TYPE_CODE_BOOL: