From a50faaf6207b7556f691369097cd5bf903298794 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Wed, 9 Oct 2019 23:57:11 +0200 Subject: [PATCH] [gdb/testsuite] Add XFAILs in gdb.rust/simple.exp for incorrect DWARF 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. gdb/testsuite/ChangeLog: 2019-10-09 Tom de Vries PR testsuite/25048 * gdb.rust/simple.exp: Add xfails for incorrect DWARF. --- gdb/testsuite/ChangeLog | 5 +++ gdb/testsuite/gdb.rust/simple.exp | 56 ++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4adf16af00..4191661a2f 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-09 Tom de Vries + + PR testsuite/25048 + * gdb.rust/simple.exp: Add xfails for incorrect DWARF. + 2019-10-07 Andrew Burgess * gdb.ada/catch_ex_std.exp: Handle being unabled to catch Ada diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp index dcbfb90920..d3edbd712b 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\"}" -- 2.34.1