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

Fix zero-sized BTreeMap gdb pretty-printer #79235

Merged
merged 1 commit into from
Dec 2, 2020
Merged
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
9 changes: 5 additions & 4 deletions src/etc/gdb_providers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from sys import version_info

import gdb
from gdb import lookup_type

if version_info[0] >= 3:
xrange = range
Expand Down Expand Up @@ -213,7 +212,7 @@ def children_of_btree_map(map):
def children_of_node(node_ptr, height):
def cast_to_internal(node):
internal_type_name = node.type.target().name.replace("LeafNode", "InternalNode", 1)
internal_type = lookup_type(internal_type_name)
internal_type = gdb.lookup_type(internal_type_name)
return node.cast(internal_type.pointer())

leaf = node_ptr.dereference()
Expand All @@ -230,8 +229,10 @@ 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 "()"
val = vals[i]["value"]["value"] if vals.type.sizeof > 0 else "()"
key_type_size = keys.type.sizeof
val_type_size = vals.type.sizeof
key = keys[i]["value"]["value"] if key_type_size > 0 else gdb.parse_and_eval("()")
val = vals[i]["value"]["value"] if val_type_size > 0 else gdb.parse_and_eval("()")
yield key, val

if map["length"] > 0:
Expand Down