3 # This is not quite right, as local vars may override symname
4 def read_global_var (symname):
5 return gdb.selected_frame().read_var(symname)
7 def g_quark_to_string (quark):
13 val = read_global_var ("g_quarks")
14 max_q = long(read_global_var ("g_quark_seq_id"))
16 return val[quark].string()
19 # We override the node printers too, so that node->next is not expanded
20 class GListNodePrinter:
23 def __init__ (self, val):
27 return "{data=%s, next=0x%x, prev=0x%x}" % (str(self.val["data"]), long(self.val["next"]), long(self.val["prev"]))
29 class GSListNodePrinter:
30 "Prints a GSList node"
32 def __init__ (self, val):
36 return "{data=%s, next=0x%x}" % (str(self.val["data"]), long(self.val["next"]))
42 def __init__(self, head, listtype):
44 self.listtype = listtype
53 data = self.link['data']
54 self.link = self.link['next']
56 self.count = self.count + 1
57 return ('[%d]' % count, data)
59 def __init__ (self, val, listtype):
61 self.listtype = listtype
64 return self._iterator(self.val, self.listtype)
67 return "0x%x" % (long(self.val))
69 def display_hint (self):
72 def pretty_printer_lookup (val):
73 if is_g_type_instance (val):
74 return GTypePrettyPrinter (val)
76 def pretty_printer_lookup (val):
77 # None yet, want things like hash table and list
79 type = val.type.unqualified()
81 # If it points to a reference, get the reference.
82 if type.code == gdb.TYPE_CODE_REF:
85 if type.code == gdb.TYPE_CODE_PTR:
86 type = type.target().unqualified()
89 return GListPrinter(val, "GList")
91 return GListPrinter(val, "GSList")
95 return GListNodePrinter(val)
97 return GListPrinter(val, "GSList")
104 obj.pretty_printers.append(pretty_printer_lookup)