import gdb from teachos import TeachOSBasePrinter class KapiMemoryAddressPrinter(TeachOSBasePrinter): def __init__(self, val): super().__init__(val) self.__type = val.type.template_argument(0) def to_string(self): try: raw_address = int(self.value["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.value}: {e}" def children(self): if "linear" in str(self.__type): pointer_type = gdb.lookup_type("std::byte").pointer() yield ("[bytes]", self.value["m_value"].cast(pointer_type)) yield from super().children()