summaryrefslogtreecommitdiff
path: root/gdb/go-valprint.c
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
commit23b0f06be43054a9b182e7ea60a763c35302924a (patch)
treef576a6b26248bef41099a9f08885566aebe1dae7 /gdb/go-valprint.c
parent5f56f7cbd22219e84df3caece06f469c5063e5fb (diff)
downloadbinutils-gdb-23b0f06be43054a9b182e7ea60a763c35302924a.tar.gz
Convert Go printing to value-based API
This introduces go_value_print_inner, a modified copy of go_val_print. Unlike some of the other languages, Go was straightforward to convert to the value-based API all at once, so this patch takes that approach. gdb/ChangeLog 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.
Diffstat (limited to 'gdb/go-valprint.c')
-rw-r--r--gdb/go-valprint.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c
index 1648a6c02c0..79b3ad58d5a 100644
--- a/gdb/go-valprint.c
+++ b/gdb/go-valprint.c
@@ -122,3 +122,40 @@ go_val_print (struct type *type, int embedded_offset,
break;
}
}
+
+/* See go-lang.h. */
+
+void
+go_value_print_inner (struct value *val, struct ui_file *stream,
+ int recurse, const struct value_print_options *options)
+{
+ struct type *type = check_typedef (value_type (val));
+
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_STRUCT:
+ {
+ enum go_type go_type = go_classify_struct_type (type);
+
+ switch (go_type)
+ {
+ case GO_TYPE_STRING:
+ if (! options->raw)
+ {
+ print_go_string (type, value_embedded_offset (val),
+ value_address (val),
+ stream, recurse, val, options);
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ /* Fall through. */
+
+ default:
+ c_value_print_inner (val, stream, recurse, options);
+ break;
+ }
+}