[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  <tdevries@suse.de>

	PR testsuite/25048
	* gdb.rust/simple.exp: Add xfails for incorrect DWARF.
This commit is contained in:
Tom de Vries
2019-10-09 23:57:11 +02:00
parent cff32449e8
commit a50faaf620
2 changed files with 56 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2019-10-09 Tom de Vries <tdevries@suse.de>
PR testsuite/25048
* gdb.rust/simple.exp: Add xfails for incorrect DWARF.
2019-10-07 Andrew Burgess <andrew.burgess@embecosm.com> 2019-10-07 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.ada/catch_ex_std.exp: Handle being unabled to catch Ada * gdb.ada/catch_ex_std.exp: Handle being unabled to catch Ada

View File

@ -200,7 +200,16 @@ gdb_test "print e2.notexist" \
gdb_test "print e2.0" \ gdb_test "print e2.0" \
"Variant simple::MoreComplicated::Four is not a tuple variant" "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" " = simple::SpaceSaver::Thebox\\(9, $hex\\)"
gdb_test "print *l.1" " = 1729" 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 5.." " = .*::ops::RangeFrom.* \\{start: 5\\}"
gdb_test "print .." " = .*::ops::RangeFull" 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 .*" " = 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 " = <error reading variable>"
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<u8>::Some\\(1\\)" gdb_test "print int_some" " = core::option::Option<u8>::Some\\(1\\)"
gdb_test "print int_none" " = core::option::Option<u8>::None" gdb_test "print int_none" " = core::option::Option<u8>::None"
gdb_test "print box_some" " = core::option::Option<\[a-z:\]*Box<u8>>::Some\\(.*\\)" gdb_test "print box_some" " = core::option::Option<\[a-z:\]*Box<u8>>::Some\\(.*\\)"
gdb_test "print box_none" " = core::option::Option<\[a-z:\]*Box<u8>>::None" gdb_test "print box_none" " = core::option::Option<\[a-z:\]*Box<u8>>::None"
gdb_test "print custom_some" \
set pass_pattern \
" = simple::NonZeroOptimized::Value\\(\[a-z\]+::string::String .*" " = 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" \ gdb_test "print st" \
" = simple::StringAtOffset {field1: \"hello\", field2: 1, field3: \"world\"}" " = simple::StringAtOffset {field1: \"hello\", field2: 1, field3: \"world\"}"