diff options
Diffstat (limited to 'scripts/gdb')
| -rw-r--r-- | scripts/gdb/pretty_printers.py | 6 | ||||
| -rw-r--r-- | scripts/gdb/teachos/__init__.py | 30 |
2 files changed, 35 insertions, 1 deletions
diff --git a/scripts/gdb/pretty_printers.py b/scripts/gdb/pretty_printers.py index 83db491..c209328 100644 --- a/scripts/gdb/pretty_printers.py +++ b/scripts/gdb/pretty_printers.py @@ -4,7 +4,11 @@ import gdb import importlib.util script_path = os.path.abspath(__file__) -repo_root = os.path.dirname(os.path.dirname(os.path.dirname(script_path))) +script_root = os.path.dirname(script_path) +repo_root = os.path.dirname(os.path.dirname(script_root)) + +if script_root not in sys.path: + sys.path.insert(0, script_root) components = { "kstd": "libs/kstd/gdb", diff --git a/scripts/gdb/teachos/__init__.py b/scripts/gdb/teachos/__init__.py new file mode 100644 index 0000000..d90d6ad --- /dev/null +++ b/scripts/gdb/teachos/__init__.py @@ -0,0 +1,30 @@ +import gdb + + +class TeachOSBasePrinter: + def __init__(self, val): + self.__val = val + + @property + def value(self): + return self.__val + + def children(self): + real_type = self.value.type.strip_typedefs() + + if real_type.code not in (gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_UNION): + return + + for field in real_type.fields(): + if field.artificial: + continue + + try: + if field.is_base_class: + yield (field.name, self.value.cast(field.type)) + elif field.name is not None: + yield (field.name, self.value[field.name]) + else: + yield ("<anonymous>", self.value[field]) + except gdb.error: + yield (str(field.name), "<unreadable>") |
