[glib: 1/2] Update gdb pretty-printer for GHashTable



commit d1d81c8a07e3e2b68b4eaa8b8cbd6217f7788d1b
Author: zb3 <onlylogout gmail com>
Date:   Fri May 17 17:46:24 2019 +0200

    Update gdb pretty-printer for GHashTable
    
    Fixes #1780

 glib/glib_gdb.py | 20 ++++++++++++++++++--
 1 file 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]