Rewrite c_value_print_inner
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 rewrites c_value_print_inner, copying in the body of
c_val_print_inner and adusting as needed.  This will form the base of
future changes to fully convert this to using the value-based API

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

* c-valprint.c (c_value_print_inner): Rewrite.

gdb/ChangeLog
gdb/c-valprint.c

index 227f9a9a1655acc99882ceb2accadbe5ab09504f..9c7113fe87719cb1887b42fad22f4cc35df8d51b 100644 (file)
@@ -1,3 +1,7 @@
+2020-03-13  Tom Tromey  <tom@tromey.com>
+
+       * c-valprint.c (c_value_print_inner): Rewrite.
+
 2020-03-13  Tom Tromey  <tom@tromey.com>
 
        * valprint.c (generic_value_print_complex): New function.
index b5ae3fac48feb8b8014064e78f4c7c0b97febead..1fa33efbcedb3e8a743530ff4968751265aeaa15 100644 (file)
@@ -564,8 +564,67 @@ void
 c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
                     const struct value_print_options *options)
 {
-  c_val_print (value_type (val), value_embedded_offset (val),
-              value_address (val), stream, recurse, val, options);
+  struct type *type = value_type (val);
+  struct type *unresolved_type = type;
+  CORE_ADDR address = value_address (val);
+  const gdb_byte *valaddr = value_contents_for_printing (val);
+
+  type = check_typedef (type);
+  switch (TYPE_CODE (type))
+    {
+    case TYPE_CODE_ARRAY:
+      c_val_print_array (type, valaddr, 0, address, stream,
+                        recurse, val, options);
+      break;
+
+    case TYPE_CODE_METHODPTR:
+      cplus_print_method_ptr (valaddr, type, stream);
+      break;
+
+    case TYPE_CODE_PTR:
+      c_val_print_ptr (type, valaddr, 0, stream, recurse,
+                      val, options);
+      break;
+
+    case TYPE_CODE_UNION:
+      c_val_print_union (type, valaddr, 0, address, stream,
+                        recurse, val, options);
+      break;
+
+    case TYPE_CODE_STRUCT:
+      c_val_print_struct (type, valaddr, 0, address, stream,
+                         recurse, val, options);
+      break;
+
+    case TYPE_CODE_INT:
+      c_val_print_int (type, unresolved_type, valaddr, 0, stream,
+                      val, options);
+      break;
+
+    case TYPE_CODE_MEMBERPTR:
+      c_val_print_memberptr (type, valaddr, 0, address, stream,
+                            recurse, val, options);
+      break;
+
+    case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
+    case TYPE_CODE_ENUM:
+    case TYPE_CODE_FLAGS:
+    case TYPE_CODE_FUNC:
+    case TYPE_CODE_METHOD:
+    case TYPE_CODE_BOOL:
+    case TYPE_CODE_RANGE:
+    case TYPE_CODE_FLT:
+    case TYPE_CODE_DECFLOAT:
+    case TYPE_CODE_VOID:
+    case TYPE_CODE_ERROR:
+    case TYPE_CODE_UNDEF:
+    case TYPE_CODE_COMPLEX:
+    case TYPE_CODE_CHAR:
+    default:
+      generic_value_print (val, stream, recurse, options, &c_decorations);
+      break;
+    }
 }
 
 \f