From 9b8b8ba97b02241c0ff1e545232badb0fcee294a Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 3 May 2013 18:26:10 +0200 Subject: [PATCH] Debugger: Replace GdbMi::findChild() with an operator[] Less noise. Change-Id: I8e533c97207ff5b9c79182c4fb99993f1992154f Reviewed-by: David Schulz --- src/plugins/debugger/cdb/cdbengine.cpp | 44 ++-- src/plugins/debugger/cdb/cdbparsehelpers.cpp | 30 +-- src/plugins/debugger/debuggerprotocol.cpp | 4 +- src/plugins/debugger/debuggerprotocol.h | 2 +- .../debugger/gdb/abstractplaingdbadapter.cpp | 4 +- src/plugins/debugger/gdb/attachgdbadapter.cpp | 4 +- src/plugins/debugger/gdb/classicgdbengine.cpp | 48 ++-- src/plugins/debugger/gdb/coregdbadapter.cpp | 2 +- src/plugins/debugger/gdb/gdbengine.cpp | 247 +++++++++--------- src/plugins/debugger/gdb/pythongdbengine.cpp | 14 +- .../debugger/gdb/remotegdbserveradapter.cpp | 16 +- src/plugins/debugger/gdb/termgdbadapter.cpp | 4 +- src/plugins/debugger/lldb/lldbengine.cpp | 78 +++--- src/plugins/debugger/pdb/pdbengine.cpp | 10 +- src/plugins/debugger/threadshandler.cpp | 28 +- src/plugins/debugger/watchdata.cpp | 52 ++-- tests/auto/debugger/tst_dumpers.cpp | 6 +- 17 files changed, 298 insertions(+), 295 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 6dcf854bb3..9adc678c50 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -1821,14 +1821,14 @@ void CdbEngine::handlePid(const CdbExtensionCommandPtr &reply) static Register parseRegister(const GdbMi &gdbmiReg) { Register reg; - reg.name = gdbmiReg.findChild("name").data(); - const GdbMi description = gdbmiReg.findChild("description"); + reg.name = gdbmiReg["name"].data(); + const GdbMi description = gdbmiReg["description"]; if (description.type() != GdbMi::Invalid) { reg.name += " ("; reg.name += description.data(); reg.name += ')'; } - reg.value = gdbmiReg.findChild("value").data(); + reg.value = gdbmiReg["value"].data(); return reg; } @@ -1842,11 +1842,11 @@ void CdbEngine::handleModules(const CdbExtensionCommandPtr &reply) modules.reserve(value.childCount()); foreach (const GdbMi &gdbmiModule, value.children()) { Module module; - module.moduleName = QString::fromLatin1(gdbmiModule.findChild("name").data()); - module.modulePath = QString::fromLatin1(gdbmiModule.findChild("image").data()); - module.startAddress = gdbmiModule.findChild("start").data().toULongLong(0, 0); - module.endAddress = gdbmiModule.findChild("end").data().toULongLong(0, 0); - if (gdbmiModule.findChild("deferred").type() == GdbMi::Invalid) + module.moduleName = QString::fromLatin1(gdbmiModule["name"].data()); + module.modulePath = QString::fromLatin1(gdbmiModule["image"].data()); + module.startAddress = gdbmiModule["start"].data().toULongLong(0, 0); + module.endAddress = gdbmiModule["end"].data().toULongLong(0, 0); + if (gdbmiModule["deferred"].type() == GdbMi::Invalid) module.symbolsRead = Module::ReadOk; modules.push_back(module); } @@ -1902,8 +1902,8 @@ void CdbEngine::handleLocals(const CdbExtensionCommandPtr &reply) // Courtesy of GDB engine foreach (const GdbMi &child, root.children()) { WatchData dummy; - dummy.iname = child.findChild("iname").data(); - dummy.name = QLatin1String(child.findChild("name").data()); + dummy.iname = child["iname"].data(); + dummy.name = QLatin1String(child["name"].data()); parseWatchData(watchHandler()->expandedINames(), dummy, child, &watchData); } // Fix the names of watch data. @@ -2023,7 +2023,7 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, rc |= StopShutdownInProgress; if (debug) qDebug("%s", stopReason.toString(true, 4).constData()); - const QByteArray reason = stopReason.findChild("reason").data(); + const QByteArray reason = stopReason["reason"].data(); if (reason.isEmpty()) { *message = tr("Malformed stop response received."); rc |= StopReportParseError|StopNotifyStop; @@ -2036,12 +2036,12 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, rc |= StopReportLog; return rc; } - const int threadId = stopReason.findChild("threadId").data().toInt(); + const int threadId = stopReason["threadId"].data().toInt(); if (reason == "breakpoint") { // Note: Internal breakpoints (run to line) are reported with id=0. // Step out creates temporary breakpoints with id 10000. int number = 0; - BreakpointModelId id = cdbIdToBreakpointModelId(stopReason.findChild("breakpointId")); + BreakpointModelId id = cdbIdToBreakpointModelId(stopReason["breakpointId"]); if (id.isValid()) { if (breakHandler()->engineBreakpointIds(this).contains(id)) { const BreakpointResponse parameters = breakHandler()->response(id); @@ -2211,7 +2211,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT // Re-fetch stack again. postCommandSequence(CommandListStack); } else { - const GdbMi stack = stopReason.findChild("stack"); + const GdbMi stack = stopReason["stack"]; if (stack.isValid()) { switch (parseStackTrace(stack, sourceStepInto)) { case ParseStackStepInto: // Hit on a frame while step into, see parseStackTrace(). @@ -2222,16 +2222,16 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT return; } } else { - showMessage(QString::fromLatin1(stopReason.findChild("stackerror").data()), LogError); + showMessage(QString::fromLatin1(stopReason["stackerror"].data()), LogError); } } - const GdbMi threads = stopReason.findChild("threads"); + const GdbMi threads = stopReason["threads"]; if (threads.isValid()) { threadsHandler()->updateThreads(threads); if (forcedThreadId.isValid()) threadsHandler()->setCurrentThread(forcedThreadId); } else { - showMessage(QString::fromLatin1(stopReason.findChild("threaderror").data()), LogError); + showMessage(QString::fromLatin1(stopReason["threaderror"].data()), LogError); } // Fire off remaining commands asynchronously if (!m_pendingBreakpointMap.isEmpty()) @@ -2839,15 +2839,15 @@ static StackFrames parseFrames(const GdbMi &gdbmi, bool *incomplete = 0) } StackFrame frame; frame.level = i; - const GdbMi fullName = frameMi.findChild("fullname"); + const GdbMi fullName = frameMi["fullname"]; if (fullName.isValid()) { frame.file = QFile::decodeName(fullName.data()); - frame.line = frameMi.findChild("line").data().toInt(); + frame.line = frameMi["line"].data().toInt(); frame.usable = false; // To be decided after source path mapping. } - frame.function = QLatin1String(frameMi.findChild("func").data()); - frame.from = QLatin1String(frameMi.findChild("from").data()); - frame.address = frameMi.findChild("addr").data().toULongLong(0, 16); + frame.function = QLatin1String(frameMi["func"].data()); + frame.from = QLatin1String(frameMi["from"].data()); + frame.address = frameMi["addr"].data().toULongLong(0, 16); rc.push_back(frame); } return rc; diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.cpp b/src/plugins/debugger/cdb/cdbparsehelpers.cpp index eb49328c03..862a8fa0ab 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.cpp +++ b/src/plugins/debugger/cdb/cdbparsehelpers.cpp @@ -298,7 +298,7 @@ static inline bool parseThread(QByteArray line, ThreadData *thread, bool *curren // Helper to retrieve an int child from GDBMI static inline bool gdbmiChildToInt(const GdbMi &parent, const char *childName, int *target) { - const GdbMi childBA = parent.findChild(childName); + const GdbMi childBA = parent[childName]; if (childBA.isValid()) { bool ok; const int v = childBA.data().toInt(&ok); @@ -313,7 +313,7 @@ static inline bool gdbmiChildToInt(const GdbMi &parent, const char *childName, i // Helper to retrieve an bool child from GDBMI static inline bool gdbmiChildToBool(const GdbMi &parent, const char *childName, bool *target) { - const GdbMi childBA = parent.findChild(childName); + const GdbMi childBA = parent[childName]; if (childBA.isValid()) { *target = childBA.data() == "true"; return true; @@ -331,16 +331,16 @@ void parseBreakPoint(const GdbMi &gdbmi, BreakpointResponse *r, gdbmiChildToBool(gdbmi, "deferred", &(r->pending)); r->id = BreakpointResponseId(); // Might not be valid if there is not id - r->id = cdbIdToBreakpointResponseId(gdbmi.findChild("id")); - const GdbMi moduleG = gdbmi.findChild("module"); + r->id = cdbIdToBreakpointResponseId(gdbmi["id"]); + const GdbMi moduleG = gdbmi["module"]; if (moduleG.isValid()) r->module = QString::fromLocal8Bit(moduleG.data()); if (expression) { - const GdbMi expressionG = gdbmi.findChild("expression"); + const GdbMi expressionG = gdbmi["expression"]; if (expressionG.isValid()) *expression = QString::fromLocal8Bit(expressionG.data()); } - const GdbMi addressG = gdbmi.findChild("address"); + const GdbMi addressG = gdbmi["address"]; if (addressG.isValid()) r->address = addressG.data().toULongLong(0, 0); if (gdbmiChildToInt(gdbmi, "passcount", &(r->ignoreCount))) @@ -410,23 +410,23 @@ WinException::WinException() : void WinException::fromGdbMI(const GdbMi &gdbmi) { - exceptionCode = gdbmi.findChild("exceptionCode").data().toUInt(); - exceptionFlags = gdbmi.findChild("exceptionFlags").data().toUInt(); - exceptionAddress = gdbmi.findChild("exceptionAddress").data().toULongLong(); - firstChance = gdbmi.findChild("firstChance").data() != "0"; - const GdbMi ginfo1 = gdbmi.findChild("exceptionInformation0"); + exceptionCode = gdbmi["exceptionCode"].data().toUInt(); + exceptionFlags = gdbmi["exceptionFlags"].data().toUInt(); + exceptionAddress = gdbmi["exceptionAddress"].data().toULongLong(); + firstChance = gdbmi["firstChance"].data() != "0"; + const GdbMi ginfo1 = gdbmi["exceptionInformation0"]; if (ginfo1.isValid()) { info1 = ginfo1.data().toULongLong(); - const GdbMi ginfo2 = gdbmi.findChild("exceptionInformation1"); + const GdbMi ginfo2 = gdbmi["exceptionInformation1"]; if (ginfo2.isValid()) info2 = ginfo1.data().toULongLong(); } - const GdbMi gLineNumber = gdbmi.findChild("exceptionLine"); + const GdbMi gLineNumber = gdbmi["exceptionLine"]; if (gLineNumber.isValid()) { lineNumber = gLineNumber.data().toInt(); - file = gdbmi.findChild("exceptionFile").data(); + file = gdbmi["exceptionFile"].data(); } - function = gdbmi.findChild("exceptionFunction").data(); + function = gdbmi["exceptionFunction"].data(); } QString WinException::toString(bool includeLocation) const diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index b2cabdade1..53d787a9d7 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -331,9 +331,9 @@ void GdbMi::fromStringMultiple(const QByteArray &ba) parseTuple_helper(from, to); } -GdbMi GdbMi::findChild(const char *name) const +GdbMi GdbMi::operator[](const char *name) const { - for (int i = 0; i < m_children.size(); ++i) + for (int i = 0, n = m_children.size(); i < n; ++i) if (m_children.at(i).m_name == name) return m_children.at(i); return GdbMi(); diff --git a/src/plugins/debugger/debuggerprotocol.h b/src/plugins/debugger/debuggerprotocol.h index 8f3df34bca..8920e9eed5 100644 --- a/src/plugins/debugger/debuggerprotocol.h +++ b/src/plugins/debugger/debuggerprotocol.h @@ -119,7 +119,7 @@ public: const GdbMi &childAt(int index) const { return m_children[index]; } GdbMi &childAt(int index) { return m_children[index]; } - GdbMi findChild(const char *name) const; + GdbMi operator[](const char *name) const; QByteArray toString(bool multiline = false, int indent = 0) const; qulonglong toAddress() const; diff --git a/src/plugins/debugger/gdb/abstractplaingdbadapter.cpp b/src/plugins/debugger/gdb/abstractplaingdbadapter.cpp index 84488944f8..dc39a49f67 100644 --- a/src/plugins/debugger/gdb/abstractplaingdbadapter.cpp +++ b/src/plugins/debugger/gdb/abstractplaingdbadapter.cpp @@ -65,7 +65,7 @@ void GdbAbstractPlainEngine::handleFileExecAndSymbols(const GdbResponse &respons if (response.resultClass == GdbResultDone) { handleInferiorPrepared(); } else { - QByteArray ba = response.data.findChild("msg").data(); + QByteArray ba = response.data["msg"].data(); QString msg = fromLocalEncoding(ba); // Extend the message a bit in unknown cases. if (!ba.endsWith("File format not recognized")) @@ -92,7 +92,7 @@ void GdbAbstractPlainEngine::handleExecRun(const GdbResponse &response) if (debuggerCore()->boolSetting(EnableReverseDebugging)) postCommand("target record"); } else { - QString msg = fromLocalEncoding(response.data.findChild("msg").data()); + QString msg = fromLocalEncoding(response.data["msg"].data()); //QTC_CHECK(status() == InferiorRunOk); //interruptInferior(); showMessage(msg); diff --git a/src/plugins/debugger/gdb/attachgdbadapter.cpp b/src/plugins/debugger/gdb/attachgdbadapter.cpp index 5fd49de81c..bd4cd51694 100644 --- a/src/plugins/debugger/gdb/attachgdbadapter.cpp +++ b/src/plugins/debugger/gdb/attachgdbadapter.cpp @@ -96,13 +96,13 @@ void GdbAttachEngine::handleAttach(const GdbResponse &response) handleInferiorPrepared(); break; case GdbResultError: - if (response.data.findChild("msg").data() == "ptrace: Operation not permitted.") { + if (response.data["msg"].data() == "ptrace: Operation not permitted.") { notifyInferiorSetupFailed(DumperHelper::msgPtraceError(startParameters().startMode)); break; } // if msg != "ptrace: ..." fall through default: - QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data()); + QString msg = QString::fromLocal8Bit(response.data["msg"].data()); notifyInferiorSetupFailed(msg); } } diff --git a/src/plugins/debugger/gdb/classicgdbengine.cpp b/src/plugins/debugger/gdb/classicgdbengine.cpp index e0e692528c..76f6313ca8 100644 --- a/src/plugins/debugger/gdb/classicgdbengine.cpp +++ b/src/plugins/debugger/gdb/classicgdbengine.cpp @@ -271,7 +271,7 @@ static QByteArray qClassName(const QByteArray &qtNamespace, const char *classNam static double getDumperVersion(const GdbMi &contents) { - const GdbMi dumperVersionG = contents.findChild("dumperversion"); + const GdbMi dumperVersionG = contents["dumperversion"]; if (dumperVersionG.type() != GdbMi::Invalid) { bool ok; const double v = QString::fromLatin1(dumperVersionG.data()).toDouble(&ok); @@ -302,10 +302,10 @@ bool DumperHelper::parseQuery(const GdbMi &contents) qDebug() << "parseQuery" << contents.toString(true, 2); // Common info, dumper version, etc - QByteArray ns = contents.findChild("namespace").data(); + QByteArray ns = contents["namespace"].data(); setQtNamespace(ns); int qtv = 0; - const GdbMi qtversion = contents.findChild("qtversion"); + const GdbMi qtversion = contents["qtversion"]; if (qtversion.children().size() == 3) { qtv = (qtversion.childAt(0).data().toInt() << 16) + (qtversion.childAt(1).data().toInt() << 8) @@ -314,7 +314,7 @@ bool DumperHelper::parseQuery(const GdbMi &contents) m_qtVersion = qtv; // Get list of helpers QByteArrayList availableSimpleDebuggingHelpers; - foreach (const GdbMi &item, contents.findChild("dumpers").children()) + foreach (const GdbMi &item, contents["dumpers"].children()) availableSimpleDebuggingHelpers.append(item.data()); // Parse types @@ -326,7 +326,7 @@ bool DumperHelper::parseQuery(const GdbMi &contents) m_dumperVersion = getDumperVersion(contents); // Parse sizes - foreach (const GdbMi &sizesList, contents.findChild("sizes").children()) { + foreach (const GdbMi &sizesList, contents["sizes"].children()) { const int childCount = sizesList.childCount(); if (childCount > 1) { const int size = sizesList.childAt(0).data().toInt(); @@ -335,7 +335,7 @@ bool DumperHelper::parseQuery(const GdbMi &contents) } } // Parse expressions - foreach (const GdbMi &exprList, contents.findChild("expressions").children()) + foreach (const GdbMi &exprList, contents["expressions"].children()) if (exprList.childCount() == 2) m_expressionCache.insert(exprList.childAt(0).data(), exprList.childAt(1).data()); @@ -1011,8 +1011,8 @@ void GdbEngine::handleDebuggingHelperValue2Classic(const GdbResponse &response) return; } - data.updateType(response.data.findChild("type")); - data.updateDisplayedType(response.data.findChild("displaytype")); + data.updateType(response.data["type"]); + data.updateDisplayedType(response.data["displaytype"]); QList list; parseWatchData(watchHandler()->expandedINames(), data, contents, &list); //for (int i = 0; i != list.size(); ++i) @@ -1198,9 +1198,9 @@ void GdbEngine::handleStackListArgumentsClassic(const GdbResponse &response) // is ok. m_currentFunctionArgs.clear(); if (response.resultClass == GdbResultDone) { - const GdbMi list = response.data.findChild("stack-args"); - const GdbMi frame = list.findChild("frame"); - const GdbMi args = frame.findChild("args"); + const GdbMi list = response.data["stack-args"]; + const GdbMi frame = list["frame"]; + const GdbMi args = frame["args"]; m_currentFunctionArgs = args.children(); } else { // Seems to occur on "RedHat 4 based Linux" gdb 7.0.1: @@ -1215,7 +1215,7 @@ void GdbEngine::handleStackListLocalsClassic(const GdbResponse &response) // stage 2/2 // There could be shadowed variables - QList locals = response.data.findChild("locals").children(); + QList locals = response.data["locals"].children(); locals += m_currentFunctionArgs; QMap seen; // If desired, retrieve list of uninitialized variables looking at @@ -1346,7 +1346,7 @@ void GdbEngine::handleQueryDebuggingHelperClassic(const GdbResponse &response) void GdbEngine::handleDebuggingHelperVersionCheckClassic(const GdbResponse &response) { if (response.resultClass == GdbResultDone) { - QString value = _(response.data.findChild("value").data()); + QString value = _(response.data["value"].data()); QString debuggeeQtVersion = value.section(QLatin1Char('"'), 1, 1); QString dumperQtVersion = QLatin1String(m_dumperHelper.qtVersionString()); if (debuggeeQtVersion.isEmpty()) { @@ -1375,8 +1375,8 @@ void GdbEngine::handleVarListChildrenHelperClassic(const GdbMi &item, { //qDebug() << "VAR_LIST_CHILDREN: PARENT" << parent.toString(); //qDebug() << "VAR_LIST_CHILDREN: ITEM" << item.toString(); - QByteArray exp = item.findChild("exp").data(); - QByteArray name = item.findChild("name").data(); + QByteArray exp = item["exp"].data(); + QByteArray name = item["name"].data(); if (isAccessSpecifier(exp)) { // Suppress 'private'/'protected'/'public' level. WatchData data; @@ -1393,15 +1393,15 @@ void GdbEngine::handleVarListChildrenHelperClassic(const GdbMi &item, postCommand(cmd, Discardable, CB(handleVarListChildrenClassic), QVariant::fromValue(data)); } else if (!startsWithDigit(QLatin1String(exp)) - && item.findChild("numchild").data() == "0") { + && item["numchild"].data() == "0") { // Happens for structs without data, e.g. interfaces. WatchData data; data.name = _(exp); data.iname = parent.iname + '.' + data.name.toLatin1(); data.variable = name; - data.updateType(item.findChild("type")); + data.updateType(item["type"]); data.updateValue(item); - data.updateAddress(item.findChild("addr")); + data.updateAddress(item["addr"]); data.setHasChildren(false); insertData(data); } else if (parent.iname.endsWith('.')) { @@ -1423,10 +1423,10 @@ void GdbEngine::handleVarListChildrenHelperClassic(const GdbMi &item, data.iname = parent.iname + '.' + exp; data.variable = name; data.sortId = sortId; - data.updateType(item.findChild("type")); + data.updateType(item["type"]); data.updateValue(item); - data.updateAddress(item.findChild("addr")); - data.updateChildCount(item.findChild("numchild")); + data.updateAddress(item["addr"]); + data.updateChildCount(item["numchild"]); if (!watchHandler()->isExpandedIName(data.iname)) data.setChildrenUnneeded(); @@ -1481,7 +1481,7 @@ void GdbEngine::handleVarListChildrenClassic(const GdbResponse &response) return; if (response.resultClass == GdbResultDone) { //qDebug() << "VAR_LIST_CHILDREN: PARENT" << data.toString(); - QList children = response.data.findChild("children").children(); + QList children = response.data["children"].children(); if (children.isEmpty()) { // happens e.g. if no debug information is present or @@ -1509,7 +1509,7 @@ void GdbEngine::handleVarListChildrenClassic(const GdbResponse &response) handleVarListChildrenHelperClassic(children.at(i), data, i); } } else { - data.setError(QString::fromLocal8Bit(response.data.findChild("msg").data())); + data.setError(QString::fromLocal8Bit(response.data["msg"].data())); } } @@ -1523,7 +1523,7 @@ void GdbEngine::handleEvaluateExpressionClassic(const GdbResponse &response) //else data.updateValue(response.data); } else { - data.setError(QString::fromLocal8Bit(response.data.findChild("msg").data())); + data.setError(QString::fromLocal8Bit(response.data["msg"].data())); } //qDebug() << "HANDLE EVALUATE EXPRESSION:" << data.toString(); insertData(data); diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp index d82b6cd129..fb31d37f90 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.cpp +++ b/src/plugins/debugger/gdb/coregdbadapter.cpp @@ -190,7 +190,7 @@ void GdbCoreEngine::handleTargetCore(const GdbResponse &response) } QString msg = tr("Attach to core \"%1\" failed:\n") .arg(startParameters().coreFile) - + QString::fromLocal8Bit(response.data.findChild("msg").data()); + + QString::fromLocal8Bit(response.data["msg"].data()); notifyInferiorSetupFailed(msg); } diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 46fa703ded..ed72d56f93 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -451,7 +451,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) m_pendingLogStreamOutput.clear(); m_pendingConsoleStreamOutput.clear(); } else if (asyncClass == "running") { - GdbMi threads = result.findChild("thread-id"); + GdbMi threads = result["thread-id"]; threadsHandler()->notifyRunning(threads.data()); if (state() == InferiorRunOk || state() == InferiorSetupRequested) { // We get multiple *running after thread creation and in Windows terminals. @@ -470,7 +470,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) // target-name="/lib/i386-linux-gnu/libc.so.6" // host-name="/lib/i386-linux-gnu/libc.so.6" // symbols-loaded="0",thread-group="i1" - QByteArray id = result.findChild("id").data(); + QByteArray id = result["id"].data(); if (!id.isEmpty()) showStatusMessage(tr("Library %1 loaded").arg(_(id)), 1000); progressPing(); @@ -478,15 +478,15 @@ void GdbEngine::handleResponse(const QByteArray &buff) Module module; module.startAddress = 0; module.endAddress = 0; - module.hostPath = _(result.findChild("host-name").data()); - module.modulePath = _(result.findChild("target-name").data()); + module.hostPath = _(result["host-name"].data()); + module.modulePath = _(result["target-name"].data()); module.moduleName = QFileInfo(module.hostPath).baseName(); modulesHandler()->updateModule(module); } else if (asyncClass == "library-unloaded") { // Archer has 'id="/usr/lib/libdrm.so.2", // target-name="/usr/lib/libdrm.so.2", // host-name="/usr/lib/libdrm.so.2" - QByteArray id = result.findChild("id").data(); + QByteArray id = result["id"].data(); progressPing(); showStatusMessage(tr("Library %1 unloaded").arg(_(id)), 1000); invalidateSourcesList(); @@ -499,11 +499,11 @@ void GdbEngine::handleResponse(const QByteArray &buff) // 7.0.x, there was a *-created instead. progressPing(); // 7.1.50 has thread-group-started,id="i1",pid="3529" - QByteArray id = result.findChild("id").data(); + QByteArray id = result["id"].data(); showStatusMessage(tr("Thread group %1 created").arg(_(id)), 1000); int pid = id.toInt(); if (!pid) { - id = result.findChild("pid").data(); + id = result["pid"].data(); pid = id.toInt(); } if (pid) @@ -511,26 +511,26 @@ void GdbEngine::handleResponse(const QByteArray &buff) handleThreadGroupCreated(result); } else if (asyncClass == "thread-created") { //"{id="1",group-id="28902"}" - QByteArray id = result.findChild("id").data(); + QByteArray id = result["id"].data(); showStatusMessage(tr("Thread %1 created").arg(_(id)), 1000); ThreadData thread; thread.id = ThreadId(id.toLong()); - thread.groupId = result.findChild("group-id").data(); + thread.groupId = result["group-id"].data(); threadsHandler()->updateThread(thread); } else if (asyncClass == "thread-group-exited") { // Archer has "{id="28902"}" - QByteArray id = result.findChild("id").data(); + QByteArray id = result["id"].data(); showStatusMessage(tr("Thread group %1 exited").arg(_(id)), 1000); handleThreadGroupExited(result); } else if (asyncClass == "thread-exited") { //"{id="1",group-id="28902"}" - QByteArray id = result.findChild("id").data(); - QByteArray groupid = result.findChild("group-id").data(); + QByteArray id = result["id"].data(); + QByteArray groupid = result["group-id"].data(); showStatusMessage(tr("Thread %1 in group %2 exited") .arg(_(id)).arg(_(groupid)), 1000); threadsHandler()->removeThread(ThreadId(id.toLong())); } else if (asyncClass == "thread-selected") { - QByteArray id = result.findChild("id").data(); + QByteArray id = result["id"].data(); showStatusMessage(tr("Thread %1 selected").arg(_(id)), 1000); //"{id="2"}" } else if (m_isMacGdb && asyncClass == "shlibs-updated") { @@ -550,8 +550,8 @@ void GdbEngine::handleResponse(const QByteArray &buff) // bkpt={number="1",type="breakpoint",disp="keep",enabled="y", // addr="0x0000000115cc3ddf",func="foo()",file="../foo.cpp", // line="1584",shlib="/../libFoo_debug.dylib",times="0"} - const GdbMi bkpt = result.findChild("bkpt"); - const BreakpointResponseId rid(bkpt.findChild("number").data()); + const GdbMi bkpt = result["bkpt"]; + const BreakpointResponseId rid(bkpt["number"].data()); if (!isQmlStepBreakpoint(rid)) { BreakHandler *handler = breakHandler(); BreakpointModelId id = handler->findBreakpointByResponseId(rid); @@ -584,7 +584,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) BreakpointModelId id; BreakpointResponse br; foreach (const GdbMi &bkpt, result.children()) { - const QByteArray nr = bkpt.findChild("number").data(); + const QByteArray nr = bkpt["number"].data(); BreakpointResponseId rid(nr); if (!isHiddenBreakpoint(rid)) { if (nr.contains('.')) { @@ -625,7 +625,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) // "breakpoint-deleted" "{id="1"}" // New in FSF gdb since 2011-04-27. BreakHandler *handler = breakHandler(); - QByteArray nr = result.findChild("id").data(); + QByteArray nr = result["id"].data(); BreakpointResponseId rid(nr); BreakpointModelId id = handler->findBreakpointByResponseId(rid); if (id.isValid()) { @@ -1088,7 +1088,7 @@ void GdbEngine::handleResultRecord(GdbResponse *response) "TWO RESPONSES FOR ONE COMMAND?").arg(token). arg(QString::fromLatin1(stateName(state())))); if (response->resultClass == GdbResultError) { - QByteArray msg = response->data.findChild("msg").data(); + QByteArray msg = response->data["msg"].data(); if (msg == "Cannot find new threads: generic error") { // Handle a case known to occur on Linux/gdb 6.8 when debugging moc // with helpers enabled. In this case we get a second response with @@ -1283,12 +1283,12 @@ void GdbEngine::handleQuerySources(const GdbResponse &response) m_fullToShortName.clear(); // "^done,files=[{file="../../../../bin/dumper/dumper.cpp", // fullname="/data5/dev/ide/main/bin/dumper/dumper.cpp"}, - GdbMi files = response.data.findChild("files"); + GdbMi files = response.data["files"]; foreach (const GdbMi &item, files.children()) { - GdbMi fileName = item.findChild("file"); + GdbMi fileName = item["file"]; if (fileName.data().endsWith("")) continue; - GdbMi fullName = item.findChild("fullname"); + GdbMi fullName = item["fullname"]; QString file = QString::fromLocal8Bit(fileName.data()); QString full; if (fullName.isValid()) { @@ -1394,10 +1394,10 @@ void GdbEngine::handleStopResponse(const GdbMi &data) return; } - GdbMi threads = data.findChild("stopped-thread"); + GdbMi threads = data["stopped-thread"]; threadsHandler()->notifyStopped(threads.data()); - const QByteArray reason = data.findChild("reason").data(); + const QByteArray reason = data["reason"].data(); if (isExitedReason(reason)) { // // The user triggered a stop, but meanwhile the app simply exited ... @@ -1407,10 +1407,10 @@ void GdbEngine::handleStopResponse(const GdbMi &data) QString msg; if (reason == "exited") { msg = tr("Application exited with exit code %1") - .arg(_(data.findChild("exit-code").toString())); + .arg(_(data["exit-code"].toString())); } else if (reason == "exited-signalled" || reason == "signal-received") { msg = tr("Application exited after receiving signal %1") - .arg(_(data.findChild("signal-name").toString())); + .arg(_(data["signal-name"].toString())); } else { msg = tr("Application exited normally"); } @@ -1429,18 +1429,18 @@ void GdbEngine::handleStopResponse(const GdbMi &data) gotoHandleStop1 = false; } - BreakpointResponseId rid(data.findChild("bkptno").data()); - const GdbMi frame = data.findChild("frame"); + BreakpointResponseId rid(data["bkptno"].data()); + const GdbMi frame = data["frame"]; int lineNumber = 0; QString fullName; if (frame.isValid()) { - const GdbMi lineNumberG = frame.findChild("line"); + const GdbMi lineNumberG = frame["line"]; if (lineNumberG.isValid()) { lineNumber = lineNumberG.data().toInt(); - fullName = cleanupFullName(QString::fromLocal8Bit(frame.findChild("fullname").data())); + fullName = cleanupFullName(QString::fromLocal8Bit(frame["fullname"].data())); if (fullName.isEmpty()) - fullName = QString::fromLocal8Bit(frame.findChild("file").data()); + fullName = QString::fromLocal8Bit(frame["file"].data()); } // found line number } else { showMessage(_("INVALID STOPPED REASON"), LogWarning); @@ -1533,8 +1533,8 @@ void GdbEngine::handleStop1(const GdbMi &data) { QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); QTC_ASSERT(!isDying(), return); - const GdbMi frame = data.findChild("frame"); - const QByteArray reason = data.findChild("reason").data(); + const GdbMi frame = data["frame"]; + const QByteArray reason = data["reason"].data(); // This was seen on XP after removing a breakpoint while running // >945*stopped,reason="signal-received",signal-name="SIGTRAP", @@ -1558,8 +1558,8 @@ void GdbEngine::handleStop1(const GdbMi &data) if (debuggerCore()->boolSetting(SkipKnownFrames)) { if (reason == "end-stepping-range" || reason == "function-finished") { //showMessage(frame.toString()); - QString funcName = _(frame.findChild("func").data()); - QString fileName = QString::fromLocal8Bit(frame.findChild("file").data()); + QString funcName = _(frame["func"].data()); + QString fileName = QString::fromLocal8Bit(frame["file"].data()); if (isLeavableFunction(funcName, fileName)) { //showMessage(_("LEAVING ") + funcName); ++stepCounter; @@ -1584,7 +1584,7 @@ void GdbEngine::handleStop1(const GdbMi &data) // fullname="/../app.cpp",line="1611"},gdb-result-var="$1", // return-value="{d = 0x808d998}",thread-id="1",stopped-threads="all", // core="1" - GdbMi resultVar = data.findChild("gdb-result-var"); + GdbMi resultVar = data["gdb-result-var"]; if (resultVar.isValid()) m_resultVarName = resultVar.data(); else @@ -1603,7 +1603,7 @@ void GdbEngine::handleStop1(const GdbMi &data) if (initHelpers && dumperHandling() != DumperLoadedByGdbPreload && reason == "signal-received") { - const QByteArray name = data.findChild("signal-name").data(); + const QByteArray name = data["signal-name"].data(); const DebuggerStartParameters &sp = startParameters(); if (name != stopSignal(sp.toolChainAbi)) initHelpers = false; @@ -1656,15 +1656,15 @@ void GdbEngine::handleStop2(const GdbMi &data) // dNOTE: INFERIOR STOP OK // dState changed from InferiorStopRequested(13) to InferiorStopOk(14). - const QByteArray reason = data.findChild("reason").data(); - const QByteArray func = data.findChild("frame").findChild("from").data(); + const QByteArray reason = data["reason"].data(); + const QByteArray func = data["frame"]["from"].data(); const DebuggerStartParameters &sp = startParameters(); bool isStopperThread = false; if (sp.useTerminal && reason == "signal-received" - && data.findChild("signal-name").data() == "SIGSTOP" + && data["signal-name"].data() == "SIGSTOP" && (func.endsWith("/ld-linux.so.2") || func.endsWith("/ld-linux-x86-64.so.2"))) { @@ -1677,7 +1677,7 @@ void GdbEngine::handleStop2(const GdbMi &data) if (sp.toolChainAbi.os() == Abi::WindowsOS && sp.useTerminal && reason == "signal-received" - && data.findChild("signal-name").data() == "SIGTRAP") + && data["signal-name"].data() == "SIGTRAP") { // This is the stopper thread. That also means that the // reported thread is not the one we'd like to expose @@ -1700,19 +1700,19 @@ void GdbEngine::handleStop2(const GdbMi &data) // func="QScopedPointer",args=[{name="this",value="0xbfffed40"}, // {name="p",value="0x0"}],file="x.h",fullname="/home/.../x.h",line="95"}, // thread-id="1",stopped-threads="all",core="2" - const GdbMi wpt = data.findChild("wpt"); - const BreakpointResponseId rid(wpt.findChild("number").data()); + const GdbMi wpt = data["wpt"]; + const BreakpointResponseId rid(wpt["number"].data()); const BreakpointModelId id = breakHandler()->findBreakpointByResponseId(rid); - const quint64 bpAddress = wpt.findChild("exp").data().mid(1).toULongLong(0, 0); + const quint64 bpAddress = wpt["exp"].data().mid(1).toULongLong(0, 0); QString msg; if (id && breakHandler()->type(id) == WatchpointAtExpression) msg = msgWatchpointByExpressionTriggered(id, rid.majorPart(), breakHandler()->expression(id)); if (id && breakHandler()->type(id) == WatchpointAtAddress) msg = msgWatchpointByAddressTriggered(id, rid.majorPart(), bpAddress); - GdbMi value = data.findChild("value"); - GdbMi oldValue = value.findChild("old"); - GdbMi newValue = value.findChild("new"); + GdbMi value = data["value"]; + GdbMi oldValue = value["old"]; + GdbMi newValue = value["new"]; if (oldValue.isValid() && newValue.isValid()) { msg += QLatin1Char(' '); msg += tr("Value changed from %1 to %2.") @@ -1720,19 +1720,19 @@ void GdbEngine::handleStop2(const GdbMi &data) } showStatusMessage(msg); } else if (reason == "breakpoint-hit") { - GdbMi gNumber = data.findChild("bkptno"); // 'number' or 'bkptno'? + GdbMi gNumber = data["bkptno"]; // 'number' or 'bkptno'? if (!gNumber.isValid()) - gNumber = data.findChild("number"); + gNumber = data["number"]; const BreakpointResponseId rid(gNumber.data()); - const QByteArray threadId = data.findChild("thread-id").data(); + const QByteArray threadId = data["thread-id"].data(); const BreakpointModelId id = breakHandler()->findBreakpointByResponseId(rid); showStatusMessage(msgBreakpointTriggered(id, rid.majorPart(), _(threadId))); m_currentThread = threadId; } else { QString reasontr = msgStopped(_(reason)); if (reason == "signal-received") { - QByteArray name = data.findChild("signal-name").data(); - QByteArray meaning = data.findChild("signal-meaning").data(); + QByteArray name = data["signal-name"].data(); + QByteArray meaning = data["signal-meaning"].data(); // Ignore these as they are showing up regularly when // stopping debugging. if (name == stopSignal(sp.toolChainAbi)) { @@ -1848,12 +1848,12 @@ void GdbEngine::handlePythonSetup(const GdbResponse &response) m_hasPython = true; GdbMi data; data.fromStringMultiple(response.consoleStreamOutput); - const GdbMi dumpers = data.findChild("dumpers"); + const GdbMi dumpers = data["dumpers"]; foreach (const GdbMi &dumper, dumpers.children()) { - QByteArray type = dumper.findChild("type").data(); + QByteArray type = dumper["type"].data(); QStringList formats(tr("Raw structure")); foreach (const QByteArray &format, - dumper.findChild("formats").data().split(',')) { + dumper["formats"].data().split(',')) { if (format == "Normal") formats.append(tr("Normal")); else if (format == "Displayed") @@ -1863,7 +1863,7 @@ void GdbEngine::handlePythonSetup(const GdbResponse &response) } watchHandler()->addTypeFormats(type, formats); } - const GdbMi hasInferiorThreadList = data.findChild("hasInferiorThreadList"); + const GdbMi hasInferiorThreadList = data["hasInferiorThreadList"]; m_hasInferiorThreadList = (hasInferiorThreadList.data().toInt() != 0); } } @@ -1900,7 +1900,7 @@ void GdbEngine::handleExecuteContinue(const GdbResponse &response) notifyInferiorRunOk(); // Only needed for gdb < 7.0. return; } - QByteArray msg = response.data.findChild("msg").data(); + QByteArray msg = response.data["msg"].data(); if (msg.startsWith("Cannot find bounds of current function")) { notifyInferiorRunFailed(); if (isDying()) @@ -2015,7 +2015,7 @@ void GdbEngine::handleInferiorShutdown(const GdbResponse &response) notifyInferiorShutdownOk(); return; } - QByteArray ba = response.data.findChild("msg").data(); + QByteArray ba = response.data["msg"].data(); if (ba.contains(": No such file or directory.")) { // This happens when someone removed the binary behind our back. // It is not really an error from a user's point of view. @@ -2066,7 +2066,7 @@ void GdbEngine::handleGdbExit(const GdbResponse &response) //notifyEngineShutdownOk(); } else { QString msg = msgGdbStopFailed( - QString::fromLocal8Bit(response.data.findChild("msg").data())); + QString::fromLocal8Bit(response.data["msg"].data())); qDebug() << (_("GDB WON'T EXIT (%1); KILLING IT").arg(msg)); showMessage(_("GDB WON'T EXIT (%1); KILLING IT").arg(msg)); gdbProc()->kill(); @@ -2089,15 +2089,18 @@ void GdbEngine::handleDetach(const GdbResponse &response) void GdbEngine::handleThreadGroupCreated(const GdbMi &result) { - QByteArray id = result.findChild("id").data(); - QByteArray pid = result.findChild("pid").data(); - Q_UNUSED(id); - Q_UNUSED(pid); + Q_UNUSED(result); +// QByteArray id = result["id"].data(); +// QByteArray pid = result["pid"].data(); +// Q_UNUSED(id); +// Q_UNUSED(pid); } void GdbEngine::handleThreadGroupExited(const GdbMi &result) { - QByteArray id = result.findChild("id").data(); + Q_UNUSED(result); +// QByteArray id = result["id"].data(); +// Q_UNUSED(id); } int GdbEngine::currentFrame() const @@ -2199,7 +2202,7 @@ void GdbEngine::handleExecuteStep(const GdbResponse &response) notifyInferiorRunOk(); // Only needed for gdb < 7.0. return; } - QByteArray msg = response.data.findChild("msg").data(); + QByteArray msg = response.data["msg"].data(); if (msg.startsWith("Cannot find bounds of current function") || msg.contains("Error accessing memory address") || msg.startsWith("Cannot access memory at address")) { @@ -2276,7 +2279,7 @@ void GdbEngine::handleExecuteNext(const GdbResponse &response) return; } QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); - QByteArray msg = response.data.findChild("msg").data(); + QByteArray msg = response.data["msg"].data(); if (msg.startsWith("Cannot find bounds of current function") || msg.contains("Error accessing memory address ")) { if (!m_commandsToRunOnTemporaryBreak.isEmpty()) @@ -2498,7 +2501,7 @@ void GdbEngine::updateResponse(BreakpointResponse &response, const GdbMi &bkpt) if (child.data().contains("tracepoint")) { response.tracepoint = true; } else if (child.data() == "hw watchpoint" || child.data() == "watchpoint") { - QByteArray what = bkpt.findChild("what").data(); + QByteArray what = bkpt["what"].data(); if (what.startsWith("*0x")) { response.type = WatchpointAtAddress; response.address = what.mid(1).toULongLong(0, 0); @@ -2623,12 +2626,12 @@ void GdbEngine::handleWatchInsert(const GdbResponse &response) BreakpointResponse br = handler->response(id); // "Hardware watchpoint 2: *0xbfffed40\n" QByteArray ba = response.consoleStreamOutput; - GdbMi wpt = response.data.findChild("wpt"); + GdbMi wpt = response.data["wpt"]; if (wpt.isValid()) { // Mac yields: //>32^done,wpt={number="4",exp="*4355182176"} - br.id = BreakpointResponseId(wpt.findChild("number").data()); - QByteArray exp = wpt.findChild("exp").data(); + br.id = BreakpointResponseId(wpt["number"].data()); + QByteArray exp = wpt["exp"].data(); if (exp.startsWith('*')) br.address = exp.mid(1).toULongLong(0, 0); handler->setResponse(id, br); @@ -2683,7 +2686,7 @@ void GdbEngine::handleBkpt(const GdbMi &bkpt, const BreakpointModelId &id) { BreakHandler *handler = breakHandler(); BreakpointResponse br = handler->response(id); - const QByteArray nr = bkpt.findChild("number").data(); + const QByteArray nr = bkpt["number"].data(); const BreakpointResponseId rid(nr); QTC_ASSERT(rid.isValid(), return); if (nr.contains('.')) { @@ -2698,11 +2701,11 @@ void GdbEngine::handleBkpt(const GdbMi &bkpt, const BreakpointModelId &id) // The MI output format might change, see // http://permalink.gmane.org/gmane.comp.gdb.patches/83936 - const GdbMi locations = bkpt.findChild("locations"); + const GdbMi locations = bkpt["locations"]; if (locations.isValid()) { foreach (const GdbMi &loc, locations.children()) { // A sub-breakpoint. - const QByteArray subnr = loc.findChild("number").data(); + const QByteArray subnr = loc["number"].data(); const BreakpointResponseId subrid(subnr); BreakpointResponse sub; updateResponse(sub, loc); @@ -2725,9 +2728,9 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response) if (handler->state(id) == BreakpointRemoveRequested) { if (response.resultClass == GdbResultDone) { // This delete was defered. Act now. - const GdbMi mainbkpt = response.data.findChild("bkpt"); + const GdbMi mainbkpt = response.data["bkpt"]; handler->notifyBreakpointRemoveProceeding(id); - QByteArray nr = mainbkpt.findChild("number").data(); + QByteArray nr = mainbkpt["number"].data(); postCommand("-break-delete " + nr, NeedsStop | RebuildBreakpointModel); handler->notifyBreakpointRemoveOk(id); @@ -2740,8 +2743,8 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response) // the "main" entry. Use the "main" entry to retrieve the // already known data from the BreakpointManager, and then // iterate over all items to update main- and sub-data. - const GdbMi mainbkpt = response.data.findChild("bkpt"); - const QByteArray mainnr = mainbkpt.findChild("number").data(); + const GdbMi mainbkpt = response.data["bkpt"]; + const QByteArray mainnr = mainbkpt["number"].data(); const BreakpointResponseId mainrid(mainnr); if (!isHiddenBreakpoint(mainrid)) { foreach (const GdbMi &bkpt, response.data.children()) @@ -2760,7 +2763,7 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response) NeedsStop, CB(handleBreakListMultiple), QVariant::fromValue(id)); } - } else if (response.data.findChild("msg").data().contains("Unknown option")) { + } else if (response.data["msg"].data().contains("Unknown option")) { // Older version of gdb don't know the -a option to set tracepoints // ^error,msg="mi_cmd_break_insert: Unknown option ``a''" const QString fileName = handler->fileName(id); @@ -2824,7 +2827,7 @@ void GdbEngine::handleBreakList(const GdbResponse &response) // addr="",pending="plugin.cpp:7",times="0"}] ... } if (response.resultClass == GdbResultDone) { - GdbMi table = response.data.findChild("BreakpointTable"); + GdbMi table = response.data["BreakpointTable"]; if (table.isValid()) handleBreakList(table); } @@ -2832,7 +2835,7 @@ void GdbEngine::handleBreakList(const GdbResponse &response) void GdbEngine::handleBreakList(const GdbMi &table) { - const GdbMi body = table.findChild("body"); + const GdbMi body = table["body"]; QList bkpts; if (body.isValid()) { // Non-Mac @@ -2842,7 +2845,7 @@ void GdbEngine::handleBreakList(const GdbMi &table) bkpts = table.children(); // Remove the 'hdr' and artificial items. for (int i = bkpts.size(); --i >= 0; ) { - int num = bkpts.at(i).findChild("number").data().toInt(); + int num = bkpts.at(i)["number"].data().toInt(); if (num <= 0) bkpts.removeAt(i); } @@ -2851,7 +2854,7 @@ void GdbEngine::handleBreakList(const GdbMi &table) BreakHandler *handler = breakHandler(); foreach (const GdbMi &bkpt, bkpts) { BreakpointResponse needle; - needle.id = BreakpointResponseId(bkpt.findChild("number").data()); + needle.id = BreakpointResponseId(bkpt["number"].data()); if (isQmlStepBreakpoint2(needle.id)) continue; if (isQFatalBreakpoint(needle.id)) @@ -3555,12 +3558,12 @@ void GdbEngine::handleModulesList(const GdbResponse &response) // shlib-info={...}... foreach (const GdbMi &item, response.data.children()) { module.modulePath = - QString::fromLocal8Bit(item.findChild("path").data()); + QString::fromLocal8Bit(item["path"].data()); module.moduleName = nameFromPath(module.modulePath); - module.symbolsRead = (item.findChild("state").data() == "Y") + module.symbolsRead = (item["state"].data() == "Y") ? Module::ReadOk : Module::ReadFailed; module.startAddress = - item.findChild("loaded_addr").data().toULongLong(0, 0); + item["loaded_addr"].data().toULongLong(0, 0); module.endAddress = 0; // FIXME: End address not easily available. handler->updateModule(module); } @@ -3653,15 +3656,15 @@ StackFrame GdbEngine::parseStackFrame(const GdbMi &frameMi, int level) //qDebug() << "HANDLING FRAME:" << frameMi.toString(); StackFrame frame; frame.level = level; - GdbMi fullName = frameMi.findChild("fullname"); + GdbMi fullName = frameMi["fullname"]; if (fullName.isValid()) frame.file = cleanupFullName(QFile::decodeName(fullName.data())); else - frame.file = QFile::decodeName(frameMi.findChild("file").data()); - frame.function = _(frameMi.findChild("func").data()); - frame.from = _(frameMi.findChild("from").data()); - frame.line = frameMi.findChild("line").data().toInt(); - frame.address = frameMi.findChild("addr").toAddress(); + frame.file = QFile::decodeName(frameMi["file"].data()); + frame.function = _(frameMi["func"].data()); + frame.from = _(frameMi["from"].data()); + frame.line = frameMi["line"].data().toInt(); + frame.address = frameMi["addr"].toAddress(); frame.usable = QFileInfo(frame.file).isReadable(); return frame; } @@ -3681,7 +3684,7 @@ void GdbEngine::handleStackListFrames(const GdbResponse &response) StackCookie cookie = response.cookie.value(); QList stackFrames; - GdbMi stack = response.data.findChild("stack"); + GdbMi stack = response.data["stack"]; if (!stack.isValid()) { qDebug() << "FIXME: stack:" << stack.toString(); return; @@ -3789,7 +3792,7 @@ void GdbEngine::handleThreadListIds(const GdbResponse &response) // "72^done,{thread-ids={thread-id="2",thread-id="1"},number-of-threads="2"} // In gdb 7.1+ additionally: current-thread-id="1" ThreadsHandler *handler = threadsHandler(); - const QList items = response.data.findChild("thread-ids").children(); + const QList items = response.data["thread-ids"].children(); for (int index = 0, n = items.size(); index != n; ++index) { ThreadData thread; thread.id = ThreadId(items.at(index).data().toInt()); @@ -3806,9 +3809,9 @@ void GdbEngine::handleThreadNames(const GdbResponse &response) names.fromString(response.consoleStreamOutput); foreach (const GdbMi &name, names.children()) { ThreadData thread; - thread.id = ThreadId(name.findChild("id").data().toInt()); - thread.name = decodeData(name.findChild("value").data(), - name.findChild("valueencoded").data().toInt()); + thread.id = ThreadId(name["id"].data().toInt()); + thread.name = decodeData(name["value"].data(), + name["valueencoded"].data().toInt()); handler->updateThread(thread); } updateViews(); @@ -3854,7 +3857,7 @@ void GdbEngine::handleMakeSnapshot(const GdbResponse &response) sp.isSnapshot = true; DebuggerRunControlFactory::createAndScheduleRun(sp); } else { - QByteArray msg = response.data.findChild("msg").data(); + QByteArray msg = response.data["msg"].data(); showMessageBox(QMessageBox::Critical, tr("Snapshot Creation Error"), tr("Cannot create snapshot:\n") + QString::fromLocal8Bit(msg)); } @@ -3903,7 +3906,7 @@ void GdbEngine::handleRegisterListNames(const GdbResponse &response) // This both handles explicitly having space for all the registers and // initializes all indices to 0, giving missing registers a sane default // in the event of something wacky. - GdbMi names = response.data.findChild("register-names"); + GdbMi names = response.data["register-names"]; m_registerNumbers.resize(names.childCount()); foreach (const GdbMi &item, names.children()) { // Since we throw away missing registers to eliminate empty rows @@ -3929,12 +3932,12 @@ void GdbEngine::handleRegisterListValues(const GdbResponse &response) const int gdbRegisterCount = m_registerNumbers.size(); // 24^done,register-values=[{number="0",value="0xf423f"},...] - const GdbMi values = response.data.findChild("register-values"); + const GdbMi values = response.data["register-values"]; QTC_ASSERT(registerCount == values.children().size(), return); foreach (const GdbMi &item, values.children()) { - const int number = item.findChild("number").data().toInt(); + const int number = item["number"].data().toInt(); if (number >= 0 && number < gdbRegisterCount) - registers[m_registerNumbers[number]].value = item.findChild("value").data(); + registers[m_registerNumbers[number]].value = item["value"].data(); } registerHandler()->setAndMarkRegisters(registers); } @@ -4199,16 +4202,16 @@ void GdbEngine::handleVarCreate(const GdbResponse &response) //qDebug() << "HANDLE VARIABLE CREATION:" << data.toString(); if (response.resultClass == GdbResultDone) { data.variable = data.iname; - data.updateType(response.data.findChild("type")); + data.updateType(response.data["type"]); if (watchHandler()->isExpandedIName(data.iname) - && !response.data.findChild("children").isValid()) + && !response.data["children"].isValid()) data.setChildrenNeeded(); else data.setChildrenUnneeded(); - data.updateChildCount(response.data.findChild("numchild")); + data.updateChildCount(response.data["numchild"]); insertData(data); } else { - data.setError(QString::fromLocal8Bit(response.data.findChild("msg").data())); + data.setError(QString::fromLocal8Bit(response.data["msg"].data())); if (data.isWatcher()) { data.value = WatchData::msgNotInScope(); data.type = " "; @@ -4225,7 +4228,7 @@ void GdbEngine::handleDebuggingHelperSetup(const GdbResponse &response) { if (response.resultClass == GdbResultDone) { } else { - QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data()); + QString msg = QString::fromLocal8Bit(response.data["msg"].data()); showStatusMessage(tr("Custom dumper setup: %1").arg(msg), 10000); } } @@ -4256,9 +4259,9 @@ WatchData GdbEngine::localVariable(const GdbMi &item, numExps += int(child.name() == "exp"); if (numExps > 1) return WatchData(); - name = item.findChild("exp").data(); + name = item["exp"].data(); } else { - name = item.findChild("name").data(); + name = item["name"].data(); } const QMap::iterator it = seen->find(name); if (it != seen->end()) { @@ -4285,7 +4288,7 @@ WatchData GdbEngine::localVariable(const GdbMi &item, data.iname = "local." + name; data.name = nam; data.exp = name; - data.updateType(item.findChild("type")); + data.updateType(item["type"]); if (uninitializedVariables.contains(data.name)) { data.setError(WatchData::msgNotInScope()); return data; @@ -4305,7 +4308,7 @@ WatchData GdbEngine::localVariable(const GdbMi &item, if (!watchHandler()->isExpandedIName(data.iname)) data.setChildrenUnneeded(); - GdbMi t = item.findChild("numchild"); + GdbMi t = item["numchild"]; if (t.isValid()) data.setHasChildren(t.data().toInt() > 0); else if (isPointerType(data.type) || data.name == QLatin1String("this")) @@ -4435,12 +4438,12 @@ void GdbEngine::handleFetchMemory(const GdbResponse &response) MemoryAgentCookie ac = response.cookie.value(); QTC_ASSERT(ac.agent, return); QByteArray ba; - GdbMi memory = response.data.findChild("memory"); + GdbMi memory = response.data["memory"]; QTC_ASSERT(memory.children().size() <= 1, return); if (memory.children().isEmpty()) return; GdbMi memory0 = memory.children().at(0); // we asked for only one 'row' - GdbMi data = memory0.findChild("data"); + GdbMi data = memory0["data"]; foreach (const GdbMi &child, data.children()) { bool ok = true; unsigned char c = '?'; @@ -4592,11 +4595,11 @@ void GdbEngine::fetchDisassemblerByCliRangePlain(const DisassemblerAgentCookie & static DisassemblerLine parseLine(const GdbMi &line) { DisassemblerLine dl; - QByteArray address = line.findChild("address").data(); + QByteArray address = line["address"].data(); dl.address = address.toULongLong(0, 0); - dl.data = _(line.findChild("inst").data()); - dl.function = _(line.findChild("func-name").data()); - dl.offset = line.findChild("offset").data().toUInt(); + dl.data = _(line["inst"].data()); + dl.function = _(line["func-name"].data()); + dl.offset = line["offset"].data().toUInt(); return dl; } @@ -4621,10 +4624,10 @@ DisassemblerLines GdbEngine::parseMiDisassembler(const GdbMi &lines) // FIXME: Performance? foreach (const GdbMi &child, lines.children()) { if (child.hasName("src_and_asm_line")) { - const QString fileName = QFile::decodeName(child.findChild("file").data()); - const uint line = child.findChild("line").data().toUInt(); + const QString fileName = QFile::decodeName(child["file"].data()); + const uint line = child["line"].data().toUInt(); result.appendSourceLine(fileName, line); - GdbMi insn = child.findChild("line_asm_insn"); + GdbMi insn = child["line_asm_insn"]; foreach (const GdbMi &item, insn.children()) result.appendLine(parseLine(item)); } else { @@ -4651,7 +4654,7 @@ DisassemblerLines GdbEngine::parseDisassembler(const GdbResponse &response) // FIXME: Check whether wrapping this into -interpreter-exec console // (i.e. usgind the 'ConsoleCommand' GdbCommandFlag makes a // difference. - GdbMi lines = response.data.findChild("asm_insns"); + GdbMi lines = response.data["asm_insns"]; if (lines.isValid()) return parseMiDisassembler(lines); return parseCliDisassembler(response.consoleStreamOutput); @@ -4736,7 +4739,7 @@ void GdbEngine::handleFetchDisassemblerByCliRangePlain(const GdbResponse &respon //76^error,msg="No function contains program counter for selected..." //76^error,msg="No function contains specified address." //>568^error,msg="Line number 0 out of range; - QByteArray msg = response.data.findChild("msg").data(); + QByteArray msg = response.data["msg"].data(); showStatusMessage(tr("Disassembler failed: %1") .arg(QString::fromLocal8Bit(msg)), 5000); } @@ -5207,8 +5210,8 @@ void GdbEngine::handleNamespaceExtraction(const GdbResponse &response) void GdbEngine::handleBreakOnQFatal(const GdbResponse &response) { if (response.resultClass == GdbResultDone) { - GdbMi bkpt = response.data.findChild("bkpt"); - GdbMi number = bkpt.findChild("number"); + GdbMi bkpt = response.data["bkpt"]; + GdbMi number = bkpt["number"]; BreakpointResponseId rid(number.data()); if (rid.isValid()) { m_qFatalBreakpointResponseId = rid; diff --git a/src/plugins/debugger/gdb/pythongdbengine.cpp b/src/plugins/debugger/gdb/pythongdbengine.cpp index 03285e1b8c..e1d62ab703 100644 --- a/src/plugins/debugger/gdb/pythongdbengine.cpp +++ b/src/plugins/debugger/gdb/pythongdbengine.cpp @@ -148,7 +148,7 @@ void GdbEngine::handleStackFramePython(const GdbResponse &response) } GdbMi all; all.fromStringMultiple(out); - GdbMi data = all.findChild("data"); + GdbMi data = all["data"]; WatchHandler *handler = watchHandler(); QList list; @@ -161,23 +161,23 @@ void GdbEngine::handleStackFramePython(const GdbResponse &response) foreach (const GdbMi &child, data.children()) { WatchData dummy; - dummy.iname = child.findChild("iname").data(); - GdbMi wname = child.findChild("wname"); + dummy.iname = child["iname"].data(); + GdbMi wname = child["wname"]; if (wname.isValid()) { // Happens (only) for watched expressions. They are encoded as // base64 encoded 8 bit data, without quotes dummy.name = decodeData(wname.data(), Base64Encoded8Bit); dummy.exp = dummy.name.toUtf8(); } else { - dummy.name = _(child.findChild("name").data()); + dummy.name = _(child["name"].data()); } parseWatchData(handler->expandedINames(), dummy, child, &list); } - const GdbMi typeInfo = all.findChild("typeinfo"); + const GdbMi typeInfo = all["typeinfo"]; if (typeInfo.type() == GdbMi::List) { foreach (const GdbMi &s, typeInfo.children()) { - const GdbMi name = s.findChild("name"); - const GdbMi size = s.findChild("size"); + const GdbMi name = s["name"]; + const GdbMi size = s["size"]; if (name.isValid() && size.isValid()) m_typeInfoCache.insert(QByteArray::fromBase64(name.data()), TypeInfo(size.data().toUInt())); diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp index cba6d0c672..9beadfe351 100644 --- a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp +++ b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp @@ -246,7 +246,7 @@ void GdbRemoteServerEngine::handleFileExecAndSymbols(const GdbResponse &response if (response.resultClass == GdbResultDone) { callTargetRemote(); } else { - QByteArray reason = response.data.findChild("msg").data(); + QByteArray reason = response.data["msg"].data(); QString msg = tr("Reading debug information failed:\n"); msg += QString::fromLocal8Bit(reason); if (reason.endsWith("No such file or directory.")) { @@ -300,7 +300,7 @@ void GdbRemoteServerEngine::handleTargetRemote(const GdbResponse &response) } else { // 16^error,msg="hd:5555: Connection timed out." QString msg = msgConnectRemoteServerFailed( - QString::fromLocal8Bit(response.data.findChild("msg").data())); + QString::fromLocal8Bit(response.data["msg"].data())); notifyInferiorSetupFailed(msg); } } @@ -320,7 +320,7 @@ void GdbRemoteServerEngine::handleTargetExtendedRemote(const GdbResponse &respon postCommand("attach " + QByteArray::number(m_targetPid), CB(handleTargetExtendedAttach)); } else { QString msg = msgConnectRemoteServerFailed( - QString::fromLocal8Bit(response.data.findChild("msg").data())); + QString::fromLocal8Bit(response.data["msg"].data())); notifyInferiorSetupFailed(msg); } } @@ -333,7 +333,7 @@ void GdbRemoteServerEngine::handleTargetExtendedAttach(const GdbResponse &respon handleInferiorPrepared(); } else { QString msg = msgConnectRemoteServerFailed( - QString::fromLocal8Bit(response.data.findChild("msg").data())); + QString::fromLocal8Bit(response.data["msg"].data())); notifyInferiorSetupFailed(msg); } } @@ -361,7 +361,7 @@ void GdbRemoteServerEngine::handleTargetQnx(const GdbResponse &response) } else { // 16^error,msg="hd:5555: Connection timed out." QString msg = msgConnectRemoteServerFailed( - QString::fromLocal8Bit(response.data.findChild("msg").data())); + QString::fromLocal8Bit(response.data["msg"].data())); notifyInferiorSetupFailed(msg); } } @@ -378,13 +378,13 @@ void GdbRemoteServerEngine::handleAttach(const GdbResponse &response) break; } case GdbResultError: - if (response.data.findChild("msg").data() == "ptrace: Operation not permitted.") { + if (response.data["msg"].data() == "ptrace: Operation not permitted.") { notifyInferiorSetupFailed(DumperHelper::msgPtraceError(startParameters().startMode)); break; } // if msg != "ptrace: ..." fall through default: - QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data()); + QString msg = QString::fromLocal8Bit(response.data["msg"].data()); notifyInferiorSetupFailed(msg); } } @@ -418,7 +418,7 @@ void GdbRemoteServerEngine::handleExecRun(const GdbResponse &response) showMessage(_("INFERIOR STARTED")); showMessage(msgInferiorSetupOk(), StatusBar); } else { - QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data()); + QString msg = QString::fromLocal8Bit(response.data["msg"].data()); showMessage(msg); notifyEngineRunFailed(); } diff --git a/src/plugins/debugger/gdb/termgdbadapter.cpp b/src/plugins/debugger/gdb/termgdbadapter.cpp index 4d2d508060..65e783238c 100644 --- a/src/plugins/debugger/gdb/termgdbadapter.cpp +++ b/src/plugins/debugger/gdb/termgdbadapter.cpp @@ -168,11 +168,11 @@ void GdbTermEngine::handleStubAttached(const GdbResponse &response) handleInferiorPrepared(); break; case GdbResultError: - if (response.data.findChild("msg").data() == "ptrace: Operation not permitted.") { + if (response.data["msg"].data() == "ptrace: Operation not permitted.") { notifyInferiorSetupFailed(DumperHelper::msgPtraceError(startParameters().startMode)); break; } - notifyInferiorSetupFailed(QString::fromLocal8Bit(response.data.findChild("msg").data())); + notifyInferiorSetupFailed(QString::fromLocal8Bit(response.data["msg"].data())); break; default: notifyInferiorSetupFailed(QString::fromLatin1("Invalid response %1").arg(response.resultClass)); diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 2790d206e0..e5273c6245 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -411,36 +411,36 @@ void LldbEngine::attemptBreakpointSynchronization() void LldbEngine::updateBreakpointData(const GdbMi &bkpt, bool added) { BreakHandler *handler = breakHandler(); - BreakpointModelId id = BreakpointModelId(bkpt.findChild("modelid").data()); + BreakpointModelId id = BreakpointModelId(bkpt["modelid"].data()); BreakpointResponse response = handler->response(id); - BreakpointResponseId rid = BreakpointResponseId(bkpt.findChild("lldbid").data()); + BreakpointResponseId rid = BreakpointResponseId(bkpt["lldbid"].data()); if (added) response.id = rid; QTC_CHECK(response.id == rid); response.address = 0; - response.enabled = bkpt.findChild("enabled").data().toInt(); - response.ignoreCount = bkpt.findChild("ignorecount").data().toInt(); - response.condition = bkpt.findChild("condition").data(); - response.hitCount = bkpt.findChild("hitcount").data().toInt(); + response.enabled = bkpt["enabled"].data().toInt(); + response.ignoreCount = bkpt["ignorecount"].data().toInt(); + response.condition = bkpt["condition"].data(); + response.hitCount = bkpt["hitcount"].data().toInt(); if (added) { // Added. - GdbMi locations = bkpt.findChild("locations"); + GdbMi locations = bkpt["locations"]; const int numChild = locations.children().size(); if (numChild > 1) { foreach (const GdbMi &location, locations.children()) { BreakpointResponse sub; sub.id = BreakpointResponseId(rid.majorPart(), - location.findChild("subid").data().toUShort()); + location["subid"].data().toUShort()); sub.type = response.type; - sub.address = location.findChild("addr").toAddress(); - sub.functionName = QString::fromUtf8(location.findChild("func").data()); + sub.address = location["addr"].toAddress(); + sub.functionName = QString::fromUtf8(location["func"].data()); handler->insertSubBreakpoint(id, sub); } } else if (numChild == 1) { const GdbMi location = locations.childAt(0); - response.address = location.findChild("addr").toAddress(); - response.functionName = QString::fromUtf8(location.findChild("func").data()); + response.address = location["addr"].toAddress(); + response.functionName = QString::fromUtf8(location["func"].data()); } else { QTC_CHECK(false); } @@ -459,11 +459,11 @@ void LldbEngine::refreshDisassembly(const GdbMi &lines) foreach (const GdbMi &line, lines.children()) { DisassemblerLine dl; - QByteArray address = line.findChild("address").data(); + QByteArray address = line["address"].data(); dl.address = address.toULongLong(0, 0); - dl.data = _(line.findChild("inst").data()); - dl.function = _(line.findChild("func-name").data()); - dl.offset = line.findChild("offset").data().toUInt(); + dl.data = _(line["inst"].data()); + dl.function = _(line["func-name"].data()); + dl.offset = line["offset"].data().toUInt(); result.appendLine(dl); } @@ -475,21 +475,21 @@ void LldbEngine::refreshDisassembly(const GdbMi &lines) void LldbEngine::refreshBreakpoints(const GdbMi &bkpts) { BreakHandler *handler = breakHandler(); - GdbMi added = bkpts.findChild("added"); - GdbMi changed = bkpts.findChild("changed"); - GdbMi removed = bkpts.findChild("removed"); + GdbMi added = bkpts["added"]; + GdbMi changed = bkpts["changed"]; + GdbMi removed = bkpts["removed"]; foreach (const GdbMi &bkpt, added.children()) { - BreakpointModelId id = BreakpointModelId(bkpt.findChild("modelid").data()); + BreakpointModelId id = BreakpointModelId(bkpt["modelid"].data()); QTC_CHECK(handler->state(id) == BreakpointInsertProceeding); updateBreakpointData(bkpt, true); } foreach (const GdbMi &bkpt, changed.children()) { - BreakpointModelId id = BreakpointModelId(bkpt.findChild("modelid").data()); + BreakpointModelId id = BreakpointModelId(bkpt["modelid"].data()); QTC_CHECK(handler->state(id) == BreakpointChangeProceeding); updateBreakpointData(bkpt, false); } foreach (const GdbMi &bkpt, removed.children()) { - BreakpointModelId id = BreakpointModelId(bkpt.findChild("modelid").data()); + BreakpointModelId id = BreakpointModelId(bkpt["modelid"].data()); QTC_CHECK(handler->state(id) == BreakpointRemoveProceeding); handler->notifyBreakpointRemoveOk(id); } @@ -514,8 +514,8 @@ void LldbEngine::refreshModules(const GdbMi &modules) Modules mods; foreach (const GdbMi &item, modules.children()) { Module module; - module.modulePath = QString::fromUtf8(item.findChild("file").data()); - module.moduleName = QString::fromUtf8(item.findChild("name").data()); + module.modulePath = QString::fromUtf8(item["file"].data()); + module.moduleName = QString::fromUtf8(item["name"].data()); module.symbolsRead = Module::UnknownReadState; module.startAddress = 0; // item.findChild("loaded_addr").data().toULongLong(0, 0); @@ -816,15 +816,15 @@ void LldbEngine::refreshLocals(const GdbMi &vars) foreach (const GdbMi &child, vars.children()) { WatchData dummy; - dummy.iname = child.findChild("iname").data(); - GdbMi wname = child.findChild("wname"); + dummy.iname = child["iname"].data(); + GdbMi wname = child["wname"]; if (wname.isValid()) { // Happens (only) for watched expressions. They are encoded as // base64 encoded 8 bit data, without quotes dummy.name = decodeData(wname.data(), Base64Encoded8Bit); dummy.exp = dummy.name.toUtf8(); } else { - dummy.name = _(child.findChild("name").data()); + dummy.name = _(child["name"].data()); } parseWatchData(handler->expandedINames(), dummy, child, &list); } @@ -837,18 +837,18 @@ void LldbEngine::refreshStack(const GdbMi &stack) // emit stackFrameCompleted(); StackHandler *handler = stackHandler(); StackFrames frames; - foreach (const GdbMi &item, stack.findChild("frames").children()) { + foreach (const GdbMi &item, stack["frames"].children()) { StackFrame frame; - frame.level = item.findChild("level").data().toInt(); - frame.file = QString::fromLatin1(item.findChild("file").data()); - frame.function = QString::fromLatin1(item.findChild("func").data()); - frame.from = QString::fromLatin1(item.findChild("func").data()); - frame.line = item.findChild("line").data().toInt(); - frame.address = item.findChild("addr").toAddress(); + frame.level = item["level"].data().toInt(); + frame.file = QString::fromLatin1(item["file"].data()); + frame.function = QString::fromLatin1(item["func"].data()); + frame.from = QString::fromLatin1(item["func"].data()); + frame.line = item["line"].data().toInt(); + frame.address = item["addr"].toAddress(); frame.usable = QFileInfo(frame.file).isReadable(); frames.append(frame); } - bool canExpand = stack.findChild("hasmore").data().toInt(); + bool canExpand = stack["hasmore"].data().toInt(); debuggerCore()->action(ExpandStack)->setEnabled(canExpand); handler->setFrames(frames); } @@ -859,8 +859,8 @@ void LldbEngine::refreshRegisters(const GdbMi ®isters) Registers regs; foreach (const GdbMi &item, registers.children()) { Register reg; - reg.name = item.findChild("name").data(); - reg.value = item.findChild("value").data(); + reg.name = item["name"].data(); + reg.value = item["value"].data(); //reg.type = item.findChild("type").data(); regs.append(reg); } @@ -925,8 +925,8 @@ void LldbEngine::refreshState(const GdbMi &reportedState) void LldbEngine::refreshLocation(const GdbMi &reportedLocation) { - QByteArray file = reportedLocation.findChild("file").data(); - int line = reportedLocation.findChild("line").data().toInt(); + QByteArray file = reportedLocation["file"].data(); + int line = reportedLocation["line"].data().toInt(); gotoLocation(Location(QString::fromUtf8(file), line)); } diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index 0074031490..8ff71c8d9e 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -404,8 +404,8 @@ void PdbEngine::handleListModules(const PdbResponse &response) Modules modules; foreach (const GdbMi &item, out.children()) { Module module; - module.moduleName = _(item.findChild("name").data()); - QString path = _(item.findChild("value").data()); + module.moduleName = _(item["name"].data()); + QString path = _(item["value"].data()); int pos = path.indexOf(_("' from '")); if (pos != -1) { path = path.mid(pos + 8); @@ -435,7 +435,7 @@ void PdbEngine::handleListSymbols(const PdbResponse &response) QString moduleName = response.cookie.toString(); foreach (const GdbMi &item, out.children()) { Symbol symbol; - symbol.name = _(item.findChild("name").data()); + symbol.name = _(item["name"].data()); symbols.append(symbol); } debuggerCore()->showModuleSymbols(moduleName, symbols); @@ -819,8 +819,8 @@ void PdbEngine::handleListLocals(const PdbResponse &response) WatchHandler *handler = watchHandler(); foreach (const GdbMi &child, all.children()) { WatchData dummy; - dummy.iname = child.findChild("iname").data(); - dummy.name = _(child.findChild("name").data()); + dummy.iname = child["iname"].data(); + dummy.name = _(child["name"].data()); //qDebug() << "CHILD: " << child.toString(); parseWatchData(handler->expandedINames(), dummy, child, &list); } diff --git a/src/plugins/debugger/threadshandler.cpp b/src/plugins/debugger/threadshandler.cpp index ef27294154..a4a00aebfa 100644 --- a/src/plugins/debugger/threadshandler.cpp +++ b/src/plugins/debugger/threadshandler.cpp @@ -424,30 +424,30 @@ void ThreadsHandler::updateThreads(const GdbMi &data) } ThreadId currentId; - const GdbMi current = data.findChild("current-thread-id"); + const GdbMi current = data["current-thread-id"]; if (current.isValid()) currentId = ThreadId(current.data().toLongLong()); - const QList items = data.findChild("threads").children(); + const QList items = data["threads"].children(); const int n = items.size(); for (int index = 0; index != n; ++index) { bool ok = false; const GdbMi item = items.at(index); - const GdbMi frame = item.findChild("frame"); + const GdbMi frame = item["frame"]; ThreadData thread; - thread.id = ThreadId(item.findChild("id").data().toInt()); - thread.targetId = QString::fromLatin1(item.findChild("target-id").data()); - thread.details = QString::fromLatin1(item.findChild("details").data()); - thread.core = QString::fromLatin1(item.findChild("core").data()); - thread.state = QString::fromLatin1(item.findChild("state").data()); - thread.address = frame.findChild("addr").data().toULongLong(&ok, 0); - thread.function = QString::fromLatin1(frame.findChild("func").data()); - thread.fileName = QString::fromLatin1(frame.findChild("fullname").data()); - thread.lineNumber = frame.findChild("line").data().toInt(); - thread.module = QString::fromLocal8Bit(frame.findChild("from").data()); + thread.id = ThreadId(item["id"].data().toInt()); + thread.targetId = QString::fromLatin1(item["target-id"].data()); + thread.details = QString::fromLatin1(item["details"].data()); + thread.core = QString::fromLatin1(item["core"].data()); + thread.state = QString::fromLatin1(item["state"].data()); + thread.address = frame["addr"].data().toULongLong(&ok, 0); + thread.function = QString::fromLatin1(frame["func"].data()); + thread.fileName = QString::fromLatin1(frame["fullname"].data()); + thread.lineNumber = frame["line"].data().toInt(); + thread.module = QString::fromLocal8Bit(frame["from"].data()); thread.stopped = true; // Non-GDB (Cdb2) output name here. - thread.name = QString::fromLatin1(frame.findChild("name").data()); + thread.name = QString::fromLatin1(frame["name"].data()); if (thread.state == QLatin1String("running")) thread.stopped = false; if (thread.id == currentId) diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index d1f755c062..d5c3c92734 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -415,9 +415,9 @@ QByteArray WatchData::hexAddress() const void WatchData::updateValue(const GdbMi &item) { - GdbMi value = item.findChild("value"); + GdbMi value = item["value"]; if (value.isValid()) { - int encoding = item.findChild("valueencoded").data().toInt(); + int encoding = item["valueencoded"].data().toInt(); setValue(decodeData(value.data(), encoding)); } else { setValueNeeded(); @@ -578,63 +578,63 @@ void parseWatchData(const QSet &expandedINames, if (!isExpanded) data.setChildrenUnneeded(); - GdbMi children = item.findChild("children"); + GdbMi children = item["children"]; if (children.isValid() || !isExpanded) data.setChildrenUnneeded(); - data.updateType(item.findChild("type")); - GdbMi mi = item.findChild("editvalue"); + data.updateType(item["type"]); + GdbMi mi = item["editvalue"]; if (mi.isValid()) data.editvalue = mi.data(); - mi = item.findChild("editformat"); + mi = item["editformat"]; if (mi.isValid()) data.editformat = mi.data().toInt(); - mi = item.findChild("typeformats"); + mi = item["typeformats"]; if (mi.isValid()) data.typeFormats = QString::fromUtf8(mi.data()); - mi = item.findChild("bitpos"); + mi = item["bitpos"]; if (mi.isValid()) data.bitpos = mi.data().toInt(); - mi = item.findChild("bitsize"); + mi = item["bitsize"]; if (mi.isValid()) data.bitsize = mi.data().toInt(); - mi = item.findChild("origaddr"); + mi = item["origaddr"]; if (mi.isValid()) data.origaddr = mi.toAddress(); - data.updateAddress(item.findChild("addr")); + data.updateAddress(item["addr"]); data.updateValue(item); - setWatchDataSize(data, item.findChild("size")); + setWatchDataSize(data, item["size"]); - mi = item.findChild("exp"); + mi = item["exp"]; if (mi.isValid()) data.exp = mi.data(); - setWatchDataValueEnabled(data, item.findChild("valueenabled")); - setWatchDataValueEditable(data, item.findChild("valueeditable")); - data.updateChildCount(item.findChild("numchild")); + setWatchDataValueEnabled(data, item["valueenabled"]); + setWatchDataValueEditable(data, item["valueeditable"]); + data.updateChildCount(item["numchild"]); //qDebug() << "\nAPPEND TO LIST: " << data.toString() << "\n"; list->append(data); bool ok = false; - qulonglong addressBase = item.findChild("addrbase").data().toULongLong(&ok, 0); - qulonglong addressStep = item.findChild("addrstep").data().toULongLong(&ok, 0); + qulonglong addressBase = item["addrbase"].data().toULongLong(&ok, 0); + qulonglong addressStep = item["addrstep"].data().toULongLong(&ok, 0); // Try not to repeat data too often. WatchData childtemplate; - childtemplate.updateType(item.findChild("childtype")); - childtemplate.updateChildCount(item.findChild("childnumchild")); + childtemplate.updateType(item["childtype"]); + childtemplate.updateChildCount(item["childnumchild"]); //qDebug() << "CHILD TEMPLATE:" << childtemplate.toString(); - mi = item.findChild("arraydata"); + mi = item["arraydata"]; if (mi.isValid()) { - int encoding = item.findChild("arrayencoding").data().toInt(); + int encoding = item["arrayencoding"].data().toInt(); childtemplate.iname = data.iname + '.'; childtemplate.address = addressBase; decodeArray(list, childtemplate, mi.data(), encoding); @@ -643,12 +643,12 @@ void parseWatchData(const QSet &expandedINames, const GdbMi &child = children.children().at(i); WatchData data1 = childtemplate; data1.sortId = i; - GdbMi name = child.findChild("name"); + GdbMi name = child["name"]; if (name.isValid()) data1.name = QString::fromLatin1(name.data()); else data1.name = QString::number(i); - GdbMi iname = child.findChild("iname"); + GdbMi iname = child["iname"]; if (iname.isValid()) { data1.iname = iname.data(); } else { @@ -662,9 +662,9 @@ void parseWatchData(const QSet &expandedINames, setWatchDataAddress(data1, addressBase); addressBase += addressStep; } - QByteArray key = child.findChild("key").data(); + QByteArray key = child["key"].data(); if (!key.isEmpty()) { - int encoding = child.findChild("keyencoded").data().toInt(); + int encoding = child["keyencoded"].data().toInt(); QString skey = decodeData(key, encoding); if (skey.size() > 13) { skey = skey.left(12); diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index 5c5eb9d9b3..9ffaaa8be0 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -724,10 +724,10 @@ void tst_Dumpers::dumper() QList list; foreach (const GdbMi &child, actual.children()) { WatchData dummy; - dummy.iname = child.findChild("iname").data(); - dummy.name = QLatin1String(child.findChild("name").data()); + dummy.iname = child["iname").data(); + dummy.name = QLatin1String(child["name").data()); if (dummy.iname == "local.qtversion") - context.qtVersion = child.findChild("value").data().toInt(); + context.qtVersion = child["value").data().toInt(); else parseWatchData(expandedINames, dummy, child, &list); } -- GitLab