[47/55] Introduce ada_value_print_ptr

Message ID 20191208182958.10181-48-tom@tromey.com
State New
Headers show
Series
  • Remove val_print
Related show

Commit Message

Tom Tromey Dec. 8, 2019, 6:29 p.m.
This adds ada_value_print_ptr, a value-based analogue of
ada_val_print_ptr.

gdb/ChangeLog
2019-12-08  Tom Tromey  <tom@tromey.com>

	* ada-valprint.c (ada_value_print_ptr): New function.
	(ada_value_print_1): Use it.

Change-Id: I6c70599ebf91c0b0a55b040b0e838cb047d502a3
---
 gdb/ChangeLog      |  5 +++++
 gdb/ada-valprint.c | 24 +++++++++++++++++++++---
 2 files changed, 26 insertions(+), 3 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 83033d9ee8c..b3fb9512f57 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -813,6 +813,26 @@  ada_val_print_ptr (struct type *type, const gdb_byte *valaddr,
     }
 }
 
+/* Implement Ada value_print'ing for the case where TYPE is a
+   TYPE_CODE_PTR.  */
+
+static void
+ada_value_print_ptr (struct value *val,
+		     struct ui_file *stream, int recurse,
+		     const struct value_print_options *options)
+{
+  common_val_print (val, stream, recurse, options, language_def (language_c));
+
+  struct type *type = ada_check_typedef (value_type (val));
+  if (ada_is_tag_type (type))
+    {
+      const char *name = ada_tag_name (val);
+
+      if (name != NULL)
+	fprintf_filtered (stream, " (%s)", name);
+    }
+}
+
 /* Implement Ada val_print'ing for the case where TYPE is
    a TYPE_CODE_INT or TYPE_CODE_RANGE.  */
 
@@ -1254,9 +1274,7 @@  ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_PTR:
-      ada_val_print_ptr (type, valaddr, 0, 0,
-			 address, stream, recurse, val,
-			 options);
+      ada_value_print_ptr (val, stream, recurse, options);
       break;
 
     case TYPE_CODE_INT: