public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] [gdb/testsuite] Add XFAILs in gdb.rust/simple.exp for incorrect DWARF
Date: Tue, 15 Oct 2019 23:51:00 -0000	[thread overview]
Message-ID: <a50faaf6207b7556f691369097cd5bf903298794@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT a50faaf6207b7556f691369097cd5bf903298794 ***

commit a50faaf6207b7556f691369097cd5bf903298794
Author:     Tom de Vries <tdevries@suse.de>
AuthorDate: Wed Oct 9 23:57:11 2019 +0200
Commit:     Tom de Vries <tdevries@suse.de>
CommitDate: Wed Oct 9 23:57:11 2019 +0200

    [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.

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  <tdevries@suse.de>
+
+	PR testsuite/25048
+	* gdb.rust/simple.exp: Add xfails for incorrect DWARF.
+
 2019-10-07  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* 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 " = <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_none" " = core::option::Option<u8>::None"
 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 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\"}"


             reply	other threads:[~2019-10-15 23:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15 23:51 gdb-buildbot [this message]
2019-10-15 23:51 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
2019-10-16  1:20 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot
2019-10-16  2:09 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2019-10-22  8:19 ` Failures on Fedora-i686, " gdb-buildbot
2019-10-22  9:54 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2019-10-22 11:38 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a50faaf6207b7556f691369097cd5bf903298794@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).