OSDN Git Service

Asynchronous breakpoint handling
authorArvid Ephraim Picciani <arvid.picciani@nokia.com>
Mon, 8 Nov 2010 17:55:32 +0000 (18:55 +0100)
committerArvid Ephraim Picciani <arvid.picciani@nokia.com>
Tue, 9 Nov 2010 11:36:37 +0000 (12:36 +0100)
src/plugins/debugger/breakpoint.cpp
src/plugins/debugger/breakpoint.h
src/plugins/debugger/breakwindow.cpp
src/plugins/debugger/debuggerengine.cpp
src/plugins/debugger/debuggerengine.h

index ece3945..269e37d 100644 (file)
@@ -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();
index ff117bb..e155457 100644 (file)
@@ -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?
index 1f5a3dd..14aa658 100644 (file)
@@ -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();
 }
index 927a2c5..425d56f 100644 (file)
@@ -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)
 {
 }
index 43d3c0d..3c91236 100644 (file)
@@ -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