return self._children_generator()
+class HtabPrinter:
+ """Pretty-printer for htab_t hash tables."""
+
+ def __init__(self, val):
+ self._val = val
+
+ def display_hint(self):
+ return "array"
+
+ def to_string(self):
+ n = int(self._val["n_elements"]) - int(self._val["n_deleted"])
+ return "htab_t with {} elements".format(n)
+
+ def children(self):
+ size = int(self._val["size"])
+ entries = self._val["entries"]
+
+ child_i = 0
+ for entries_i in range(size):
+ entry = entries[entries_i]
+ # 0 (NULL pointer) means there's nothing, 1 (HTAB_DELETED_ENTRY)
+ # means there was something, but is now deleted.
+ if int(entry) in (0, 1):
+ continue
+
+ yield (str(child_i), entry)
+ child_i += 1
+
+
def type_lookup_function(val):
"""A routine that returns the correct pretty printer for VAL
if appropriate. Returns None otherwise.
return CoreAddrPrettyPrinter(val)
elif tag is not None and tag.startswith("intrusive_list<"):
return IntrusiveListPrinter(val)
+ elif name == "htab_t":
+ return HtabPrinter(val)
return None