aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/launch.json2
-rw-r--r--.vscode/settings.json2
-rw-r--r--kapi/gdb/__init__.py (renamed from scripts/gdb/kapi/__init__.py)0
-rw-r--r--kapi/gdb/address.py (renamed from scripts/gdb/kapi/address.py)0
-rw-r--r--libs/kstd/gdb/__init__.py (renamed from scripts/gdb/kstd/__init__.py)0
-rw-r--r--libs/kstd/gdb/smart_pointers.py (renamed from scripts/gdb/kstd/smart_pointers.py)0
-rw-r--r--libs/kstd/gdb/std_types.py (renamed from scripts/gdb/kstd/std_types.py)0
-rw-r--r--libs/kstd/gdb/string.py (renamed from scripts/gdb/kstd/string.py)0
-rw-r--r--libs/kstd/gdb/vector.py (renamed from scripts/gdb/kstd/vector.py)0
-rw-r--r--scripts/gdb/load.py16
-rw-r--r--scripts/gdb/pretty_printers.py37
11 files changed, 39 insertions, 18 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index d5b2401..15f5d3a 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -28,7 +28,7 @@
},
{
"description": "Load custom Python helpers",
- "text": "-interpreter-exec console \"source ${workspaceFolder}/scripts/gdb/load.py\""
+ "text": "-interpreter-exec console \"source ${workspaceFolder}/scripts/gdb/pretty_printers.py\""
}
]
}
diff --git a/.vscode/settings.json b/.vscode/settings.json
index c8f9013..efe3bc7 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -90,7 +90,7 @@
},
{
"description": "Load custom Python helpers",
- "text": "-interpreter-exec console \"source ${workspaceFolder}/scripts/gdb/load.py\""
+ "text": "-interpreter-exec console \"source ${workspaceFolder}/scripts/gdb/pretty_printers.py\""
}
],
},
diff --git a/scripts/gdb/kapi/__init__.py b/kapi/gdb/__init__.py
index c37c7b7..c37c7b7 100644
--- a/scripts/gdb/kapi/__init__.py
+++ b/kapi/gdb/__init__.py
diff --git a/scripts/gdb/kapi/address.py b/kapi/gdb/address.py
index 677c9aa..677c9aa 100644
--- a/scripts/gdb/kapi/address.py
+++ b/kapi/gdb/address.py
diff --git a/scripts/gdb/kstd/__init__.py b/libs/kstd/gdb/__init__.py
index fc5e8fb..fc5e8fb 100644
--- a/scripts/gdb/kstd/__init__.py
+++ b/libs/kstd/gdb/__init__.py
diff --git a/scripts/gdb/kstd/smart_pointers.py b/libs/kstd/gdb/smart_pointers.py
index 6e4a4f9..6e4a4f9 100644
--- a/scripts/gdb/kstd/smart_pointers.py
+++ b/libs/kstd/gdb/smart_pointers.py
diff --git a/scripts/gdb/kstd/std_types.py b/libs/kstd/gdb/std_types.py
index 78d094c..78d094c 100644
--- a/scripts/gdb/kstd/std_types.py
+++ b/libs/kstd/gdb/std_types.py
diff --git a/scripts/gdb/kstd/string.py b/libs/kstd/gdb/string.py
index 8230b21..8230b21 100644
--- a/scripts/gdb/kstd/string.py
+++ b/libs/kstd/gdb/string.py
diff --git a/scripts/gdb/kstd/vector.py b/libs/kstd/gdb/vector.py
index 597ffdc..597ffdc 100644
--- a/scripts/gdb/kstd/vector.py
+++ b/libs/kstd/gdb/vector.py
diff --git a/scripts/gdb/load.py b/scripts/gdb/load.py
deleted file mode 100644
index ec512b7..0000000
--- a/scripts/gdb/load.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import sys
-import os
-import gdb
-
-script_dir = os.path.dirname(os.path.abspath(__file__))
-
-if script_dir not in sys.path:
- sys.path.insert(0, script_dir)
-
-import kstd
-import kapi
-
-kstd.register_printers(gdb.current_objfile())
-kapi.register_printers(gdb.current_objfile())
-
-gdb.write("Loaded TeachOS pretty printers.\n")
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")