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
This commit is contained in:
Friedemann Kleint
2010-10-11 12:59:49 +02:00
parent 6d0f0c7cd3
commit 82f80d5403
5 changed files with 16 additions and 2 deletions

View File

@@ -705,7 +705,7 @@ void CdbEngine::updateWatchData(const WatchData &incomplete, const WatchUpdateFl
if (incomplete.iname.startsWith("watch.")) { if (incomplete.iname.startsWith("watch.")) {
WatchData watchData = incomplete; WatchData watchData = incomplete;
evaluateWatcher(&watchData); watchData.setError(tr("<not supported>"));
watchHandler()->insertData(watchData); watchHandler()->insertData(watchData);
return; return;
} }

View File

@@ -30,6 +30,7 @@
#include "sessionengine.h" #include "sessionengine.h"
#include "breakhandler.h" #include "breakhandler.h"
#include "watchhandler.h" #include "watchhandler.h"
#include "debuggerconstants.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -64,6 +65,12 @@ void SessionEngine::saveSessionData()
breakHandler()->saveSessionData(); breakHandler()->saveSessionData();
} }
unsigned SessionEngine::debuggerCapabilities() const
{
return DebuggerEngine::debuggerCapabilities()
| AddWatcherCapability | WatchpointCapability;
}
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger

View File

@@ -51,6 +51,7 @@ public:
virtual void shutdownEngine() {} virtual void shutdownEngine() {}
virtual void shutdownInferior() {} virtual void shutdownInferior() {}
virtual void executeDebuggerCommand(const QString &command); virtual void executeDebuggerCommand(const QString &command);
virtual unsigned debuggerCapabilities() const;
virtual bool isSessionEngine() const { return true; } virtual bool isSessionEngine() const { return true; }

View File

@@ -704,6 +704,9 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
case EngineActionsEnabledRole: case EngineActionsEnabledRole:
return engine()->debuggerActionsEnabled(); return engine()->debuggerActionsEnabled();
case EngineStateRole:
return QVariant(int(engine()->state()));
} }
const WatchItem *item = watchItem(idx); const WatchItem *item = watchItem(idx);

View File

@@ -296,6 +296,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
const unsigned engineCapabilities = modelData(EngineCapabilitiesRole).toUInt(); const unsigned engineCapabilities = modelData(EngineCapabilitiesRole).toUInt();
const bool canHandleWatches = const bool canHandleWatches =
actionsEnabled && (engineCapabilities & AddWatcherCapability); actionsEnabled && (engineCapabilities & AddWatcherCapability);
const DebuggerState state = static_cast<DebuggerState>(modelData(EngineStateRole).toInt());
QMenu menu; QMenu menu;
QAction *actInsertNewWatchItem = menu.addAction(tr("Insert New Watch Item")); QAction *actInsertNewWatchItem = menu.addAction(tr("Insert New Watch Item"));
@@ -352,10 +353,12 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
QAction *actWatchExpression = new QAction(actionName, &menu); QAction *actWatchExpression = new QAction(actionName, &menu);
actWatchExpression->setEnabled(canHandleWatches && !exp.isEmpty()); actWatchExpression->setEnabled(canHandleWatches && !exp.isEmpty());
// Can remove watch if engine can handle it or session engine.
actionName = exp.isEmpty() ? tr("Remove Watch Expression") actionName = exp.isEmpty() ? tr("Remove Watch Expression")
: tr("Remove Watch Expression \"%1\"").arg(exp); : tr("Remove Watch Expression \"%1\"").arg(exp);
QAction *actRemoveWatchExpression = new QAction(actionName, &menu); QAction *actRemoveWatchExpression = new QAction(actionName, &menu);
actRemoveWatchExpression->setEnabled(canHandleWatches && !exp.isEmpty()); actRemoveWatchExpression->setEnabled((canHandleWatches || state == DebuggerNotReady)
&& !exp.isEmpty());
if (m_type == LocalsType) if (m_type == LocalsType)
menu.addAction(actWatchExpression); menu.addAction(actWatchExpression);