summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/qtcreator/debugger/dumper.py2
-rw-r--r--share/qtcreator/debugger/misctypes.py13
-rw-r--r--tests/auto/debugger/tst_dumpers.cpp26
3 files changed, 40 insertions, 1 deletions
diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py
index 663015e77d..898e3dece2 100644
--- a/share/qtcreator/debugger/dumper.py
+++ b/share/qtcreator/debugger/dumper.py
@@ -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))
diff --git a/share/qtcreator/debugger/misctypes.py b/share/qtcreator/debugger/misctypes.py
index 3550a3def5..d1093bd88b 100644
--- a/share/qtcreator/debugger/misctypes.py
+++ b/share/qtcreator/debugger/misctypes.py
@@ -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))
+
diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp
index f4b5bdb52c..4fbee42cb6 100644
--- a/tests/auto/debugger/tst_dumpers.cpp
+++ b/tests/auto/debugger/tst_dumpers.cpp
@@ -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")