From patchwork Mon Oct 2 20:10:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 23284 Received: (qmail 12120 invoked by alias); 2 Oct 2017 20:11:00 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 11847 invoked by uid 89); 2 Oct 2017 20:10:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gproxy4-pub.mail.unifiedlayer.com Received: from gproxy4-pub.mail.unifiedlayer.com (HELO gproxy4-pub.mail.unifiedlayer.com) (69.89.23.142) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Oct 2017 20:10:58 +0000 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy4.mail.unifiedlayer.com (Postfix) with ESMTP id E9C93176071 for ; Mon, 2 Oct 2017 14:10:56 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id GkAt1w00l2f2jeq01kAwBs; Mon, 02 Oct 2017 14:10:56 -0600 X-Authority-Analysis: v=2.2 cv=K4VSJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=02M-m0pO-4AA:10 a=zstS-IiYAAAA:8 a=b1FHsT970dd0kW40S9UA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-0-208.hlrn.qwest.net ([75.166.0.208]:55566 helo=pokyo.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dz73F-003jcm-Fm; Mon, 02 Oct 2017 14:10:53 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI 1/3] Allow indexing of &str in Rust Date: Mon, 2 Oct 2017 14:10:39 -0600 Message-Id: <20171002201041.4815-2-tom@tromey.com> In-Reply-To: <20171002201041.4815-1-tom@tromey.com> References: <20171002201041.4815-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dz73F-003jcm-Fm X-Source-Sender: 75-166-0-208.hlrn.qwest.net (pokyo.Home) [75.166.0.208]:55566 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes 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 * rust-lang.c (rust_slice_type_p): Recognize &str as a slice type. 2017-10-02 Tom Tromey * gdb.rust/simple.exp: Test index of slice. --- gdb/ChangeLog | 4 ++++ gdb/rust-lang.c | 3 ++- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.rust/simple.exp | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f5b265b..a8820c8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2017-10-02 Tom Tromey + * rust-lang.c (rust_slice_type_p): Recognize &str as a slice type. + +2017-10-02 Tom Tromey + * rust-lang.h (rust_slice_type): Add "extern". 2017-10-02 Tom Tromey diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index c5764bf..a9895fe 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 4348e76..edc5079 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-10-02 Tom Tromey + + * gdb.rust/simple.exp: Test index of slice. + 2017-09-27 Tom Tromey * 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 403a11b..1a46317 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"