From 3d435d802376f1136ba191a1ead46cec1bd00fe0 Mon Sep 17 00:00:00 2001 From: Stein Somers Date: Sun, 22 Mar 2020 20:10:48 +0000 Subject: [PATCH] Test and fix gdb pretty printing again --- src/etc/gdb_rust_pretty_printing.py | 4 ++-- src/test/debuginfo/pretty-std-collections.rs | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/etc/gdb_rust_pretty_printing.py b/src/etc/gdb_rust_pretty_printing.py index 51dfc3fff3f92..d580329cb504e 100755 --- a/src/etc/gdb_rust_pretty_printing.py +++ b/src/etc/gdb_rust_pretty_printing.py @@ -374,7 +374,7 @@ def children(self): innermap = GdbValue(self.__val.get_wrapped_value()['map']) if innermap.get_wrapped_value()['length'] > 0: root = GdbValue(innermap.get_wrapped_value()['root']) - type_name = str(root.type.ty.name).replace('core::option::Option<', '')[:-1] + type_name = str(root.type.ty.name).replace('core::option::Option<', '', 1)[:-1] root = root.get_wrapped_value().cast(gdb.lookup_type(type_name)) node_ptr = root['node'] i = 0 @@ -398,7 +398,7 @@ def to_string(self): def children(self): if self.__val.get_wrapped_value()['length'] > 0: root = GdbValue(self.__val.get_wrapped_value()['root']) - type_name = str(root.type.ty.name).replace('core::option::Option<', '')[:-1] + type_name = str(root.type.ty.name).replace('core::option::Option<', '', 1)[:-1] root = root.get_wrapped_value().cast(gdb.lookup_type(type_name)) node_ptr = root['node'] i = 0 diff --git a/src/test/debuginfo/pretty-std-collections.rs b/src/test/debuginfo/pretty-std-collections.rs index 1da2042b2224a..1f4ff00100a23 100644 --- a/src/test/debuginfo/pretty-std-collections.rs +++ b/src/test/debuginfo/pretty-std-collections.rs @@ -26,14 +26,19 @@ // gdb-command: print empty_btree_map // gdb-check:$4 = BTreeMap(len: 0) +// gdb-command: print option_btree_map +// gdb-check:$5 = BTreeMap>(len: 2) = {[false] = [...], [true] = [...]} +// (abbreviated because both values vary wildly over gdb versions and/or linux distributions) + // gdb-command: print nasty_btree_map -// gdb-check:$5 = BTreeMap(len: 1) = {[1] = pretty_std_collections::MyLeafNode (11)} +// gdb-check:$6 = BTreeMap(len: 15) = {[0] = pretty_std_collections::MyLeafNode (0), [...]} +// (abbreviated because it's boring but we need enough elements to include internal nodes) // gdb-command: print vec_deque -// gdb-check:$6 = VecDeque(len: 3, cap: 8) = {5, 3, 7} +// gdb-check:$7 = VecDeque(len: 3, cap: 8) = {5, 3, 7} // gdb-command: print vec_deque2 -// gdb-check:$7 = VecDeque(len: 7, cap: 8) = {2, 3, 4, 5, 6, 7, 8} +// gdb-check:$8 = VecDeque(len: 7, cap: 8) = {2, 3, 4, 5, 6, 7, 8} #![allow(unused_variables)] use std::collections::BTreeMap; @@ -59,8 +64,14 @@ fn main() { let mut empty_btree_map: BTreeMap = BTreeMap::new(); + let mut option_btree_map: BTreeMap> = BTreeMap::new(); + option_btree_map.insert(false, None); + option_btree_map.insert(true, Some(true)); + let mut nasty_btree_map: BTreeMap = BTreeMap::new(); - nasty_btree_map.insert(1, MyLeafNode(11)); + for i in 0..15 { + nasty_btree_map.insert(i, MyLeafNode(i)); + } // VecDeque let mut vec_deque = VecDeque::new();