Commit 10475124 authored by hjk's avatar hjk
Browse files

debugger: implement python dumper for std::vector<bool>

parent 3a88a829
...@@ -1969,10 +1969,21 @@ def qdump__std__string(d, item): ...@@ -1969,10 +1969,21 @@ def qdump__std__string(d, item):
def qdump__std__vector(d, item): def qdump__std__vector(d, item):
impl = item.value["_M_impl"] impl = item.value["_M_impl"]
start = impl["_M_start"] type = item.value.type.template_argument(0)
finish = impl["_M_finish"]
alloc = impl["_M_end_of_storage"] alloc = impl["_M_end_of_storage"]
size = finish - start isBool = str(type) == 'bool'
if isBool:
start = impl["_M_start"]["_M_p"]
finish = impl["_M_finish"]["_M_p"]
# FIXME: 32 is sizeof(unsigned long) * CHAR_BIT
storagesize = 32
size = (finish - start) * storagesize
size += impl["_M_finish"]["_M_offset"]
size -= impl["_M_start"]["_M_offset"]
else:
start = impl["_M_start"]
finish = impl["_M_finish"]
size = finish - start
check(0 <= size and size <= 1000 * 1000 * 1000) check(0 <= size and size <= 1000 * 1000 * 1000)
check(finish <= alloc) check(finish <= alloc)
...@@ -1983,11 +1994,18 @@ def qdump__std__vector(d, item): ...@@ -1983,11 +1994,18 @@ def qdump__std__vector(d, item):
d.putItemCount(size) d.putItemCount(size)
d.putNumChild(size) d.putNumChild(size)
if d.isExpanded(item): if d.isExpanded(item):
with Children(d, [size, 10000], item.value.type.template_argument(0)): if isBool:
p = start with Children(d, [size, 10000], type):
for i in d.childRange(): for i in d.childRange():
d.putItem(Item(p.dereference(), item.iname, i)) q = start + i / storagesize
p += 1 data = (q.dereference() >> (i % storagesize)) & 1
d.putBoolItem(str(i), select(data, "true", "false"))
else:
with Children(d, [size, 10000], type):
p = start
for i in d.childRange():
d.putItem(Item(p.dereference(), item.iname, i))
p += 1
def qdump__string(d, item): def qdump__string(d, item):
......
...@@ -1199,7 +1199,7 @@ std::string testStdString() ...@@ -1199,7 +1199,7 @@ std::string testStdString()
return str; return str;
} }
std::vector<int> testStdVector() void testStdVector()
{ {
std::vector<int *> plist1; std::vector<int *> plist1;
plist1.push_back(new int(1)); plist1.push_back(new int(1));
...@@ -1233,8 +1233,9 @@ std::vector<int> testStdVector() ...@@ -1233,8 +1233,9 @@ std::vector<int> testStdVector()
std::vector<bool> vec; std::vector<bool> vec;
vec.push_back(true); vec.push_back(true);
vec.push_back(false); vec.push_back(false);
vec.push_back(false);
return flist2; vec.push_back(true);
vec.push_back(false);
} }
void testQStandardItemModel() void testQStandardItemModel()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment