From b4c1552ec2f223d9c2096c6e498d68675d98b7fd Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Wed, 7 Jan 2009 15:03:49 +0100 Subject: [PATCH] handle Qt 4.4 and Qt 4.5's QMap in dumpers --- bin/gdbmacros/gdbmacros.cpp | 20 +++++++++++++---- src/plugins/debugger/gdbengine.cpp | 35 +++++++++++++++++++++++++----- src/plugins/debugger/gdbengine.h | 1 + 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/bin/gdbmacros/gdbmacros.cpp b/bin/gdbmacros/gdbmacros.cpp index 04a04abf8f7..1ba8333d6ea 100644 --- a/bin/gdbmacros/gdbmacros.cpp +++ b/bin/gdbmacros/gdbmacros.cpp @@ -1367,14 +1367,22 @@ static void qDumpQMap(QDumper &d) P(d, "addr", addOffset(node, valueOffset)); } else { P(d, "name", "[" << i << "]"); - P(d, "type", NS"QMapNode<" << keyType << "," << valueType << " >"); +#if QT_VERSION >= 0x040500 // actually, any type (even 'char') will do... - P(d, "exp", "*('"NS"QMapNode<" << keyType << "," << valueType << " >'*)" << node); + P(d, "type", NS"QMapNode<" + << keyType << "," << valueType << " >"); + P(d, "exp", "*('"NS"QMapNode<" + << keyType << "," << valueType << " >'*)" << node); + //P(d, "exp", "*('"NS"QMapData'*)" << (void*)node); //P(d, "exp", "*(char*)" << (void*)node); - // P(d, "addr", node); does not work as gdb fails to parse - // e.g. &((*('"NS"QMapNode<QString,Foo>'*)0x616658)) +#else + P(d, "type", NS"QMapData::Node<" + << keyType << "," << valueType << " >"); + P(d, "exp", "*('"NS"QMapData::Node<" + << keyType << "," << valueType << " >'*)" << node); +#endif } d.endHash(); @@ -2483,6 +2491,10 @@ void qDumpObjectData440( "\"std::vector\"," "\"std::wstring\"," "]"; + d << ",qtversion=[" + "\"" << ((QT_VERSION >> 16) & 255) << "\"," + "\"" << ((QT_VERSION >> 8) & 255) << "\"," + "\"" << ((QT_VERSION) & 255) << "\"]"; d << ",namespace=\""NS"\""; d.disarm(); } diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 7c7d3b6d328..64a70548bb2 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -2944,8 +2944,8 @@ void GdbEngine::runCustomDumper(const WatchData & data0, bool dumpChildren) QString outertype = isTemplate ? tmplate : data.type; // adjust the data extract - if (outertype == "QWidget") - outertype = "QObject"; + if (outertype == m_namespace + "QWidget") + outertype = m_namespace + "QObject"; QString extraArgs[4]; extraArgs[0] = "0"; @@ -2978,9 +2978,15 @@ void GdbEngine::runCustomDumper(const WatchData & data0, bool dumpChildren) slotNumber = data.iname.mid(lastOpened + 1, lastClosed - lastOpened - 1); extraArgs[0] = slotNumber; } else if (outertype == m_namespace + "QMap") { - QString nodetype = m_namespace + "QMapNode"; - nodetype += data.type.mid(m_namespace.size() + 4); - //qDebug() << "OUTERTYPE: " << outertype << " NODETYPE: " << nodetype; + QString nodetype; + if (m_qtVersion >= (4 << 16) + (5 << 8) + 0) { + nodetype = m_namespace + "QMapNode"; + nodetype += data.type.mid(m_namespace.size() + 4); + } else { + nodetype = data.type + "::Node"; + } + //qDebug() << "OUTERTYPE: " << outertype << " NODETYPE: " << nodetype + // << "QT VERSION" << m_qtVersion << ((4 << 16) + (5 << 8) + 0); extraArgs[2] = sizeofTypeExpression(nodetype); extraArgs[3] = "(size_t)&(('" + nodetype + "'*)0)->value"; } else if (outertype == m_namespace + "QMapNode") { @@ -3311,6 +3317,16 @@ void GdbEngine::handleQueryDataDumper2(const GdbResultRecord &record) GdbMi contents(output.data()); GdbMi simple = contents.findChild("dumpers"); m_namespace = contents.findChild("namespace").data(); + GdbMi qtversion = contents.findChild("qtversion"); + if (qtversion.children().size() == 3) { + m_qtVersion = (qtversion.childAt(0).data().toInt() << 16) + + (qtversion.childAt(1).data().toInt() << 8) + + qtversion.childAt(2).data().toInt(); + //qDebug() << "FOUND QT VERSION: " << qtversion.toString() << m_qtVersion; + } else { + m_qtVersion = 0; + } + //qDebug() << "OUTPUT: " << output.toString(); //qDebug() << "CONTENTS: " << contents.toString(); //qDebug() << "SIMPLE DUMPERS: " << simple.toString(); @@ -3951,6 +3967,9 @@ void GdbEngine::tryLoadCustomDumpers() sendCommand("sharedlibrary " + dotEscape(lib)); if (qq->useFastStart()) sendCommand("set stop-on-solib-events 1"); + } else { + qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " + << lib << QFileInfo(lib).isExecutable(); } #endif #if defined(Q_OS_MAC) @@ -3964,6 +3983,9 @@ void GdbEngine::tryLoadCustomDumpers() sendCommand("sharedlibrary " + dotEscape(lib)); if (qq->useFastStart()) sendCommand("set stop-on-solib-events 1"); + } else { + qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " + << lib << QFileInfo(lib).isExecutable(); } #endif #if defined(Q_OS_WIN) @@ -3977,6 +3999,9 @@ void GdbEngine::tryLoadCustomDumpers() sendCommand("sharedlibrary " + dotEscape(lib)); if (qq->useFastStart()) sendCommand("set stop-on-solib-events 1"); + } else { + qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " + << lib << QFileInfo(lib).isExecutable(); } #endif diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index c1344f86dda..000c0b84a95 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -333,6 +333,7 @@ private: QStringList m_availableSimpleDumpers; QString m_namespace; // namespace used in "namespaced Qt"; + int m_qtVersion; // Qt version used in the debugged program DataDumperState m_dataDumperState; // state of qt creator dumpers QList<GdbMi> m_currentFunctionArgs; -- GitLab