summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-10-02 12:15:52 -0600
committerTom Tromey <tom@tromey.com>2017-10-02 14:06:43 -0600
commit01af5e0d09ac9c621e7b280f44a2c7ef55784493 (patch)
treebd93b3095baf09f76ecf92cf5d5e8f818482676f
parent888e3ddb20f541220f18709fce832ad0163c3e71 (diff)
downloadbinutils-gdb-01af5e0d09ac9c621e7b280f44a2c7ef55784493.tar.gz
Allow indexing of &str in Rust
rust_slice_type_p was not recognizing &str as a slice type, so indexing into (or making a slice of) a slice was not working. 2017-10-02 Tom Tromey <tom@tromey.com> * rust-lang.c (rust_slice_type_p): Recognize &str as a slice type. 2017-10-02 Tom Tromey <tom@tromey.com> * gdb.rust/simple.exp: Test index of slice.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/rust-lang.c3
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.rust/simple.exp2
4 files changed, 12 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f5b265b8a80..a8820c8abb3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2017-10-02 Tom Tromey <tom@tromey.com>
+ * rust-lang.c (rust_slice_type_p): Recognize &str as a slice type.
+
+2017-10-02 Tom Tromey <tom@tromey.com>
+
* rust-lang.h (rust_slice_type): Add "extern".
2017-10-02 Tom Tromey <tom@tromey.com>
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index c5764bf8d12..a9895feaf15 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -340,7 +340,8 @@ rust_slice_type_p (struct type *type)
{
return (TYPE_CODE (type) == TYPE_CODE_STRUCT
&& TYPE_TAG_NAME (type) != NULL
- && strncmp (TYPE_TAG_NAME (type), "&[", 2) == 0);
+ && (strncmp (TYPE_TAG_NAME (type), "&[", 2) == 0
+ || strcmp (TYPE_TAG_NAME (type), "&str") == 0));
}
/* Return true if TYPE is a range type, otherwise false. */
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 4348e76187b..edc5079146a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2017-10-02 Tom Tromey <tom@tromey.com>
+
+ * gdb.rust/simple.exp: Test index of slice.
+
2017-09-27 Tom Tromey <tom@tromey.com>
* gdb.base/macscp.exp: Add __VA_OPT__ tests.
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp
index 403a11b771e..1a463177800 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -55,6 +55,8 @@ gdb_test "print *(&c as &i32)" " = 0"
gdb_test "print *(&c as *const i32)" " = 0"
gdb_test "print *(&c as *mut i32)" " = 0"
+gdb_test "print/c f\[0\]" " = 104 'h'"
+
gdb_test "print j" " = simple::Unit"
gdb_test "ptype j" " = struct simple::Unit"
gdb_test "print j2" " = simple::Unit"