]> git.cworth.org Git - vogl/blob - src/voglcore/gdb-dumpers.py
Initial vogl checkin
[vogl] / src / voglcore / gdb-dumpers.py
1 #!/usr/bin/python
2
3 # This file contains debug dumpers / helpers / visualizers so that certain voglcore
4 # classes can be more easily inspected by gdb and QtCreator.
5
6 def qdump__vogl__dynamic_string(d, value):
7     dyn = value["m_dyn"]
8     small = value["m_small"]
9     len = value["m_len"]
10     small_flag = small["m_flag"]
11     d.putAddress(value.address)
12     buf = dyn["m_pStr"]
13     if small_flag == 1:
14         buf = small["m_buf"]
15     strPrefix = "[%d] " % int(len)
16     str = "'" + buf.string(length=len) + "'"
17     d.putValue(strPrefix + str)
18     d.putNumChild(3)
19     with Children(d):
20         d.putSubItem("m_len", len)
21         with SubItem(d, "m_small"):
22             d.putValue( str if small_flag == 1 else "<ignored>")
23             d.putNumChild(2)
24             with Children(d):
25                 d.putSubItem("m_flag", small_flag)
26                 with SubItem(d, "m_buf"):
27                     d.putValue(str if small_flag == 1 else "<ignored>")
28         with SubItem(d, "m_dyn"):
29             d.putValue("<ignored>" if small_flag == 1 else str)
30             d.putNumChild(2)
31             with Children(d):
32                 with SubItem(d, "m_buf_size"):
33                     d.putValue("<ignored>" if small_flag == 1 else dyn["m_buf_size"])
34                 with SubItem(d, "m_pStr"):
35                     d.putValue("<ignored>" if small_flag == 1 else str)
36
37 def qdump__vogl__vector(d, value):
38     size = value["m_size"]
39     capacity = value["m_capacity"]
40     data = value["m_p"]
41     maxDisplayItems = 100
42     innerType = d.templateArgument(value.type, 0)
43     p = data
44     d.putAddress(value.address)
45     d.putValue("[%d]" % size)
46     d.putNumChild(3)
47     if d.isExpanded():
48         with Children(d):
49             d.putSubItem("m_capacity", capacity)
50             d.putSubItem("m_size", size)
51             with SubItem(d, "m_p"):
52                 d.putItemCount(size)
53                 d.putNumChild(size)
54                 numDisplayItems = min(maxDisplayItems, size)
55                 with Children(d, size, maxNumChild=numDisplayItems, childType=innerType, addrBase=p, addrStep=p.dereference().__sizeof__):
56                     for i in range(0,numDisplayItems):
57                         d.putSubItem(i, p.dereference())
58                         p += 1
59
60