From 6493b4853d5d023f9db2cb7edbd58ac14c27b701 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Fri, 25 Jun 2010 09:53:23 +0200 Subject: [PATCH] debugger: adjust loading/saving of watched expressions to recent changes --- share/qtcreator/gdbmacros/dumper.py | 1 + src/plugins/debugger/breakhandler.cpp | 2 ++ src/plugins/debugger/debuggerengine.cpp | 3 ++- src/plugins/debugger/debuggerengine.h | 1 + src/plugins/debugger/debuggerplugin.cpp | 2 ++ src/plugins/debugger/gdb/gdbengine.cpp | 6 ++++-- src/plugins/debugger/watchhandler.cpp | 28 +++++++++++++++++++++---- src/plugins/debugger/watchhandler.h | 4 +++- tests/manual/gdbdebugger/simple/app.cpp | 4 +--- 9 files changed, 40 insertions(+), 11 deletions(-) diff --git a/share/qtcreator/gdbmacros/dumper.py b/share/qtcreator/gdbmacros/dumper.py index 2be8128bd95..6ebbd61f483 100644 --- a/share/qtcreator/gdbmacros/dumper.py +++ b/share/qtcreator/gdbmacros/dumper.py @@ -795,6 +795,7 @@ class SetupCommand(gdb.Command): if key.startswith("qdump__"): name = key[7:] qqDumpers[name] = value + qqFormats[name] = qqFormats.get(name, ""); elif key.startswith("qform__"): name = key[7:] formats = "" diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 9c2ce4fc910..1758f0f1447 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -979,12 +979,14 @@ void BreakHandler::setAllPending() void BreakHandler::saveSessionData() { + QTC_ASSERT(m_engine->isSessionEngine(), return); saveBreakpoints(); updateMarkers(); } void BreakHandler::loadSessionData() { + QTC_ASSERT(m_engine->isSessionEngine(), return); loadBreakpoints(); updateMarkers(); } diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index aed2dd474b0..8e6afda8581 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -515,6 +515,7 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl) QTC_ASSERT(sessionTemplate != this, startFailed(); return); breakHandler()->initializeFromTemplate(sessionTemplate->breakHandler()); + watchHandler()->initializeFromTemplate(sessionTemplate->watchHandler()); d->m_runControl = runControl; @@ -699,7 +700,6 @@ void DebuggerEngine::addToWatchWindow() if (exp.isEmpty()) return; watchHandler()->watchExpression(exp); - plugin()->updateState(this); } // Called from RunControl. @@ -713,6 +713,7 @@ void DebuggerEngine::handleFinished() DebuggerEngine *sessionTemplate = plugin()->sessionTemplate(); QTC_ASSERT(sessionTemplate != this, /**/); breakHandler()->storeToTemplate(sessionTemplate->breakHandler()); + watchHandler()->storeToTemplate(sessionTemplate->watchHandler()); } const DebuggerStartParameters &DebuggerEngine::startParameters() const diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index ad717273636..8462d318ff4 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -181,6 +181,7 @@ public: virtual unsigned debuggerCapabilities() const { return 0; } virtual bool isSynchroneous() const { return false; } + virtual bool isSessionEngine() const { return false; } virtual QString qtNamespace() const { return QString(); } public slots: diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index fd47e637944..146e27e3918 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -719,6 +719,8 @@ class SessionEngine : public DebuggerEngine public: SessionEngine() : DebuggerEngine(DebuggerStartParameters()) {} + bool isSessionEngine() const { return true; } + void loadSessionData() { breakHandler()->loadSessionData(); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index b63d3632fb3..c8a0ad106d7 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1532,12 +1532,14 @@ void GdbEngine::handleHasPython(const GdbResponse &response) foreach (const GdbMi &dumper, dumpers.children()) { QString type = _(dumper.findChild("type").data()); QStringList formats(tr("Raw structure")); - formats.append(_(dumper.findChild("formats").data()).split(_(","))); + QString reported = _(dumper.findChild("formats").data()); + formats.append(reported.split(_(","), QString::SkipEmptyParts)); watchHandler()->addTypeFormats(type, formats); } } else { m_hasPython = false; - if (m_gdbAdapter->dumperHandling() == AbstractGdbAdapter::DumperLoadedByGdbPreload + if (m_gdbAdapter->dumperHandling() + == AbstractGdbAdapter::DumperLoadedByGdbPreload && checkDebuggingHelpersClassic()) { QByteArray cmd = "set environment "; cmd += Debugger::Constants::Internal::LD_PRELOAD_ENV_VAR; diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index ddf6f9e0238..4f4e174fdd0 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -667,6 +667,9 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const int pos = type.indexOf("::Q"); if (pos >= 0 && type.count(':') == 2) type = type.mid(pos + 2); + pos = type.indexOf('<'); + if (pos >= 0) + type = type.left(pos); return m_handler->m_reportedTypeFormats.value(type); } @@ -1083,7 +1086,6 @@ void WatchModel::formatRequests(QByteArray *out, const WatchItem *item) const WatchHandler::WatchHandler(DebuggerEngine *engine) { m_engine = engine; - m_expandPointers = true; m_inChange = false; m_return = new WatchModel(this, ReturnWatch); @@ -1235,11 +1237,10 @@ void WatchHandler::watchExpression(const QString &exp) if (exp.isEmpty() || exp == watcherEditPlaceHolder()) data.setAllUnneeded(); data.iname = watcherName(data.exp); - if (m_engine && m_engine->isSynchroneous()) + if (m_engine->isSynchroneous() && !m_engine->isSessionEngine()) m_engine->updateWatchData(data); else insertData(data); - m_engine->updateWatchData(data); updateWatchersWindow(); saveWatchers(); emitAllChanged(); @@ -1351,8 +1352,8 @@ void WatchHandler::removeWatchExpression(const QString &exp0) break; } } - updateWatchersWindow(); emitAllChanged(); + updateWatchersWindow(); } void WatchHandler::updateWatchersWindow() @@ -1434,14 +1435,17 @@ void WatchHandler::saveTypeFormats() void WatchHandler::saveSessionData() { + QTC_ASSERT(m_engine->isSessionEngine(), return); saveWatchers(); saveTypeFormats(); } void WatchHandler::loadSessionData() { + QTC_ASSERT(m_engine->isSessionEngine(), return); loadWatchers(); loadTypeFormats(); + foreach (const QByteArray &exp, m_watcherNames.keys()) { WatchData data; data.iname = watcherName(exp); @@ -1450,8 +1454,24 @@ void WatchHandler::loadSessionData() data.exp = exp; insertData(data); } + updateWatchersWindow(); } +void WatchHandler::initializeFromTemplate(WatchHandler *other) +{ + m_watcherNames = other->m_watcherNames; + m_typeFormats = other->m_typeFormats; + m_individualFormats = other->m_individualFormats; +} + +void WatchHandler::storeToTemplate(WatchHandler *other) +{ + other->m_watcherNames = m_watcherNames; + other->m_typeFormats = m_typeFormats; + other->m_individualFormats = m_individualFormats; +} + + WatchModel *WatchHandler::model(WatchType type) const { switch (type) { diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 0ba82d25d6e..145a67c8cc7 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -156,6 +156,9 @@ public: void loadSessionData(); void saveSessionData(); + void initializeFromTemplate(WatchHandler *other); + void storeToTemplate(WatchHandler *other); + bool isExpandedIName(const QByteArray &iname) const { return m_expandedINames.contains(iname); } QSet<QByteArray> expandedINames() const @@ -184,7 +187,6 @@ private: void setFormat(const QString &type, int format); void updateWatchersWindow(); - bool m_expandPointers; bool m_inChange; // QWidgets and QProcesses taking care of special displays. diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index a9cef8c0179..50c73cb9e35 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -1347,7 +1347,7 @@ QVariant testQVariant3() return QVariant("xxx"); } -QVector<int> testQVector() +void testQVector() { QVector<int> big(10000); @@ -1367,8 +1367,6 @@ QVector<int> testQVector() QVector<bool> vec; vec.append(true); vec.append(false); - - return big; } QVector<QList<int> > testQVectorOfQList() -- GitLab