From patchwork Tue Oct 8 10:10:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 34867 Received: (qmail 45316 invoked by alias); 8 Oct 2019 10:10:19 -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 45303 invoked by uid 89); 8 Oct 2019 10:10:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=Four X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Oct 2019 10:10:13 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7A640AEAF; Tue, 8 Oct 2019 10:10:11 +0000 (UTC) Date: Tue, 8 Oct 2019 12:10:09 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH][gdb/testsuite] Add XFAILs in gdb.rust/simple.exp for incorrect DWARF Message-ID: <20191008101007.GA29634@delia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi, On openSUSE Leap 15.1 using rustc version 1.36.0 (using llvm 7), I get: ... (gdb) PASS: gdb.rust/simple.exp: print e2.0 print k^M $54 = simple::SpaceSaver::Thebox(40, 0x0)^M (gdb) FAIL: gdb.rust/simple.exp: print k ... while we're expecting: ... gdb_test "print k" " = simple::SpaceSaver::Nothing" ... When using a relatively recent version of Rust with a somewhat older version of LLVM, the Rust compiler will emit a legacy encoding of enums (see also quirk_rust_enum in dwarf2read.c). So, the variable k: ... <17><3d58>: Abbrev Number: 15 (DW_TAG_variable) <3d59> DW_AT_location : 3 byte block: 91 b8 4 (DW_OP_fbreg: 568) <3d5d> DW_AT_name : (indirect string, offset: 0xf9a): k <3d61> DW_AT_alignment : 1 <3d62> DW_AT_decl_file : 1 <3d63> DW_AT_decl_line : 129 <3d64> DW_AT_type : <0x4232> ... has type: ... <2><4232>: Abbrev Number: 11 (DW_TAG_union_type) <4233> DW_AT_name : (indirect string, offset: 0x3037): SpaceSaver <4237> DW_AT_byte_size : 16 <4238> DW_AT_alignment : 8 <3><4239>: Abbrev Number: 9 (DW_TAG_member) <423a> DW_AT_name : (indirect string, offset: 0x29f5): RUST$ENCODED$ENUM$0$Nothing <423e> DW_AT_type : <0x4245> <4242> DW_AT_alignment : 8 <4243> DW_AT_data_member_location: 0 ... The "RUST$ENCODED$ENUM$0$Nothing" means that field 0 is both a pointer and a discriminant, and if the value is 0, then the enum is just a data-less variant named "Nothing". However, the corresponding type has two fields, where not field 0 but field 1 is a pointer, and field 0 is a byte: ... <2><4245>: Abbrev Number: 8 (DW_TAG_structure_type) <4246> DW_AT_name : (indirect string, offset: 0x2a11): Thebox <424a> DW_AT_byte_size : 16 <424b> DW_AT_alignment : 8 <3><424c>: Abbrev Number: 9 (DW_TAG_member) <424d> DW_AT_name : (indirect string, offset: 0x670): __0 <4251> DW_AT_type : <0x436b> <4255> DW_AT_alignment : 1 <4256> DW_AT_data_member_location: 8 <3><4257>: Abbrev Number: 9 (DW_TAG_member) <4258> DW_AT_name : (indirect string, offset: 0x1662): __1 <425c> DW_AT_type : <0x45da> <4260> DW_AT_alignment : 8 <4261> DW_AT_data_member_location: 0 ... Mark this as xfail. OK for trunk? Thanks, - Tom [gdb/testsuite] Add XFAILs in gdb.rust/simple.exp for incorrect DWARF gdb/testsuite/ChangeLog: 2019-10-08 Tom de Vries PR testsuite/25048 * gdb.rust/simple.exp: Add xfails for incorrect DWARF. --- gdb/testsuite/gdb.rust/simple.exp | 56 +++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp index dcbfb90920f..d3edbd712bb 100644 --- a/gdb/testsuite/gdb.rust/simple.exp +++ b/gdb/testsuite/gdb.rust/simple.exp @@ -200,7 +200,16 @@ gdb_test "print e2.notexist" \ gdb_test "print e2.0" \ "Variant simple::MoreComplicated::Four is not a tuple variant" -gdb_test "print k" " = simple::SpaceSaver::Nothing" +set pass_pattern " = simple::SpaceSaver::Nothing" +set xfail_pattern " = simple::SpaceSaver::Thebox\\($decimal, 0x0\\)" +gdb_test_multiple "print k" "" { + -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { + pass $gdb_test_name + } + -re "\[\r\n\]*(?:$xfail_pattern)\[\r\n\]+$gdb_prompt $" { + xfail $gdb_test_name + } +} gdb_test "print l" " = simple::SpaceSaver::Thebox\\(9, $hex\\)" gdb_test "print *l.1" " = 1729" @@ -228,16 +237,53 @@ gdb_test "print ..=5" " = .*::ops::RangeToInclusive.* \\{end: 5\\}" gdb_test "print 5.." " = .*::ops::RangeFrom.* \\{start: 5\\}" gdb_test "print .." " = .*::ops::RangeFull" -gdb_test "print str_some" \ +set pass_pattern \ " = core::option::Option<\[a-z\]+::string::String>::Some\\(\[a-z\]+::string::String .*" -gdb_test "print str_none" " = core::option::Option<\[a-z\]+::string::String>::None" +set xfail_pattern " = " +gdb_test_multiple "print str_some" "" { + -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { + pass $gdb_test_name + } + -re "\[\r\n\]*(?:$xfail_pattern)\[\r\n\]+$gdb_prompt $" { + xfail $gdb_test_name + } +} + +set pass_pattern " = core::option::Option<\[a-z\]+::string::String>::None" +gdb_test_multiple "print str_none" "" { + -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { + pass $gdb_test_name + } + -re "\[\r\n\]*(?:$xfail_pattern)\[\r\n\]+$gdb_prompt $" { + xfail $gdb_test_name + } +} + gdb_test "print int_some" " = core::option::Option::Some\\(1\\)" gdb_test "print int_none" " = core::option::Option::None" gdb_test "print box_some" " = core::option::Option<\[a-z:\]*Box>::Some\\(.*\\)" gdb_test "print box_none" " = core::option::Option<\[a-z:\]*Box>::None" -gdb_test "print custom_some" \ + +set pass_pattern \ " = simple::NonZeroOptimized::Value\\(\[a-z\]+::string::String .*" -gdb_test "print custom_none" " = simple::NonZeroOptimized::Empty" +gdb_test_multiple "print custom_some" "" { + -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { + pass $gdb_test_name + } + -re "\[\r\n\]*(?:$xfail_pattern)\[\r\n\]+$gdb_prompt $" { + xfail $gdb_test_name + } +} + +set pass_pattern " = simple::NonZeroOptimized::Empty" +gdb_test_multiple "print custom_none" "" { + -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { + pass $gdb_test_name + } + -re "\[\r\n\]*(?:$xfail_pattern)\[\r\n\]+$gdb_prompt $" { + xfail $gdb_test_name + } +} gdb_test "print st" \ " = simple::StringAtOffset {field1: \"hello\", field2: 1, field3: \"world\"}"