]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Avoid running one Rust test against older LLVM
authorTom Tromey <tromey@adacore.com>
Tue, 15 Sep 2020 15:27:01 +0000 (09:27 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 15 Sep 2020 15:31:22 +0000 (09:31 -0600)
LLVM 8.0 introduced some changes to let the Rust compiler emit DWARF
variant parts.  Before this change, the compiler would emit two types
with the same name, and unfortunately gdb happens to pick the wrong
one.  So, this patch disables the test when using an older version of
LLVM.

2020-09-15  Tom Tromey  <tromey@adacore.com>

PR rust/26197:
* lib/rust-support.exp (rust_llvm_version): New proc.
* gdb.rust/simple.exp: Check rust_llvm_version.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.rust/simple.exp
gdb/testsuite/lib/rust-support.exp

index 9b150b656b2d1417a7729315904c1a6e55c840a0..452ca8eb4c8df408722f722ac023df45c4eb43fd 100644 (file)
@@ -1,3 +1,9 @@
+2020-09-15  Tom Tromey  <tromey@adacore.com>
+
+       PR rust/26197:
+       * lib/rust-support.exp (rust_llvm_version): New proc.
+       * gdb.rust/simple.exp: Check rust_llvm_version.
+
 2020-09-11  Moritz Riesterer  <moritz.riesterer@intel.com>
            Felix Willgerodt  <Felix.Willgerodt@intel.com>
 
index b32eaf1e4dce0063c6bd5a1cb15a7bbf27683010..882c2e07bcd58d56cd2cca5f09701741e43856af 100644 (file)
@@ -375,5 +375,14 @@ gdb_test "python print(e.type.fields()\[0\].artificial)" "True"
 gdb_test "python print(e.type.fields()\[1\].name)" "Two"
 
 gdb_test "python print(e.type.dynamic)" "False"
-gdb_test "python print(gdb.lookup_type('simple::MoreComplicated').dynamic)" \
-    "True"
+
+# Before LLVM 8, the rust compiler would emit two types named
+# "simple::MoreComplicated" -- the C-like "underlying" enum type and
+# the Rust enum.  lookup_type seems to get the former, which isn't
+# very useful.  With later versions of LLVM, this test works
+# correctly.
+set v [split [rust_llvm_version] .]
+if {[lindex $v 0] >= 8} {
+    gdb_test "python print(gdb.lookup_type('simple::MoreComplicated').dynamic)" \
+       "True"
+}
index 72fba2623e9982450faf29993a094c965f53f58d..9c9ef1bbd2afafbf9f89057ca780f2caf87d95ac 100644 (file)
@@ -35,3 +35,22 @@ proc gdb_compile_rust {sources dest options} {
     }
     return ""
 }
+
+# Return the version of LLVM used by the Rust compiler.  Note that
+# older versions of rustc don't print this -- in this case the
+# returned version is "0.0".
+gdb_caching_proc rust_llvm_version {
+    set rustc [find_rustc]
+    if {$rustc == ""} {
+       verbose "could not find rustc"
+    } else {
+       set output [lindex [remote_exec host "$rustc --version --verbose"] 1]
+       foreach line [split $output \n] {
+           if {[regexp "LLVM version: (.+)\$" $output ignore version]} {
+               return $version
+           }
+       }
+       verbose "could not match rustc version output: $output"
+    }
+    return 0.0
+}