diff options
author | Tom Tromey <tom@tromey.com> | 2018-11-16 15:30:35 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-11-19 11:19:01 -0700 |
commit | 73fc52c4ccecf005aac264e3faa08e815d25118a (patch) | |
tree | b9ed4875e92a738c1c09721254b05658cf3b67e2 /gdb/rust-lang.c | |
parent | 994b876a510ad2ed7e0d34a4c7d08f8039cef6ef (diff) | |
download | gdb-73fc52c4ccecf005aac264e3faa08e815d25118a.zip gdb-73fc52c4ccecf005aac264e3faa08e815d25118a.tar.gz gdb-73fc52c4ccecf005aac264e3faa08e815d25118a.tar.bz2 |
Handle TYPE_CODE_PTR when printing Rust types
This changes the Rust type printers to handle TYPE_CODE_PTR. The
current approach is not ideal, because currently the code can't
distinguish between mut and const, or between pointers and references.
(These are debuginfo deficiencies, for which there are rustc bugs on
file.)
Meanwhile, this at least clears up the case seen in PR rust/23625.
Tested on x86-64 Fedora 28. The nightly compiler gives the best
results, but I regression-tested with stable and beta as well.
gdb/ChangeLog
2018-11-16 Tom Tromey <tom@tromey.com>
PR rust/23625:
* rust-lang.c (rust_internal_print_type): Handle TYPE_CODE_PTR.
gdb/testsuite/ChangeLog
2018-11-19 Tom Tromey <tom@tromey.com>
PR rust/23625:
* gdb.rust/simple.exp: Add ptype test. Update expected output.
* gdb.rust/expr.exp: Update expected output. Change one test.
Diffstat (limited to 'gdb/rust-lang.c')
-rw-r--r-- | gdb/rust-lang.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 152413a..0a327ee 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -918,6 +918,20 @@ rust_internal_print_type (struct type *type, const char *varstring, } break; + case TYPE_CODE_PTR: + { + if (TYPE_NAME (type) != nullptr) + fputs_filtered (TYPE_NAME (type), stream); + else + { + /* We currently can't distinguish between pointers and + references. */ + fputs_filtered ("*mut ", stream); + type_print (TYPE_TARGET_TYPE (type), "", stream, 0); + } + } + break; + default: c_printer: c_print_type (type, varstring, stream, show, level, flags); |