BTreeMap: improve gdb introspection of BTreeMap with ZST keys or values
This commit is contained in:
parent
5565241f65
commit
28af355b9f
@ -87,7 +87,6 @@ impl<K, V> LeafNode<K, V> {
|
||||
#[repr(C)]
|
||||
// gdb_providers.py uses this type name for introspection.
|
||||
struct InternalNode<K, V> {
|
||||
// gdb_providers.py uses this field name for introspection.
|
||||
data: LeafNode<K, V>,
|
||||
|
||||
/// The pointers to the children of this node. `len + 1` of these are considered
|
||||
|
@ -229,8 +229,8 @@ def children_of_node(boxed_node, height):
|
||||
yield child
|
||||
if i < length:
|
||||
# Avoid "Cannot perform pointer math on incomplete type" on zero-sized arrays.
|
||||
key = keys[i]["value"]["value"] if keys.type.sizeof > 0 else None
|
||||
val = vals[i]["value"]["value"] if vals.type.sizeof > 0 else None
|
||||
key = keys[i]["value"]["value"] if keys.type.sizeof > 0 else "()"
|
||||
val = vals[i]["value"]["value"] if vals.type.sizeof > 0 else "()"
|
||||
yield key, val
|
||||
|
||||
|
||||
@ -242,11 +242,8 @@ def children_of_map(map):
|
||||
root = root.cast(gdb.lookup_type(root.type.name[21:-1]))
|
||||
boxed_root_node = root["node"]
|
||||
height = root["height"]
|
||||
for i, (key, val) in enumerate(children_of_node(boxed_root_node, height)):
|
||||
if key is not None:
|
||||
yield "key{}".format(i), key
|
||||
if val is not None:
|
||||
yield "val{}".format(i), val
|
||||
for child in children_of_node(boxed_root_node, height):
|
||||
yield child
|
||||
|
||||
|
||||
class StdBTreeSetProvider:
|
||||
@ -258,8 +255,8 @@ class StdBTreeSetProvider:
|
||||
|
||||
def children(self):
|
||||
inner_map = self.valobj["map"]
|
||||
for child in children_of_map(inner_map):
|
||||
yield child
|
||||
for i, (child, _) in enumerate(children_of_map(inner_map)):
|
||||
yield "[{}]".format(i), child
|
||||
|
||||
@staticmethod
|
||||
def display_hint():
|
||||
@ -274,8 +271,9 @@ class StdBTreeMapProvider:
|
||||
return "BTreeMap(size={})".format(self.valobj["length"])
|
||||
|
||||
def children(self):
|
||||
for child in children_of_map(self.valobj):
|
||||
yield child
|
||||
for i, (key, val) in enumerate(children_of_map(self.valobj)):
|
||||
yield "key{}".format(i), key
|
||||
yield "val{}".format(i), val
|
||||
|
||||
@staticmethod
|
||||
def display_hint():
|
||||
|
@ -34,20 +34,26 @@
|
||||
// gdb-check:$6 = BTreeMap(size=15) = {[0] = pretty_std_collections::MyLeafNode (0), [...]}
|
||||
// (abbreviated because it's boring but we need enough elements to include internal nodes)
|
||||
|
||||
// gdb-command: print zst_btree_map
|
||||
// gdb-check:$7 = BTreeMap(size=1)
|
||||
// gdb-command: print zst_key_btree_map
|
||||
// gdb-check:$7 = BTreeMap(size=1) = {[()] = 1}
|
||||
|
||||
// gdb-command: print zst_val_btree_map
|
||||
// gdb-check:$8 = BTreeMap(size=1) = {[1] = ()}
|
||||
|
||||
// gdb-command: print zst_key_val_btree_map
|
||||
// gdb-check:$9 = BTreeMap(size=1) = {[()] = ()}
|
||||
|
||||
// gdb-command: print vec_deque
|
||||
// gdb-check:$8 = VecDeque(size=3) = {5, 3, 7}
|
||||
// gdb-check:$10 = VecDeque(size=3) = {5, 3, 7}
|
||||
|
||||
// gdb-command: print vec_deque2
|
||||
// gdb-check:$9 = VecDeque(size=7) = {2, 3, 4, 5, 6, 7, 8}
|
||||
// gdb-check:$11 = VecDeque(size=7) = {2, 3, 4, 5, 6, 7, 8}
|
||||
|
||||
// gdb-command: print hash_map
|
||||
// gdb-check:$10 = HashMap(size=4) = {[1] = 10, [2] = 20, [3] = 30, [4] = 40}
|
||||
// gdb-check:$12 = HashMap(size=4) = {[1] = 10, [2] = 20, [3] = 30, [4] = 40}
|
||||
|
||||
// gdb-command: print hash_set
|
||||
// gdb-check:$11 = HashSet(size=4) = {1, 2, 3, 4}
|
||||
// gdb-check:$13 = HashSet(size=4) = {1, 2, 3, 4}
|
||||
|
||||
// === LLDB TESTS ==================================================================================
|
||||
|
||||
@ -114,8 +120,14 @@ fn main() {
|
||||
nasty_btree_map.insert(i, MyLeafNode(i));
|
||||
}
|
||||
|
||||
let mut zst_btree_map: BTreeMap<(), ()> = BTreeMap::new();
|
||||
zst_btree_map.insert((), ());
|
||||
let mut zst_key_btree_map: BTreeMap<(), i32> = BTreeMap::new();
|
||||
zst_key_btree_map.insert((), 1);
|
||||
|
||||
let mut zst_val_btree_map: BTreeMap<i32, ()> = BTreeMap::new();
|
||||
zst_val_btree_map.insert(1, ());
|
||||
|
||||
let mut zst_key_val_btree_map: BTreeMap<(), ()> = BTreeMap::new();
|
||||
zst_key_val_btree_map.insert((), ());
|
||||
|
||||
// VecDeque
|
||||
let mut vec_deque = VecDeque::new();
|
||||
|
Loading…
x
Reference in New Issue
Block a user