Simplify generic_val_print_func
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 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
2020-03-13  Tom Tromey  <tom@tromey.com>

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

gdb/ChangeLog
gdb/valprint.c

index 38e9fb7e4833c58249ef80fca3a9c25a74991b68..c969b12bcad076e435507ad403a3ed1d4f8fbc72 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-13  Tom Tromey  <tom@tromey.com>
+
+       * valprint.c (generic_val_print_func): Simplify.
+       (generic_val_print, generic_value_print): Update.
+
 2020-03-13  Tom Tromey  <tom@tromey.com>
 
        * valprint.c (generic_val_print_flags): Remove.
index 499d03f16dcc6d7d711c0165d7bd38e969bacafd..0517bf089f3c7e20b9b234a7dbf914e379e7fa11 100644 (file)
@@ -742,22 +742,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.  */
@@ -971,8 +965,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:
@@ -1084,8 +1082,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: