aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-03-13 17:39:52 -0600
committerTom Tromey <tom@tromey.com>2020-03-13 18:03:41 -0600
commit2a5b130bcb6f376b6a28d8378172ed3f9b92e9d9 (patch)
tree1d47b710c1abd592fee84d7921257ae75b47038e
parentabc66ce95eee79db058123b985e19dcfc03dc1a7 (diff)
downloadgdb-2a5b130bcb6f376b6a28d8378172ed3f9b92e9d9.zip
gdb-2a5b130bcb6f376b6a28d8378172ed3f9b92e9d9.tar.gz
gdb-2a5b130bcb6f376b6a28d8378172ed3f9b92e9d9.tar.bz2
Introduce generic_value_print_ptr
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.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/valprint.c26
2 files changed, 27 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bfeec81..322d4c7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
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.
2020-03-13 Tom Tromey <tom@tromey.com>
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 50b5a1f..0063bb5 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -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: