aboutsummaryrefslogtreecommitdiff
path: root/scripts/gdb/pretty_printers.py
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-05-04 08:20:42 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-05-04 08:20:42 +0200
commit1246e00478fb5ab2a357de17066fd8738395d9f1 (patch)
tree940aee5a7fbd2f980aaf233c8837220fbe8ab4ae /scripts/gdb/pretty_printers.py
parent3ab0a15fb6aba0ad9516da69589b9da8dbd63a8e (diff)
downloadkernel-1246e00478fb5ab2a357de17066fd8738395d9f1.tar.xz
kernel-1246e00478fb5ab2a357de17066fd8738395d9f1.zip
debug: split gdb modules
Diffstat (limited to 'scripts/gdb/pretty_printers.py')
-rw-r--r--scripts/gdb/pretty_printers.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/gdb/pretty_printers.py b/scripts/gdb/pretty_printers.py
new file mode 100644
index 0000000..83db491
--- /dev/null
+++ b/scripts/gdb/pretty_printers.py
@@ -0,0 +1,37 @@
+import sys
+import os
+import gdb
+import importlib.util
+
+script_path = os.path.abspath(__file__)
+repo_root = os.path.dirname(os.path.dirname(os.path.dirname(script_path)))
+
+components = {
+ "kstd": "libs/kstd/gdb",
+ "kapi": "kapi/gdb",
+}
+
+for component, path in components.items():
+ full_path = os.path.join(repo_root, *path.split("/"))
+ init_file = os.path.join(full_path, "__init__.py")
+
+ if os.path.isfile(init_file):
+ try:
+ spec = importlib.util.spec_from_file_location(component, init_file)
+ module = importlib.util.module_from_spec(spec)
+ sys.modules[component] = module
+ spec.loader.exec_module(module)
+
+ if hasattr(module, "register_printers"):
+ module.register_printers(gdb.current_objfile())
+ gdb.write(f"Info: Registered pretty printers for '{component}'.\n")
+ else:
+ gdb.write(
+ f"Warning: '{component}' does not have 'register_printers' function\n"
+ )
+ except Exception as e:
+ gdb.write(f"Warning: Failed to load '{component}' pretty printers: {e}\n")
+ else:
+ gdb.write(f"Warning: GDB extension init not found: '{init_file}'\n")
+
+gdb.write("Info: Loaded TeachOS pretty printers.\n")