diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2019-05-21 11:16:37 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2019-05-21 11:16:37 +0000 |
commit | dfa7a5b5b5fc1a878b8c4875c5b943944ef34b3a (patch) | |
tree | 84847896ef9e1a6ef051c74d37c08229b0fa75c6 | |
parent | f7a41aa43b8099c791d5d10a60922062b1ce033f (diff) | |
parent | d1d81c8a07e3e2b68b4eaa8b8cbd6217f7788d1b (diff) | |
download | glib-dfa7a5b5b5fc1a878b8c4875c5b943944ef34b3a.tar.gz |
Merge branch '1780-fix-ghashprinter' into 'master'
Update gdb pretty-printer for GHashTable
Closes #1780
See merge request GNOME/glib!852
-rw-r--r-- | glib/glib_gdb.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/glib/glib_gdb.py b/glib/glib_gdb.py index 1cf2ed936..37d01cb76 100644 --- a/glib/glib_gdb.py +++ b/glib/glib_gdb.py @@ -86,11 +86,27 @@ class GHashPrinter: "Prints a GHashTable" class _iterator: + class _pointer_array: + def __init__(self, ptr, big_items): + self._big_items = big_items + self._gpointer_type = gdb.lookup_type("gpointer") + item_type = self._gpointer_type if self._big_items else gdb.lookup_type("guint") + + self._items = ptr.cast(item_type.pointer()) + + def __getitem__(self, item): + item = self._items[item] + + if not self._big_items: + item = item.cast(self._gpointer_type) + + return item + def __init__(self, ht, keys_are_strings): self.ht = ht if ht != 0: - self.keys = ht["keys"] - self.values = ht["values"] + self.keys = self._pointer_array(ht["keys"], ht["have_big_keys"]) + self.values = self._pointer_array(ht["values"], ht["have_big_values"]) self.hashes = ht["hashes"] self.size = ht["size"] self.pos = 0 |