Rollup merge of #77932 - ssomers:btree_cleanup_gdb, r=Mark-Simulacrum
BTreeMap: improve gdb introspection of BTreeMap with ZST keys or values I accidentally pushed an earlier revision in #77788: it changes the index of tuples for BTreeSet from ""[{}]".format(i) to "key{}".format(i). Which doesn't seem to make the slightest difference on my linux box nor on CI. In fact, gdb doesn't make any distinction between "key{}" and "val{}" for a BTreeMap either, leading to confusing output if you test more. But easy to improve. r? @Mark-Simulacrum
This commit is contained in:
commit
16b878fd0f
3 changed files with 29 additions and 20 deletions
|
@ -87,7 +87,6 @@ impl<K, V> LeafNode<K, V> {
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
// gdb_providers.py uses this type name for introspection.
|
// gdb_providers.py uses this type name for introspection.
|
||||||
struct InternalNode<K, V> {
|
struct InternalNode<K, V> {
|
||||||
// gdb_providers.py uses this field name for introspection.
|
|
||||||
data: LeafNode<K, V>,
|
data: LeafNode<K, V>,
|
||||||
|
|
||||||
/// The pointers to the children of this node. `len + 1` of these are considered
|
/// 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
|
yield child
|
||||||
if i < length:
|
if i < length:
|
||||||
# Avoid "Cannot perform pointer math on incomplete type" on zero-sized arrays.
|
# Avoid "Cannot perform pointer math on incomplete type" on zero-sized arrays.
|
||||||
key = keys[i]["value"]["value"] if keys.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 None
|
val = vals[i]["value"]["value"] if vals.type.sizeof > 0 else "()"
|
||||||
yield key, val
|
yield key, val
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,11 +242,8 @@ def children_of_map(map):
|
||||||
root = root.cast(gdb.lookup_type(root.type.name[21:-1]))
|
root = root.cast(gdb.lookup_type(root.type.name[21:-1]))
|
||||||
boxed_root_node = root["node"]
|
boxed_root_node = root["node"]
|
||||||
height = root["height"]
|
height = root["height"]
|
||||||
for i, (key, val) in enumerate(children_of_node(boxed_root_node, height)):
|
for child in children_of_node(boxed_root_node, height):
|
||||||
if key is not None:
|
yield child
|
||||||
yield "key{}".format(i), key
|
|
||||||
if val is not None:
|
|
||||||
yield "val{}".format(i), val
|
|
||||||
|
|
||||||
|
|
||||||
class StdBTreeSetProvider:
|
class StdBTreeSetProvider:
|
||||||
|
@ -258,8 +255,8 @@ class StdBTreeSetProvider:
|
||||||
|
|
||||||
def children(self):
|
def children(self):
|
||||||
inner_map = self.valobj["map"]
|
inner_map = self.valobj["map"]
|
||||||
for child in children_of_map(inner_map):
|
for i, (child, _) in enumerate(children_of_map(inner_map)):
|
||||||
yield child
|
yield "[{}]".format(i), child
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def display_hint():
|
def display_hint():
|
||||||
|
@ -274,8 +271,9 @@ class StdBTreeMapProvider:
|
||||||
return "BTreeMap(size={})".format(self.valobj["length"])
|
return "BTreeMap(size={})".format(self.valobj["length"])
|
||||||
|
|
||||||
def children(self):
|
def children(self):
|
||||||
for child in children_of_map(self.valobj):
|
for i, (key, val) in enumerate(children_of_map(self.valobj)):
|
||||||
yield child
|
yield "key{}".format(i), key
|
||||||
|
yield "val{}".format(i), val
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def display_hint():
|
def display_hint():
|
||||||
|
|
|
@ -34,20 +34,26 @@
|
||||||
// gdb-check:$6 = BTreeMap(size=15) = {[0] = pretty_std_collections::MyLeafNode (0), [...]}
|
// 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)
|
// (abbreviated because it's boring but we need enough elements to include internal nodes)
|
||||||
|
|
||||||
// gdb-command: print zst_btree_map
|
// gdb-command: print zst_key_btree_map
|
||||||
// gdb-check:$7 = BTreeMap(size=1)
|
// 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-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-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-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-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 ==================================================================================
|
// === LLDB TESTS ==================================================================================
|
||||||
|
|
||||||
|
@ -114,8 +120,14 @@ fn main() {
|
||||||
nasty_btree_map.insert(i, MyLeafNode(i));
|
nasty_btree_map.insert(i, MyLeafNode(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut zst_btree_map: BTreeMap<(), ()> = BTreeMap::new();
|
let mut zst_key_btree_map: BTreeMap<(), i32> = BTreeMap::new();
|
||||||
zst_btree_map.insert((), ());
|
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
|
// VecDeque
|
||||||
let mut vec_deque = VecDeque::new();
|
let mut vec_deque = VecDeque::new();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue