From d8a136fa10edb5614b1a2f311d1aa05c206a65d5 Mon Sep 17 00:00:00 2001 From: Stein Somers Date: Fri, 10 Jan 2020 17:31:56 +0100 Subject: [PATCH] Test pretty printing more and fix overzealous type substitution --- src/etc/gdb_rust_pretty_printing.py | 2 +- src/test/debuginfo/pretty-std-collections.rs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/etc/gdb_rust_pretty_printing.py b/src/etc/gdb_rust_pretty_printing.py index cae64ef6665..51dfc3fff3f 100755 --- a/src/etc/gdb_rust_pretty_printing.py +++ b/src/etc/gdb_rust_pretty_printing.py @@ -335,7 +335,7 @@ class RustStdVecDequePrinter(object): def children_of_node(boxed_node, height, want_values): node_ptr = boxed_node['ptr']['pointer'] if height > 0: - type_name = str(node_ptr.type.target()).replace('LeafNode', 'InternalNode') + type_name = str(node_ptr.type.target()).replace('LeafNode', 'InternalNode', 1) node_type = gdb.lookup_type(type_name) node_ptr = node_ptr.cast(node_type.pointer()) leaf = node_ptr['data'] diff --git a/src/test/debuginfo/pretty-std-collections.rs b/src/test/debuginfo/pretty-std-collections.rs index 3d2d88a676d..1da2042b222 100644 --- a/src/test/debuginfo/pretty-std-collections.rs +++ b/src/test/debuginfo/pretty-std-collections.rs @@ -26,17 +26,22 @@ // gdb-command: print empty_btree_map // gdb-check:$4 = BTreeMap(len: 0) +// gdb-command: print nasty_btree_map +// gdb-check:$5 = BTreeMap(len: 1) = {[1] = pretty_std_collections::MyLeafNode (11)} + // gdb-command: print vec_deque -// gdb-check:$5 = VecDeque(len: 3, cap: 8) = {5, 3, 7} +// gdb-check:$6 = VecDeque(len: 3, cap: 8) = {5, 3, 7} // gdb-command: print vec_deque2 -// gdb-check:$6 = VecDeque(len: 7, cap: 8) = {2, 3, 4, 5, 6, 7, 8} +// gdb-check:$7 = VecDeque(len: 7, cap: 8) = {2, 3, 4, 5, 6, 7, 8} #![allow(unused_variables)] use std::collections::BTreeMap; use std::collections::BTreeSet; use std::collections::VecDeque; +struct MyLeafNode(i32); // helps to ensure we don't blindly replace substring "LeafNode" + fn main() { // BTreeSet let mut btree_set = BTreeSet::new(); @@ -54,6 +59,9 @@ fn main() { let mut empty_btree_map: BTreeMap = BTreeMap::new(); + let mut nasty_btree_map: BTreeMap = BTreeMap::new(); + nasty_btree_map.insert(1, MyLeafNode(11)); + // VecDeque let mut vec_deque = VecDeque::new(); vec_deque.push_back(5);