Introduce c_value_print_memberptr
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 adds c_value_print_memberptr, a value-based analogue of
c_val_print_memberptr.

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

* c-valprint.c (c_value_print_memberptr): New function.
(c_value_print_inner): Use it.

gdb/ChangeLog
gdb/c-valprint.c

index b5d41ae130f1d18c577b1400f35895bce0205dcb..15d20e18e0b6b2bc54d55173921c11b13d07c4b6 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-13  Tom Tromey  <tom@tromey.com>
+
+       * c-valprint.c (c_value_print_memberptr): New function.
+       (c_value_print_inner): Use it.
+
 2020-03-13  Tom Tromey  <tom@tromey.com>
 
        * c-valprint.c (c_value_print_int): New function.
index 80ba5d7195aee58dc4ad3da446b8b02c4f8cb4eb..d1a0816f43929d3e78eda787abca297bb9d5b56d 100644 (file)
@@ -553,6 +553,23 @@ c_val_print_memberptr (struct type *type, const gdb_byte *valaddr,
     }
 }
 
+/* c_value_print helper for TYPE_CODE_MEMBERPTR.  */
+
+static void
+c_value_print_memberptr (struct value *val, struct ui_file *stream,
+                        int recurse,
+                        const struct value_print_options *options)
+{
+  if (!options->format)
+    {
+      struct type *type = check_typedef (value_type (val));
+      const gdb_byte *valaddr = value_contents_for_printing (val);
+      cp_print_class_member (valaddr, type, stream, "&");
+    }
+  else
+    generic_value_print (val, stream, recurse, options, &c_decorations);
+}
+
 /* See val_print for a description of the various parameters of this
    function; they are identical.  */
 
@@ -667,8 +684,7 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_MEMBERPTR:
-      c_val_print_memberptr (type, valaddr, 0, address, stream,
-                            recurse, val, options);
+      c_value_print_memberptr (val, stream, recurse, options);
       break;
 
     case TYPE_CODE_REF: