From 5f75e5979e6373b69ecf8b17854c35caa09d1d6e Mon Sep 17 00:00:00 2001 From: Arvid Ephraim Picciani <arvid.picciani@nokia.com> Date: Mon, 8 Nov 2010 18:55:32 +0100 Subject: [PATCH] Asynchronous breakpoint handling --- src/plugins/debugger/breakpoint.cpp | 3 +- src/plugins/debugger/breakpoint.h | 2 + src/plugins/debugger/breakwindow.cpp | 1 + src/plugins/debugger/debuggerengine.cpp | 101 ++++++++++++++++++++++++ src/plugins/debugger/debuggerengine.h | 13 +++ 5 files changed, 119 insertions(+), 1 deletion(-) diff --git a/src/plugins/debugger/breakpoint.cpp b/src/plugins/debugger/breakpoint.cpp index ece39457dd5..269e37d7c0a 100644 --- a/src/plugins/debugger/breakpoint.cpp +++ b/src/plugins/debugger/breakpoint.cpp @@ -60,7 +60,7 @@ static quint64 nextBPId() { } BreakpointData::BreakpointData() : - id(nextBPId()), enabled(true), + id(nextBPId()), uiDirty(false), enabled(true), pending(true), type(BreakpointByFileAndLine), ignoreCount(0), lineNumber(0), address(0), useFullPath(false), @@ -102,6 +102,7 @@ BreakpointData::~BreakpointData() void BreakpointData::clear() { + uiDirty = false; pending = true; bpNumber.clear(); bpCondition.clear(); diff --git a/src/plugins/debugger/breakpoint.h b/src/plugins/debugger/breakpoint.h index ff117bb103b..e155457ffd2 100644 --- a/src/plugins/debugger/breakpoint.h +++ b/src/plugins/debugger/breakpoint.h @@ -97,6 +97,8 @@ private: public: quint64 id; + BreakpointState state; + bool uiDirty; // ui has changed stuff bool enabled; // Should we talk to the debugger engine? bool pending; // Does the debugger engine know about us already? diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp index 1f5a3ddfe09..14aa6588b89 100644 --- a/src/plugins/debugger/breakwindow.cpp +++ b/src/plugins/debugger/breakwindow.cpp @@ -519,6 +519,7 @@ void BreakWindow::editBreakpoints(const QModelIndexList &list) data->condition = newCondition.toLatin1(); data->ignoreCount = newIgnoreCount.toInt(); data->threadSpec = newThreadSpec.toLatin1(); + data->uiDirty = true; } synchronizeBreakpoints(); } diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 927a2c5baea..425d56fbbf0 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -1220,6 +1220,27 @@ void DebuggerEngine::updateAll() void DebuggerEngine::attemptBreakpointSynchronization() { + for (int i = 0; i < breakHandler()->size(); i++) { + BreakpointData *bp = breakHandler()->at(i); + if (!m_breakpoints.contains(bp->id)) { + m_breakpoints.insert(bp->id, bp); + } + QTC_ASSERT(m_breakpoints[bp->id] == bp, qDebug() << "corrupted breakpoint map"); + if (bp->uiDirty) { + bp->uiDirty = false; + bp->state = BreakpointChangeRequested; + changeBreakpoint(*bp); + } + } + + Breakpoints bps = breakHandler()->takeRemovedBreakpoints(); + foreach (BreakpointData *bp, bps) { + if (m_breakpoints.contains(bp->id)) { + bp->state = BreakpointRemovalRequested; + removeBreakpoint(bp->id); + } else + delete bp; + } } bool DebuggerEngine::acceptsBreakpoint(const BreakpointData *) @@ -1227,6 +1248,86 @@ bool DebuggerEngine::acceptsBreakpoint(const BreakpointData *) return true; } +void DebuggerEngine::addBreakpoint(const BreakpointData &) +{ +} + +void DebuggerEngine::notifyAddBreakpointOk(quint64 id) +{ + BreakpointData *bp = m_breakpoints[id]; + if (!bp) + return; + bp->state = BreakpointOk; +} + +void DebuggerEngine::notifyAddBreakpointFailed(quint64 id) +{ + BreakpointData *bp = m_breakpoints[id]; + if (!bp) + return; + bp->state = BreakpointDead; +} + +void DebuggerEngine::removeBreakpoint(quint64) +{ +} + +void DebuggerEngine::notifyRemoveBreakpointOk(quint64 id) +{ + BreakpointData *bp = m_breakpoints.take(id); + if (!bp) + return; + bp->state = BreakpointDead; + delete bp; +} + +void DebuggerEngine::notifyRemoveBreakpointFailed(quint64 id) +{ + BreakpointData *bp = m_breakpoints[id]; + if (!bp) + return; + bp->state = BreakpointOk; +} + +void DebuggerEngine::changeBreakpoint(const BreakpointData &) +{ +} + +void DebuggerEngine::notifyChangeBreakpointOk(quint64 id) +{ + BreakpointData *bp = m_breakpoints[id]; + if (!bp) + return; + bp->state = BreakpointOk; +} + +void DebuggerEngine::notifyChangeBreakpointFailed(quint64 id) +{ + BreakpointData *bp = m_breakpoints[id]; + if (!bp) + return; + bp->state = BreakpointDead; +} + +void DebuggerEngine::notifyBreakpointAdjusted(const BreakpointData & rbp) +{ + BreakpointData *bp = m_breakpoints[rbp.id]; + if (!bp) + return; + bp->bpNumber = rbp.bpNumber; + bp->bpCondition = rbp.bpCondition; + bp->bpIgnoreCount = rbp.bpIgnoreCount; + bp->bpFileName = rbp.bpFileName; + bp->bpFullName = rbp.bpFullName; + bp->bpLineNumber = rbp.bpLineNumber; + bp->bpCorrectedLineNumber = rbp.bpCorrectedLineNumber; + bp->bpThreadSpec = rbp.bpThreadSpec; + bp->bpFuncName = rbp.bpFuncName; + bp->bpAddress = rbp.bpAddress; + bp->bpMultiple = rbp.bpMultiple; + bp->bpEnabled = rbp.bpEnabled; +} + void DebuggerEngine::selectThread(int) { } diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 43d3c0da25d..3c91236638c 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -186,6 +186,18 @@ public: virtual void attemptBreakpointSynchronization(); virtual bool acceptsBreakpoint(const Internal::BreakpointData *); + + virtual void addBreakpoint(const Internal::BreakpointData &bp); + virtual void notifyAddBreakpointOk(quint64 id); + virtual void notifyAddBreakpointFailed(quint64 id); + virtual void removeBreakpoint(quint64 id); + virtual void notifyRemoveBreakpointOk(quint64 id); + virtual void notifyRemoveBreakpointFailed(quint64 id); + virtual void changeBreakpoint(const Internal::BreakpointData &bp); + virtual void notifyChangeBreakpointOk(quint64 id); + virtual void notifyChangeBreakpointFailed(quint64 id); + virtual void notifyBreakpointAdjusted(const Internal::BreakpointData &bp); + virtual void selectThread(int index); virtual void assignValueInDebugger(const Internal::WatchData *data, @@ -342,6 +354,7 @@ private: friend class DebuggerEnginePrivate; DebuggerEnginePrivate *d; + QHash<quint64, Internal::BreakpointData *> m_breakpoints; }; } // namespace Debugger -- GitLab