mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
Fix debugger pretty printing of BTrees
This commit is contained in:
parent
4d85314a00
commit
bce7f6f3a0
@ -370,12 +370,17 @@ class RustStdBTreeSetPrinter(object):
|
||||
("(len: %i)" % self.__val.get_wrapped_value()['map']['length']))
|
||||
|
||||
def children(self):
|
||||
root = self.__val.get_wrapped_value()['map']['root']
|
||||
node_ptr = root['node']
|
||||
i = 0
|
||||
for child in children_of_node(node_ptr, root['height'], False):
|
||||
yield (str(i), child)
|
||||
i = i + 1
|
||||
prev_idx = None
|
||||
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]
|
||||
root = root.get_wrapped_value().cast(gdb.lookup_type(type_name))
|
||||
node_ptr = root['node']
|
||||
i = 0
|
||||
for child in children_of_node(node_ptr, root['height'], False):
|
||||
yield (str(i), child)
|
||||
i = i + 1
|
||||
|
||||
|
||||
class RustStdBTreeMapPrinter(object):
|
||||
@ -391,13 +396,16 @@ class RustStdBTreeMapPrinter(object):
|
||||
("(len: %i)" % self.__val.get_wrapped_value()['length']))
|
||||
|
||||
def children(self):
|
||||
root = self.__val.get_wrapped_value()['root']
|
||||
node_ptr = root['node']
|
||||
i = 0
|
||||
for child in children_of_node(node_ptr, root['height'], True):
|
||||
yield (str(i), child[0])
|
||||
yield (str(i), child[1])
|
||||
i = i + 1
|
||||
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]
|
||||
root = root.get_wrapped_value().cast(gdb.lookup_type(type_name))
|
||||
node_ptr = root['node']
|
||||
i = 0
|
||||
for child in children_of_node(node_ptr, root['height'], True):
|
||||
yield (str(i), child[0])
|
||||
yield (str(i), child[1])
|
||||
i = i + 1
|
||||
|
||||
|
||||
class RustStdStringPrinter(object):
|
||||
|
@ -17,35 +17,43 @@
|
||||
// gdb-command: print btree_set
|
||||
// gdb-check:$1 = BTreeSet<i32>(len: 15) = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}
|
||||
|
||||
// gdb-command: print empty_btree_set
|
||||
// gdb-check:$2 = BTreeSet<i32>(len: 0)
|
||||
|
||||
// gdb-command: print btree_map
|
||||
// gdb-check:$2 = BTreeMap<i32, i32>(len: 15) = {[0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8, [9] = 9, [10] = 10, [11] = 11, [12] = 12, [13] = 13, [14] = 14}
|
||||
// gdb-check:$3 = BTreeMap<i32, i32>(len: 15) = {[0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8, [9] = 9, [10] = 10, [11] = 11, [12] = 12, [13] = 13, [14] = 14}
|
||||
|
||||
// gdb-command: print empty_btree_map
|
||||
// gdb-check:$4 = BTreeMap<i32, u32>(len: 0)
|
||||
|
||||
// gdb-command: print vec_deque
|
||||
// gdb-check:$3 = VecDeque<i32>(len: 3, cap: 8) = {5, 3, 7}
|
||||
// gdb-check:$5 = VecDeque<i32>(len: 3, cap: 8) = {5, 3, 7}
|
||||
|
||||
// gdb-command: print vec_deque2
|
||||
// gdb-check:$4 = VecDeque<i32>(len: 7, cap: 8) = {2, 3, 4, 5, 6, 7, 8}
|
||||
// gdb-check:$6 = VecDeque<i32>(len: 7, cap: 8) = {2, 3, 4, 5, 6, 7, 8}
|
||||
|
||||
#![allow(unused_variables)]
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
|
||||
fn main() {
|
||||
|
||||
// BTreeSet
|
||||
let mut btree_set = BTreeSet::new();
|
||||
for i in 0..15 {
|
||||
btree_set.insert(i);
|
||||
}
|
||||
|
||||
let mut empty_btree_set: BTreeSet<i32> = BTreeSet::new();
|
||||
|
||||
// BTreeMap
|
||||
let mut btree_map = BTreeMap::new();
|
||||
for i in 0..15 {
|
||||
btree_map.insert(i, i);
|
||||
}
|
||||
|
||||
let mut empty_btree_map: BTreeMap<i32, u32> = BTreeMap::new();
|
||||
|
||||
// VecDeque
|
||||
let mut vec_deque = VecDeque::new();
|
||||
vec_deque.push_back(5);
|
||||
@ -63,4 +71,6 @@ fn main() {
|
||||
zzz(); // #break
|
||||
}
|
||||
|
||||
fn zzz() { () }
|
||||
fn zzz() {
|
||||
()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user