Debugger: Use new shared result reporting infrastructure

Unify the watchPoint() interfaces, move the combined
implementation to the DebuggerEngine base.

Change-Id: Ic93aa760e7258197aed5eb7bfea257a40012cccf
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2016-12-15 18:30:05 +01:00
parent 5c2a7b57e4
commit fc01d0ac46
6 changed files with 14 additions and 47 deletions

View File

@@ -1513,8 +1513,20 @@ void DebuggerEngine::selectWatchData(const QString &)
{ {
} }
void DebuggerEngine::watchPoint(const QPoint &) void DebuggerEngine::watchPoint(const QPoint &pnt)
{ {
DebuggerCommand cmd("watchPoint", NeedsFullStop);
cmd.arg("x", pnt.x());
cmd.arg("y", pnt.y());
cmd.callback = [this](const DebuggerResponse &response) {
qulonglong addr = response.data["selected"].toAddress();
if (addr == 0)
showStatusMessage(tr("Could not find a widget."));
// Add the watcher entry nevertheless, as that's the place where
// the user expects visual feedback.
watchHandler()->watchExpression(response.data["expr"].data(), QString(), true);
};
runCommand(cmd);
} }
void DebuggerEngine::runCommand(const DebuggerCommand &) void DebuggerEngine::runCommand(const DebuggerCommand &)

View File

@@ -220,7 +220,7 @@ public:
virtual void startDebugger(DebuggerRunControl *runControl); virtual void startDebugger(DebuggerRunControl *runControl);
virtual void prepareForRestart() {} virtual void prepareForRestart() {}
virtual void watchPoint(const QPoint &); virtual void watchPoint(const QPoint &pnt);
virtual void runCommand(const DebuggerCommand &cmd); virtual void runCommand(const DebuggerCommand &cmd);
virtual void openMemoryView(const MemoryViewSetupData &data); virtual void openMemoryView(const MemoryViewSetupData &data);
virtual void fetchMemory(MemoryAgent *, quint64 addr, quint64 length); virtual void fetchMemory(MemoryAgent *, quint64 addr, quint64 length);

View File

@@ -3615,29 +3615,6 @@ void GdbEngine::assignValueInDebugger(WatchItem *item,
runCommand(cmd); runCommand(cmd);
} }
void GdbEngine::watchPoint(const QPoint &pnt)
{
DebuggerCommand cmd("watchPoint", NeedsFullStop);
cmd.arg("x", pnt.x());
cmd.arg("y", pnt.y());
cmd.callback = CB(handleWatchPoint);
runCommand(cmd);
}
void GdbEngine::handleWatchPoint(const DebuggerResponse &response)
{
if (response.resultClass == ResultDone) {
GdbMi res;
res.fromString(response.consoleStreamOutput);
qulonglong addr = res["selected"].toAddress();
if (addr == 0)
showStatusMessage(tr("Could not find a widget."));
// Add the watcher entry nevertheless, as that's the place where
// the user expects visual feedback.
watchHandler()->watchExpression(res["expr"].data(), QString(), true);
}
}
class MemoryAgentCookie class MemoryAgentCookie
{ {
public: public:

View File

@@ -355,9 +355,6 @@ protected:
void changeMemory(MemoryAgent *agent, quint64 addr, const QByteArray &data) override; void changeMemory(MemoryAgent *agent, quint64 addr, const QByteArray &data) override;
void handleFetchMemory(const DebuggerResponse &response, MemoryAgentCookie ac); void handleFetchMemory(const DebuggerResponse &response, MemoryAgentCookie ac);
void watchPoint(const QPoint &) override;
void handleWatchPoint(const DebuggerResponse &response);
void showToolTip(); void showToolTip();
void handleVarAssign(const DebuggerResponse &response); void handleVarAssign(const DebuggerResponse &response);

View File

@@ -148,22 +148,6 @@ void LldbEngine::debugLastCommand()
runCommand(m_lastDebuggableCommand); runCommand(m_lastDebuggableCommand);
} }
void LldbEngine::watchPoint(const QPoint &pnt)
{
DebuggerCommand cmd("watchPoint", NeedsFullStop);
cmd.arg("x", pnt.x());
cmd.arg("y", pnt.y());
cmd.callback = [this](const DebuggerResponse &response) {
qulonglong addr = response.data["selected"].toAddress();
if (addr == 0)
showStatusMessage(tr("Could not find a widget."));
// Add the watcher entry nevertheless, as that's the place where
// the user expects visual feedback.
watchHandler()->watchExpression(response.data["expr"].data(), QString(), true);
};
runCommand(cmd);
}
void LldbEngine::shutdownInferior() void LldbEngine::shutdownInferior()
{ {
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state()); QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());

View File

@@ -144,9 +144,6 @@ private:
void runCommand(const DebuggerCommand &cmd) override; void runCommand(const DebuggerCommand &cmd) override;
void debugLastCommand() override; void debugLastCommand() override;
void watchPoint(const QPoint &) override;
void handleWatchPoint(const DebuggerResponse &response);
private: private:
DebuggerCommand m_lastDebuggableCommand; DebuggerCommand m_lastDebuggableCommand;