Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test gdb pretty printing more and fix overzealous type substitution #68098

Merged
merged 1 commit into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/etc/gdb_rust_pretty_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def children(self):
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']
Expand Down
12 changes: 10 additions & 2 deletions src/test/debuginfo/pretty-std-collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,22 @@
// gdb-command: print empty_btree_map
// gdb-check:$4 = BTreeMap<i32, u32>(len: 0)

// gdb-command: print nasty_btree_map
// gdb-check:$5 = BTreeMap<i32, pretty_std_collections::MyLeafNode>(len: 1) = {[1] = pretty_std_collections::MyLeafNode (11)}

// gdb-command: print vec_deque
// gdb-check:$5 = VecDeque<i32>(len: 3, cap: 8) = {5, 3, 7}
// gdb-check:$6 = VecDeque<i32>(len: 3, cap: 8) = {5, 3, 7}

// gdb-command: print vec_deque2
// gdb-check:$6 = VecDeque<i32>(len: 7, cap: 8) = {2, 3, 4, 5, 6, 7, 8}
// gdb-check:$7 = VecDeque<i32>(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();
Expand All @@ -54,6 +59,9 @@ fn main() {

let mut empty_btree_map: BTreeMap<i32, u32> = BTreeMap::new();

let mut nasty_btree_map: BTreeMap<i32, MyLeafNode> = BTreeMap::new();
nasty_btree_map.insert(1, MyLeafNode(11));

// VecDeque
let mut vec_deque = VecDeque::new();
vec_deque.push_back(5);
Expand Down