def _extract_type(type_: gdb.Type) -> Type: """ Extract a gdb.Type """ fields = [extract_field(f) for f in type_.fields()] template_arguments = [] try: i = 0 while True: arg = type_.template_argument(i) if isinstance(arg, gdb.Value): arg = _extract_value(arg) elif isinstance(arg, gdb.Type): arg = _extract_type(arg) else: raise ValueError("Template argument is not a gdb.Value or gdb.Type?") template_arguments.append(arg) i += 1 except gdb.error: pass return Type(type_code=type_.code, name=type_.name, size=type_.sizeof, tag=type_.tag, fields=fields, template_arguments=template_arguments )
def make_template_arguments_iterator(type: gdb.Type): """ """ try: idx = 0 while True: yield type.template_argument(idx) idx += 1 except RuntimeError: pass
def can_handle(gdb_type: gdb.Type) -> bool: return str(gdb_type).startswith("std::vector") and str( gdb_type.template_argument(0)) == "bool"