Commit 279192f1 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Dumpers: Fix operator + for pointers



Add an extensive unit test to prevent future regression.

Change-Id: I38b74f9b4f5893285e9afff2ddecaaad106f4114
Reviewed-by: default avatarhjk <hjk@qt.io>
parent a4bc6e8e
......@@ -3104,7 +3104,7 @@ class DumperBase:
if self.dumper.isInt(other):
stripped = self.type.stripTypedefs()
if stripped.code == TypeCodePointer:
address = self.pointer() + stripped.dereference().size()
address = self.pointer() + stripped.dereference().size() * other
val = self.dumper.Value(self.dumper)
val.laddress = None
val.ldata = bytes(struct.pack(self.dumper.packCode + 'Q', address))
......
......@@ -349,3 +349,16 @@ def qdump__QtcDumperTest_PointerArray(d, value):
for i in d.childRange():
d.putSubItem(i, foos[i])
def qdump__QtcDumperTest_BufArray(d, value):
maxItems = 1000
buffer = value['buffer']
count = int(value['count'])
objsize = int(value['objSize'])
valueType = value.type.templateArgument(0)
d.putItemCount(count, maxItems)
d.putNumChild(count)
if d.isExpanded():
with Children(d, count, maxNumChild=maxItems, childType=valueType):
for i in d.childRange():
d.putSubItem(i, (buffer + (i * objsize)).dereference().cast(valueType))
......@@ -6748,6 +6748,32 @@ void tst_Dumpers::dumper_data()
+ Check("tc.3.bar", "15", "int");
QTest::newRow("BufArray")
<< Data("#include <new>\n"
"static int c = 0;\n"
"struct Foo { int bar = c++; int baz = c++; };\n"
"template<class T>\n"
"struct QtcDumperTest_BufArray {\n"
" const int objSize = int(sizeof(T));\n"
" const int count = 10;\n"
" char *buffer;\n"
" QtcDumperTest_BufArray() {\n"
" buffer = new char[count * objSize];\n"
" for (int i = 0; i < count; ++i)\n"
" new(buffer + i * objSize) T;\n"
" }\n"
" ~QtcDumperTest_BufArray() { delete[] buffer; }\n"
"};\n\n",
"QtcDumperTest_BufArray<Foo> arr; unused(&arr);\n")
+ Cxx11Profile()
+ Check("arr.0.bar", "0", "int")
+ Check("arr.0.baz", "1", "int")
+ Check("arr.1.bar", "2", "int")
+ Check("arr.1.baz", "3", "int")
+ Check("arr.2.bar", "4", "int")
+ Check("arr.2.baz", "5", "int");
QTest::newRow("UndefinedStaticMembers")
<< Data("struct Foo { int a = 15; static int b; }; \n",
"Foo f; unused(&f);\n")
......
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