From d7c573054c1b0a02bda760ceb0b79e60a196011a Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Date: Wed, 10 Jun 2009 10:30:48 +0200
Subject: [PATCH] re-apply enabled state to restored breakpoints

---
 src/plugins/debugger/breakhandler.h    |  1 +
 src/plugins/debugger/gdb/gdbengine.cpp | 17 +++++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h
index 0f2cef63b26..2ecc314d23d 100644
--- a/src/plugins/debugger/breakhandler.h
+++ b/src/plugins/debugger/breakhandler.h
@@ -89,6 +89,7 @@ public:
     QString bpFuncName;     // function name acknowledged by the debugger engine
     QString bpAddress;      // address acknowledged by the debugger engine
     bool    bpMultiple;     // happens in constructors/gdb
+    bool    bpEnabled;      // enable/disable command sent
 
     // taken from either user input or gdb responses
     QString markerFileName; // used to locate the marker
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index b84f891c1e9..aa4820bc219 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -1799,6 +1799,7 @@ void GdbEngine::breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt
         return;
     data->pending = false;
     data->bpMultiple = false;
+    data->bpEnabled = true;
     data->bpCondition.clear();
     QStringList files;
     foreach (const GdbMi &child, bkpt.children()) {
@@ -1830,6 +1831,8 @@ void GdbEngine::breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt
             // gdb 6.3 likes to "rewrite" conditions. Just accept that fact.
             if (data->bpCondition != data->condition && data->conditionsMatch())
                 data->condition = data->bpCondition;
+        } else if (child.hasName("enabled")) {
+            data->bpEnabled = (child.data() == "y");
         }
         else if (child.hasName("pending")) {
             data->pending = true;
@@ -2146,14 +2149,18 @@ void GdbEngine::attemptBreakpointSynchronization()
 
     foreach (BreakpointData *data, handler->takeDisabledBreakpoints()) {
         QString bpNumber = data->bpNumber;
-        if (!bpNumber.trimmed().isEmpty())
+        if (!bpNumber.trimmed().isEmpty()) {
             postCommand(_("-break-disable ") + bpNumber, NeedsStop);
+            data->bpEnabled = false;
+        }
     }
 
     foreach (BreakpointData *data, handler->takeEnabledBreakpoints()) {
         QString bpNumber = data->bpNumber;
-        if (!bpNumber.trimmed().isEmpty())
+        if (!bpNumber.trimmed().isEmpty()) {
             postCommand(_("-break-enable ") + bpNumber, NeedsStop);
+            data->bpEnabled = true;
+        }
     }
 
     foreach (BreakpointData *data, handler->takeRemovedBreakpoints()) {
@@ -2210,6 +2217,12 @@ void GdbEngine::attemptBreakpointSynchronization()
                 updateNeeded = true;
                 break;
             }
+            if (data->bpNumber.toInt() && !data->enabled && data->bpEnabled) {
+                postCommand(_("-break-disable ") + data->bpNumber, NeedsStop);
+                data->bpEnabled = false;
+                updateNeeded = true;
+                break;
+            }
         }
     }
 
-- 
GitLab