aboutsummaryrefslogtreecommitdiff
path: root/gdb
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:40 -0600
commitd133c3e1a877259bbee460897d9a6a2820ffe451 (patch)
tree6d0b51c75ff0f04eb258400b4bc6438067094172 /gdb
parent23b0f06be43054a9b182e7ea60a763c35302924a (diff)
downloadgdb-d133c3e1a877259bbee460897d9a6a2820ffe451.zip
gdb-d133c3e1a877259bbee460897d9a6a2820ffe451.tar.gz
gdb-d133c3e1a877259bbee460897d9a6a2820ffe451.tar.bz2
Convert D printing to value-based API
As with Rust and Go, it was straightforward to convert D to the value-based API directly. gdb/ChangeLog 2020-03-13 Tom Tromey <tom@tromey.com> * d-valprint.c (dynamic_array_type): Call d_value_print_inner. (d_value_print_inner): New function. * d-lang.h (d_value_print_inner): Declare. * d-lang.c (d_language_defn): Use d_value_print_inner.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/d-lang.c2
-rw-r--r--gdb/d-lang.h6
-rw-r--r--gdb/d-valprint.c28
4 files changed, 39 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 862d4bc..892ad87 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2020-03-13 Tom Tromey <tom@tromey.com>
+ * d-valprint.c (dynamic_array_type): Call d_value_print_inner.
+ (d_value_print_inner): New function.
+ * d-lang.h (d_value_print_inner): Declare.
+ * d-lang.c (d_language_defn): Use d_value_print_inner.
+
+2020-03-13 Tom Tromey <tom@tromey.com>
+
* go-valprint.c (go_value_print_inner): New function.
* go-lang.h (go_value_print_inner): Declare.
* go-lang.c (go_language_defn): Use go_value_print_inner.
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 71dc4c6..4dbcf53 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -225,7 +225,7 @@ extern const struct language_defn d_language_defn =
c_print_typedef, /* Print a typedef using appropriate
syntax. */
d_val_print, /* Print a value using appropriate syntax. */
- nullptr, /* la_value_print_inner */
+ d_value_print_inner, /* la_value_print_inner */
c_value_print, /* Print a top-level value. */
default_read_var_value, /* la_read_var_value */
NULL, /* Language specific skip_trampoline. */
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index 88e1ea3..9b4e504 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -84,4 +84,10 @@ extern void d_val_print (struct type *type,
struct value *val,
const struct value_print_options *options);
+/* Implement la_value_print_inner for D. */
+
+extern void d_value_print_inner (struct value *val,
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options);
+
#endif /* !defined (D_LANG_H) */
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index b499121..e26c1ea 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -63,9 +63,7 @@ dynamic_array_type (struct type *type,
ival = value_at (true_type, addr);
true_type = value_type (ival);
- d_val_print (true_type,
- value_embedded_offset (ival), addr,
- stream, recurse + 1, ival, options);
+ d_value_print_inner (ival, stream, recurse + 1, options);
return 0;
}
return 1;
@@ -94,3 +92,27 @@ d_val_print (struct type *type, int embedded_offset,
recurse, val, options);
}
}
+
+/* See d-lang.h. */
+
+void
+d_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
+{
+ int ret;
+
+ struct type *type = check_typedef (value_type (val));
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_STRUCT:
+ ret = dynamic_array_type (type, value_embedded_offset (val),
+ value_address (val),
+ stream, recurse, val, options);
+ if (ret == 0)
+ break;
+ /* Fall through. */
+ default:
+ c_value_print_inner (val, stream, recurse, options);
+ break;
+ }
+}