]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Allow indexing of &str in Rust
authorTom Tromey <tom@tromey.com>
Mon, 2 Oct 2017 18:15:52 +0000 (12:15 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 2 Oct 2017 20:06:43 +0000 (14:06 -0600)
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.

gdb/ChangeLog
gdb/rust-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.rust/simple.exp

index f5b265b8a80dba22bb96c0b01851fdecb4daa286..a8820c8abb322525f6e3c58ea88327accc6d69d8 100644 (file)
@@ -1,3 +1,7 @@
+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".
index c5764bf8d124d2bf0175a92eaca939b6103a4cde..a9895feaf158af7c30475f6866a156f6a5c18d63 100644 (file)
@@ -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.  */
index 4348e76187b62ddb246bc9c0408ea873a6a3b367..edc5079146a0b31be99eaa35ba5bed0a9ccaecb0 100644 (file)
@@ -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.
index 403a11b771eee68a0a3f594ffa43f873ebeceea7..1a46317780062415ffd187cd3f725debe8687479 100644 (file)
@@ -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"