diff options
| author | Lukas Oesch <lukas.oesch@ost.ch> | 2026-06-10 10:40:46 +0200 |
|---|---|---|
| committer | Lukas Oesch <lukas.oesch@ost.ch> | 2026-06-10 10:40:46 +0200 |
| commit | 33abd5cf264cb9e34121082105b0bc17b3cf7a36 (patch) | |
| tree | 36b15d53fea04f4f9d9af817100f7ad013bd9b5c /libs/kstd/gdb/vector.py | |
| parent | d01caf1c4aef3c89c68b9d1cc9fe56445f0860b5 (diff) | |
| parent | 7e27130c342b7299a1d2188a7192a7f17b5ac2ad (diff) | |
| download | kernel-33abd5cf264cb9e34121082105b0bc17b3cf7a36.tar.xz kernel-33abd5cf264cb9e34121082105b0bc17b3cf7a36.zip | |
Merge of BA-FS26 branch into develop
See merge request teachos/kernel!49
Diffstat (limited to 'libs/kstd/gdb/vector.py')
| -rw-r--r-- | libs/kstd/gdb/vector.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libs/kstd/gdb/vector.py b/libs/kstd/gdb/vector.py new file mode 100644 index 0000000..f11e064 --- /dev/null +++ b/libs/kstd/gdb/vector.py @@ -0,0 +1,41 @@ +import gdb + + +class KstdVectorPrinter(gdb.ValuePrinter): + class Iterator: + def __init__(self, begin: gdb.Value, end: gdb.Value): + self._item = begin + self._end = end + self._count = 0 + + def __iter__(self): + return self + + def __next__(self): + count = self._count + self._count = count + 1 + + if self._item == self._end: + raise StopIteration + + element = self._item.dereference() + self._item = self._item + 1 + return (f"[{count}]", element) + + def __init__(self, val: gdb.Value): + self.__val = val + self.__size = int(val["m_size"]) + self.__capacity = int(val["m_capacity"]) + self.__data = val["m_data"] + + def to_string(self): + return f"vector of length {self.__size}, capacity {self.__capacity}" + + def children(self): + return self.Iterator(self.__data, self.__data + self.__size) + + def display_hint(self): + return "array" + + def num_children(self): + return self.__size |
