diff options
Diffstat (limited to 'scripts/gdb/teachos.py')
| -rw-r--r-- | scripts/gdb/teachos.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/scripts/gdb/teachos.py b/scripts/gdb/teachos.py index 355f6b97..616a9c50 100644 --- a/scripts/gdb/teachos.py +++ b/scripts/gdb/teachos.py @@ -1,6 +1,6 @@ import sys import os -import gdb +import gdb # pyright: ignore[reportMissingModuleSource] import importlib.util script_path = os.path.abspath(__file__) @@ -24,9 +24,20 @@ for component, path in components.items(): if os.path.isfile(init_file): try: spec = importlib.util.spec_from_file_location(component, init_file) + + if spec is None: + gdb.write(f"Warning: Could not create spec for '{component}' from '{init_file}'\n") + continue + module = importlib.util.module_from_spec(spec) sys.modules[component] = module - spec.loader.exec_module(module) + + loader = spec.loader + if loader is None: + gdb.write(f"Warning: No loader found for '{component}' from '{init_file}'\n") + continue + + loader.exec_module(module) if hasattr(module, "register_printers"): module.register_printers(gdb.current_objfile()) |
