Factor out memberptr printing code from c_val_print
authorSimon Marchi <simon.marchi@ericsson.com>
Thu, 9 Jul 2015 15:19:25 +0000 (11:19 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Thu, 9 Jul 2015 15:24:57 +0000 (11:24 -0400)
gdb/ChangeLog:

* c-valprint.c (c_val_print): Factor out memberptr printing code
from c_val_print to ...
(c_val_print_memberptr): ... this new function.

gdb/ChangeLog
gdb/c-valprint.c

index 8a6a2ace13e0832f8ca8e8f4d602e15f8b3f995e..b5b80a39cc61adfe47d2bdb48e7657dde5e2d4e8 100644 (file)
@@ -1,3 +1,9 @@
+2015-07-09  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * c-valprint.c (c_val_print): Factor out memberptr printing code
+       from c_val_print to ...
+       (c_val_print_memberptr): ... this new function.
+
 2015-07-09  Simon Marchi  <simon.marchi@ericsson.com>
 
        * c-valprint.c (c_val_print): Factor out int printing code to ...
index 0a61d7a6151eaa8d346f44b2d1539fd047d54dda..d76a206e25f5e108e858e9b83464e0743e95a3ac 100644 (file)
@@ -456,6 +456,26 @@ c_val_print_int (struct type *type, struct type *unresolved_type,
     }
 }
 
+/* c_val_print helper for TYPE_CODE_MEMBERPTR.  */
+
+static void
+c_val_print_memberptr (struct type *type, const gdb_byte *valaddr,
+                      int embedded_offset, CORE_ADDR address,
+                      struct ui_file *stream, int recurse,
+                      const struct value *original_value,
+                      const struct value_print_options *options)
+{
+  if (!options->format)
+    {
+      cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
+    }
+  else
+    {
+      generic_val_print (type, valaddr, embedded_offset, address, stream,
+                        recurse, original_value, options, &c_decorations);
+    }
+}
+
 /* See val_print for a description of the various parameters of this
    function; they are identical.  */
 
@@ -501,12 +521,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_MEMBERPTR:
-      if (!options->format)
-       {
-         cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
-         break;
-       }
-      /* FALLTHROUGH */
+      c_val_print_memberptr (type, valaddr, embedded_offset, address, stream,
+                            recurse, original_value, options);
+      break;
 
     case TYPE_CODE_REF:
     case TYPE_CODE_ENUM: