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 and fix gdb pretty printing more #70282

Merged
merged 1 commit into from
Mar 27, 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
4 changes: 2 additions & 2 deletions src/etc/gdb_rust_pretty_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
19 changes: 15 additions & 4 deletions src/test/debuginfo/pretty-std-collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@
// gdb-command: print empty_btree_map
// gdb-check:$4 = BTreeMap<i32, u32>(len: 0)

// gdb-command: print option_btree_map
// gdb-check:$5 = BTreeMap<bool, core::option::Option<bool>>(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<i32, pretty_std_collections::MyLeafNode>(len: 1) = {[1] = pretty_std_collections::MyLeafNode (11)}
// gdb-check:$6 = BTreeMap<i32, pretty_std_collections::MyLeafNode>(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<i32>(len: 3, cap: 8) = {5, 3, 7}
// gdb-check:$7 = VecDeque<i32>(len: 3, cap: 8) = {5, 3, 7}

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

#![allow(unused_variables)]
use std::collections::BTreeMap;
Expand All @@ -59,8 +64,14 @@ fn main() {

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

let mut option_btree_map: BTreeMap<bool, Option<bool>> = BTreeMap::new();
option_btree_map.insert(false, None);
option_btree_map.insert(true, Some(true));

let mut nasty_btree_map: BTreeMap<i32, MyLeafNode> = 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();
Expand Down