From 99ac955664efa1c99a25e8df5aff09f55abb301c Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 15 May 2017 09:32:23 +0200 Subject: [PATCH] Debugger: Fix display of pointers as arrays Task-number: QTCREATORBUG-18204 Task-number: QTCREATORBUG-17803 Change-Id: I4efe359c206b53ef773127cf29107d3cce720819 Reviewed-by: Eike Ziller Reviewed-by: Christian Stenger --- share/qtcreator/debugger/dumper.py | 2 +- tests/auto/debugger/tst_dumpers.cpp | 32 ++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index 3ff100b5c4c..694efeddd07 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -1385,7 +1385,7 @@ class DumperBase: n = (10, 100, 1000, 10000)[displayFormat - Array10Format] self.putType(typeName) self.putItemCount(n) - self.putArrayData(value.address(), n, innerType) + self.putArrayData(value.pointer(), n, innerType) return if innerType.code == TypeCodeFunction: diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index 4fbee42cb6c..441fe6b4091 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -473,6 +473,13 @@ struct RequiredMessage QString message; }; +struct DumperOptions +{ + DumperOptions(const QString &opts = QString()) : options(opts) {} + + QString options; +}; + struct Check { Check() {} @@ -699,6 +706,12 @@ public: return *this; } + const Data &operator+(const DumperOptions &options) const + { + dumperOptions += options.options; + return *this; + } + const Data &operator+(const Profile &profile) const { profileExtra += profile.contents; @@ -921,6 +934,7 @@ public: mutable QString mainFile = "main.cpp"; mutable QString projectFile = "doit.pro"; + mutable QString dumperOptions; mutable QString profileExtra; mutable QString includes; mutable QString code; @@ -1442,6 +1456,10 @@ void tst_Dumpers::dumper() QStringList args; QString cmds; + QString dumperOptions = data.dumperOptions; + if (!dumperOptions.isEmpty() && !dumperOptions.endsWith(',')) + dumperOptions += ','; + if (m_debuggerEngine == GdbEngine) { const QFileInfo gdbBinaryFile(exe); const QString uninstalledData = gdbBinaryFile.absolutePath() @@ -1465,7 +1483,7 @@ void tst_Dumpers::dumper() "python theDumper.setupDumpers()\n" "run " + nograb + "\n" "up " + QString::number(data.skipLevels) + "\n" - "python theDumper.fetchVariables({" + "python theDumper.fetchVariables({" + dumperOptions + "'token':2,'fancy':1,'forcens':1," "'autoderef':1,'dyntype':1,'passexceptions':1," "'testing':1,'qobjectnames':1," @@ -5320,6 +5338,18 @@ void tst_Dumpers::dumper_data() + Check("a2.3", "[3]", "100", "char"); + QTest::newRow("Array10Format") + << Data("", + "int arr[4] = { 1, 2, 3, 4};\n" + "int *nums = new int[4] { 1, 2, 3, 4};\n") + + + NoLldbEngine // FIXME: DumperOptions not handled yet. + + DumperOptions("'formats':{'local.nums':12}") // Array10Format + + + Check("arr.1", "[1]", "2", "int") + + Check("nums.1", "[1]", "2", "int"); + + QTest::newRow("ArrayQt") << Data("#include \n" "#include \n" + fooData,