+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-14 Tom de Vries <tdevries@suse.de>
* gdb.rust/traits.exp: Fix PATH warning.
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"
+}
}
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
+}