forked from qt-creator/qt-creator
Dumpers: Fix operator + for pointers
Add an extensive unit test to prevent future regression. Change-Id: I38b74f9b4f5893285e9afff2ddecaaad106f4114 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
a4bc6e8ee6
commit
279192f17a
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user