forked from qt-creator/qt-creator
Debugger: Fix pointer arithmetic in dumper framework
Task-number: QTCREATORBUG-17428 Change-Id: I1e3a682a6f412af51e191dc783b89ff266020e3b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -2880,9 +2880,12 @@ class DumperBase:
|
|||||||
elif isinstance(index, self.dumper.Field):
|
elif isinstance(index, self.dumper.Field):
|
||||||
field = index
|
field = index
|
||||||
elif self.dumper.isInt(index):
|
elif self.dumper.isInt(index):
|
||||||
if self.type.code in (TypeCodeArray, TypeCodePointer):
|
if self.type.code == TypeCodeArray:
|
||||||
itemAddress = self.laddress + int(index) * self.type.ltarget.size()
|
addr = self.laddress + int(index) * self.type.ltarget.size()
|
||||||
return self.dumper.createValue(itemAddress, self.type.ltarget)
|
return self.dumper.createValue(addr, self.type.ltarget)
|
||||||
|
if self.type.code == TypeCodePointer:
|
||||||
|
addr = self.pointer() + int(index) * self.type.ltarget.size()
|
||||||
|
return self.dumper.createValue(addr, self.type.ltarget)
|
||||||
return self.members(False)[index]
|
return self.members(False)[index]
|
||||||
else:
|
else:
|
||||||
error('BAD INDEX TYPE %s' % type(index))
|
error('BAD INDEX TYPE %s' % type(index))
|
||||||
|
@@ -326,3 +326,11 @@ def qdump__WTF__String(d, value):
|
|||||||
def qdump__QtcDumperTest_FieldAccessByIndex(d, value):
|
def qdump__QtcDumperTest_FieldAccessByIndex(d, value):
|
||||||
d.putValue(value["d"][2].integer())
|
d.putValue(value["d"][2].integer())
|
||||||
|
|
||||||
|
def qdump__QtcDumperTest_PointerArray(d, value):
|
||||||
|
foos = value["foos"]
|
||||||
|
d.putItemCount(10)
|
||||||
|
if d.isExpanded():
|
||||||
|
with Children(d, 10):
|
||||||
|
for i in d.childRange():
|
||||||
|
d.putSubItem(i, foos[i])
|
||||||
|
|
||||||
|
@@ -6412,6 +6412,17 @@ void tst_Dumpers::dumper_data()
|
|||||||
"QtcDumperTest_FieldAccessByIndex d; unused(&d);\n")
|
"QtcDumperTest_FieldAccessByIndex d; unused(&d);\n")
|
||||||
+ Check("d", "12", "QtcDumperTest_FieldAccessByIndex");
|
+ Check("d", "12", "QtcDumperTest_FieldAccessByIndex");
|
||||||
|
|
||||||
|
|
||||||
|
QTest::newRow("Internal2")
|
||||||
|
<< Data("struct Foo { int bar = 15; }; \n"
|
||||||
|
"struct QtcDumperTest_PointerArray {\n"
|
||||||
|
" Foo *foos = new Foo[10];\n"
|
||||||
|
"};\n\n",
|
||||||
|
"QtcDumperTest_PointerArray tc; unused(&tc);\n")
|
||||||
|
+ Check("tc.0.bar", "15", "int")
|
||||||
|
+ Check("tc.1.bar", "15", "int")
|
||||||
|
+ Check("tc.2.bar", "15", "int")
|
||||||
|
+ Check("tc.3.bar", "15", "int");
|
||||||
#if 0
|
#if 0
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
// Hint: To open a failing test in Creator, do:
|
// Hint: To open a failing test in Creator, do:
|
||||||
|
Reference in New Issue
Block a user