From 82f80d5403c8eb60e36ac1692df2f299e79a6e35 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Mon, 11 Oct 2010 12:59:49 +0200 Subject: [PATCH] Debugger[CDB]: Do not evaluate watch expressions at all. setError() on them instead (should there be any from a session mixup). Give the session engine watcher capabilities and ensure 'Remove watch item' is enabled for the session engine by checking the debugger state. Reviewed-by: hjk --- src/plugins/debugger/cdb/cdbengine.cpp | 2 +- src/plugins/debugger/sessionengine.cpp | 7 +++++++ src/plugins/debugger/sessionengine.h | 1 + src/plugins/debugger/watchhandler.cpp | 3 +++ src/plugins/debugger/watchwindow.cpp | 5 ++++- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 8d8475a5ad7..520bc5110fb 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -705,7 +705,7 @@ void CdbEngine::updateWatchData(const WatchData &incomplete, const WatchUpdateFl if (incomplete.iname.startsWith("watch.")) { WatchData watchData = incomplete; - evaluateWatcher(&watchData); + watchData.setError(tr("<not supported>")); watchHandler()->insertData(watchData); return; } diff --git a/src/plugins/debugger/sessionengine.cpp b/src/plugins/debugger/sessionengine.cpp index 9914ff33ed8..a822df35229 100644 --- a/src/plugins/debugger/sessionengine.cpp +++ b/src/plugins/debugger/sessionengine.cpp @@ -30,6 +30,7 @@ #include "sessionengine.h" #include "breakhandler.h" #include "watchhandler.h" +#include "debuggerconstants.h" #include <utils/qtcassert.h> @@ -64,6 +65,12 @@ void SessionEngine::saveSessionData() breakHandler()->saveSessionData(); } +unsigned SessionEngine::debuggerCapabilities() const +{ + return DebuggerEngine::debuggerCapabilities() + | AddWatcherCapability | WatchpointCapability; +} + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/sessionengine.h b/src/plugins/debugger/sessionengine.h index 9bdc833bc1d..c00d6f52c90 100644 --- a/src/plugins/debugger/sessionengine.h +++ b/src/plugins/debugger/sessionengine.h @@ -51,6 +51,7 @@ public: virtual void shutdownEngine() {} virtual void shutdownInferior() {} virtual void executeDebuggerCommand(const QString &command); + virtual unsigned debuggerCapabilities() const; virtual bool isSessionEngine() const { return true; } diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 1c5b6cdad97..00dd7c3a4b7 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -704,6 +704,9 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const case EngineActionsEnabledRole: return engine()->debuggerActionsEnabled(); + + case EngineStateRole: + return QVariant(int(engine()->state())); } const WatchItem *item = watchItem(idx); diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 878b0a11db4..253f41e912d 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -296,6 +296,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) const unsigned engineCapabilities = modelData(EngineCapabilitiesRole).toUInt(); const bool canHandleWatches = actionsEnabled && (engineCapabilities & AddWatcherCapability); + const DebuggerState state = static_cast<DebuggerState>(modelData(EngineStateRole).toInt()); QMenu menu; QAction *actInsertNewWatchItem = menu.addAction(tr("Insert New Watch Item")); @@ -352,10 +353,12 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) QAction *actWatchExpression = new QAction(actionName, &menu); actWatchExpression->setEnabled(canHandleWatches && !exp.isEmpty()); + // Can remove watch if engine can handle it or session engine. actionName = exp.isEmpty() ? tr("Remove Watch Expression") : tr("Remove Watch Expression \"%1\"").arg(exp); QAction *actRemoveWatchExpression = new QAction(actionName, &menu); - actRemoveWatchExpression->setEnabled(canHandleWatches && !exp.isEmpty()); + actRemoveWatchExpression->setEnabled((canHandleWatches || state == DebuggerNotReady) + && !exp.isEmpty()); if (m_type == LocalsType) menu.addAction(actWatchExpression); -- GitLab