diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index 903faf3fa969a..cf7961cbbfc2f 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -87,7 +87,6 @@ impl LeafNode { #[repr(C)] // gdb_providers.py uses this type name for introspection. struct InternalNode { - // gdb_providers.py uses this field name for introspection. data: LeafNode, /// The pointers to the children of this node. `len + 1` of these are considered diff --git a/src/etc/gdb_providers.py b/src/etc/gdb_providers.py index b2d343fd7af6a..eec3027085c91 100644 --- a/src/etc/gdb_providers.py +++ b/src/etc/gdb_providers.py @@ -229,8 +229,8 @@ def cast_to_internal(node): 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 @@ def to_string(self): 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 @@ def to_string(self): 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(): diff --git a/src/test/debuginfo/pretty-std-collections.rs b/src/test/debuginfo/pretty-std-collections.rs index c6d2090759ff2..cc2a3a345102a 100644 --- a/src/test/debuginfo/pretty-std-collections.rs +++ b/src/test/debuginfo/pretty-std-collections.rs @@ -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 = 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();