diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-05-02 14:49:28 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-05-02 14:49:28 +0200 |
| commit | 596550c8002c2a1fa375ff7f39b6b9707b9f042d (patch) | |
| tree | 4d4de89034562e38df28dc56dcbbe8761511fe53 /scripts/gdb/kapi/address.py | |
| parent | d55ebee48dbf06ed59759f6c78c75c264bf6b8c5 (diff) | |
| download | kernel-596550c8002c2a1fa375ff7f39b6b9707b9f042d.tar.xz kernel-596550c8002c2a1fa375ff7f39b6b9707b9f042d.zip | |
debug: add kapi formatter support
Diffstat (limited to 'scripts/gdb/kapi/address.py')
| -rw-r--r-- | scripts/gdb/kapi/address.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/gdb/kapi/address.py b/scripts/gdb/kapi/address.py new file mode 100644 index 0000000..677c9aa --- /dev/null +++ b/scripts/gdb/kapi/address.py @@ -0,0 +1,33 @@ +import gdb + + +class KapiMemoryAddressPrinter: + """Print kapi::MemoryAddress.""" + + def __init__(self, val): + self.val = val + self.address_type = val.type.template_argument(0) + + def to_string(self): + try: + raw_address = int(self.val["m_value"]) + type_string = str(self.address_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.address_type): + yield ( + "std::byte *", + self.val["m_value"].cast(gdb.lookup_type("std::byte").pointer()), + ) + yield ("m_value", self.val["m_value"]) |
