Introduce generic_value_print_ptr
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 introduces generic_value_print_ptr, a value-based analogue of
generic_val_print_ptr, and changes generic_value_print to use it.

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

* valprint.c (generic_value_print): Call generic_value_print_ptr.
* valprint.c (generic_value_print_ptr): New function.

gdb/ChangeLog
gdb/valprint.c

index bfeec8112e6bbf8e10a32dfe06c87565e27f22a9..322d4c77397ca463c887864e42d92463cfb9d1d9 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-13  Tom Tromey  <tom@tromey.com>
+
+       * valprint.c (generic_value_print): Call generic_value_print_ptr.
+       * valprint.c (generic_value_print_ptr): New function.
+
 2020-03-13  Tom Tromey  <tom@tromey.com>
 
        * valprint.c (generic_value_print): Rewrite.
index 50b5a1ff50d9a4b418920242d20e881b8f6ebc2b..0063bb5e0cb908ccd3de02b92b97fbb4d57b06c9 100644 (file)
@@ -489,6 +489,26 @@ generic_val_print_ptr (struct type *type,
     }
 }
 
+/* generic_value_print helper for TYPE_CODE_PTR.  */
+
+static void
+generic_value_print_ptr (struct value *val, struct ui_file *stream,
+                        const struct value_print_options *options)
+{
+
+  if (options->format && options->format != 's')
+    value_print_scalar_formatted (val, options, 0, stream);
+  else
+    {
+      struct type *type = check_typedef (value_type (val));
+      struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
+      const gdb_byte *valaddr = value_contents_for_printing (val);
+      CORE_ADDR addr = unpack_pointer (type, valaddr);
+
+      print_unpacked_pointer (type, elttype, addr, stream, options);
+    }
+}
+
 
 /* generic_val_print helper for TYPE_CODE_MEMBERPTR.  */
 
@@ -1052,13 +1072,11 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_MEMBERPTR:
-      generic_val_print_memberptr (type, 0, stream,
-                                  val, options);
+      value_print_scalar_formatted (val, options, 0, stream);
       break;
 
     case TYPE_CODE_PTR:
-      generic_val_print_ptr (type, 0, stream,
-                            val, options);
+      generic_value_print_ptr (val, stream, options);
       break;
 
     case TYPE_CODE_REF: