blob: 24fe6811df98a33335db2b3093e8ce34b9289e80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
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()
|