import gdb class KapiMemoryAddressPrinter(gdb.ValuePrinter): def __init__(self, val): self.__val = val self.__type = val.type.template_argument(0) def to_string(self): try: raw_address = int(self.__val["m_value"]) type_string = str(self.__type) if "linear" in type_string: suffix = "%lin" elif "physical" in type_string: suffix = "%phy" else: suffix = "%???" return f"{raw_address:#018x}{suffix}" except Exception as e: return f"{self.__val}: {e}" def children(self): if "linear" in str(self.__type): pointer_type = gdb.lookup_type("std::byte").pointer() yield ("[bytes]", self.__val["m_value"].cast(pointer_type)) def display_hint(self): return None