diff options
author | Tom Tromey <tom@tromey.com> | 2023-05-17 09:07:50 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-05-17 11:47:16 -0600 |
commit | cd61a1453e685a763bd91b3795a58edd3d9b4f40 (patch) | |
tree | efb4285ba1cdd9ec2d28d024bdbda5243c558599 /gdb/testsuite/gdb.rust | |
parent | 80d4e113d7b9af8a5a36e5ea4399bca86050784f (diff) | |
download | gdb-cd61a1453e685a763bd91b3795a58edd3d9b4f40.zip gdb-cd61a1453e685a763bd91b3795a58edd3d9b4f40.tar.gz gdb-cd61a1453e685a763bd91b3795a58edd3d9b4f40.tar.bz2 |
Special case "&str" in Rust parser
"&str" is an important type in Rust -- it's the type of string
literals. However, the compiler puts it in the DWARF in a funny way.
The slice itself is present and named "&str". However, the Rust
parser doesn't look for types with names like this, but instead tries
to construct them from components. In this case it tries to make a
pointer-to-"str" -- but "str" isn't always available, and in any case
that wouldn't yield the best result.
This patch adds a special case for &str.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22251
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/testsuite/gdb.rust')
-rw-r--r-- | gdb/testsuite/gdb.rust/simple.exp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp index 08ebed3..a615b92 100644 --- a/gdb/testsuite/gdb.rust/simple.exp +++ b/gdb/testsuite/gdb.rust/simple.exp @@ -68,6 +68,9 @@ gdb_test "print simple::Unit{23}" "'}', '\.\.', or identifier expected" gdb_test "print f" " = \"hi bob\"" gdb_test "print fslice" " = \"bob\"" gdb_test "print &f\[3..\]" " = \"bob\"" +gdb_test "whatis f" "type = &str" +gdb_test "print *(&f as *mut &str)" " = \"hi bob\"" \ + "print via cast to &str" gdb_test "print g" " = \\(\\*mut \\\[u8; 6\\\]\\) $hex b\"hi bob\"" gdb_test "ptype g" " = \\*mut \\\[u8; 6\\\]" |