aboutsummaryrefslogtreecommitdiff
path: root/kapi/gdb
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-05-08 18:14:08 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-05-08 18:14:08 +0200
commit8ec011d9f5ad79c1e951127d3906a08e282649d1 (patch)
tree0223ce3c923578efe913f5b9dc39bf2c7481dcc9 /kapi/gdb
parent07fb219869099c719b0fbfeae81b95512487639e (diff)
downloadkernel-8ec011d9f5ad79c1e951127d3906a08e282649d1.tar.xz
kernel-8ec011d9f5ad79c1e951127d3906a08e282649d1.zip
debug: add pretty printer for boot modules
Diffstat (limited to 'kapi/gdb')
-rw-r--r--kapi/gdb/__init__.py8
-rw-r--r--kapi/gdb/boot_modules/__init__.py1
-rw-r--r--kapi/gdb/boot_modules/boot_module.py23
3 files changed, 31 insertions, 1 deletions
diff --git a/kapi/gdb/__init__.py b/kapi/gdb/__init__.py
index afb68f8..88b1d05 100644
--- a/kapi/gdb/__init__.py
+++ b/kapi/gdb/__init__.py
@@ -1,7 +1,8 @@
import gdb.printing
-from .memory import *
+from .boot_modules import *
from .devices import *
+from .memory import *
def build_pretty_printers():
@@ -17,6 +18,11 @@ def build_pretty_printers():
pp.add_printer(
"kapi_devices_device", "^kapi::devices::device$", KapiDevicesDevicePrinter
)
+ pp.add_printer(
+ "kapi_boot_modules_boot_module",
+ "^kapi::boot_modules::boot_module$",
+ KapiBootModulesBootModulePrinter,
+ )
return pp
diff --git a/kapi/gdb/boot_modules/__init__.py b/kapi/gdb/boot_modules/__init__.py
new file mode 100644
index 0000000..fedab65
--- /dev/null
+++ b/kapi/gdb/boot_modules/__init__.py
@@ -0,0 +1 @@
+from .boot_module import KapiBootModulesBootModulePrinter
diff --git a/kapi/gdb/boot_modules/boot_module.py b/kapi/gdb/boot_modules/boot_module.py
new file mode 100644
index 0000000..f0d558b
--- /dev/null
+++ b/kapi/gdb/boot_modules/boot_module.py
@@ -0,0 +1,23 @@
+import gdb
+from teachos import format_size
+
+
+class KapiBootModulesBootModulePrinter(gdb.ValuePrinter):
+ def __init__(self, val):
+ self.__val = val
+ self.__name = val["name"]
+ self.__start = val["start_address"]
+ self.__size = val["size"]
+ self.__pointer_type = gdb.lookup_type("std::byte").pointer()
+ self.__pretty_name = self.__name if str(self.__name) != '""' else "<no name>"
+
+ def to_string(self):
+ return f"boot module {self.__pretty_name} of size {format_size(int(self.__size))}, at {self.__start.cast(self.__pointer_type)}"
+
+ def children(self):
+ yield ("name", self.__name)
+ yield ("start_address", self.__start)
+ yield ("size", self.__size)
+
+ def display_hint(self):
+ return None