about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-12-14 22:10:19 +0800
committerkennytm <kennytm@gmail.com>2018-12-14 22:17:49 +0800
commit4a0ee22bc2fdeb2de198edc5c3916f0066080de9 (patch)
tree2759f4dd46203b035e9f918ffc8d5991355167bf
parentadb674ca2913ab41129a7dc12a0c5f5ace10e35d (diff)
parent4007adfb6b9c5e7731dac188609784c3809c3713 (diff)
downloadrust-4a0ee22bc2fdeb2de198edc5c3916f0066080de9.tar.gz
rust-4a0ee22bc2fdeb2de198edc5c3916f0066080de9.zip
Rollup merge of #56756 - tromey:Bug-56730-btree-pretty-printer, r=alexcrichton
Disable btree pretty-printers on older gdbs

gdb versions before 8.1 have a bug that prevents the BTreeSet and
BTreeMap pretty-printers from working.  This patch disables the test
on those versions, and also disables the pretty-printers there as
well.

Closes #56730
-rwxr-xr-xsrc/etc/gdb_rust_pretty_printing.py15
-rw-r--r--src/test/debuginfo/pretty-std-collections.rs6
2 files changed, 18 insertions, 3 deletions
diff --git a/src/etc/gdb_rust_pretty_printing.py b/src/etc/gdb_rust_pretty_printing.py
index a376c8593f4..f02c7d87590 100755
--- a/src/etc/gdb_rust_pretty_printing.py
+++ b/src/etc/gdb_rust_pretty_printing.py
@@ -9,6 +9,7 @@
 # except according to those terms.
 
 import gdb
+import re
 import sys
 import debugger_pretty_printers_common as rustpp
 
@@ -20,6 +21,16 @@ if sys.version_info[0] >= 3:
 
 rust_enabled = 'set language rust' in gdb.execute('complete set language ru', to_string = True)
 
+# The btree pretty-printers fail in a confusing way unless
+# https://sourceware.org/bugzilla/show_bug.cgi?id=21763 is fixed.
+# This fix went in 8.1, so check for that.
+# See https://github.com/rust-lang/rust/issues/56730
+gdb_81 = False
+_match = re.match('([0-9]+)\\.([0-9]+)', gdb.VERSION)
+if _match:
+    if int(_match.group(1)) > 8 or (int(_match.group(1)) == 8 and int(_match.group(2)) >= 1):
+        gdb_81 = True
+
 #===============================================================================
 # GDB Pretty Printing Module for Rust
 #===============================================================================
@@ -110,10 +121,10 @@ def rust_pretty_printer_lookup_function(gdb_val):
     if type_kind == rustpp.TYPE_KIND_STD_VECDEQUE:
         return RustStdVecDequePrinter(val)
 
-    if type_kind == rustpp.TYPE_KIND_STD_BTREESET:
+    if type_kind == rustpp.TYPE_KIND_STD_BTREESET and gdb_81:
         return RustStdBTreeSetPrinter(val)
 
-    if type_kind == rustpp.TYPE_KIND_STD_BTREEMAP:
+    if type_kind == rustpp.TYPE_KIND_STD_BTREEMAP and gdb_81:
         return RustStdBTreeMapPrinter(val)
 
     if type_kind == rustpp.TYPE_KIND_STD_STRING:
diff --git a/src/test/debuginfo/pretty-std-collections.rs b/src/test/debuginfo/pretty-std-collections.rs
index a51be370aa4..350b30d2cc1 100644
--- a/src/test/debuginfo/pretty-std-collections.rs
+++ b/src/test/debuginfo/pretty-std-collections.rs
@@ -13,7 +13,11 @@
 // ignore-freebsd: gdb package too new
 // ignore-android: FIXME(#10381)
 // compile-flags:-g
-// min-gdb-version 7.7
+
+// The pretty printers being tested here require the patch from
+// https://sourceware.org/bugzilla/show_bug.cgi?id=21763
+// min-gdb-version 8.1
+
 // min-lldb-version: 310
 
 // === GDB TESTS ===================================================================================