Fix delete function breakpoints issue.
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Wed, 10 Apr 2019 15:00:34 +0000 (18:00 +0300)
committerMikhail Kurinnoi <m.kurinnoi@samsung.com>
Thu, 11 Apr 2019 08:46:41 +0000 (11:46 +0300)
src/debug/netcoredbg/breakpoints.cpp

index e49dd93e0134251c45e61cd35ca68b1ffba0f399..b329498099676e5a2c40edaf9d2c6759135c36d6 100644 (file)
@@ -516,21 +516,18 @@ HRESULT Breakpoints::SetBreakpoints(
     auto &breakpointsInSource = m_breakpoints[filename];
 
     // Remove old breakpoints
-    std::unordered_set<int> unchangedLines;
+    std::unordered_set<int> funcBreakpointLines;
     for (const auto &sb : srcBreakpoints)
     {
-        int line = sb.line;
-        if (breakpointsInSource.find(line) != breakpointsInSource.end())
-            unchangedLines.insert(line);
+        funcBreakpointLines.insert(sb.line);
+    }
+    for (auto it = breakpointsInSource.begin(); it != breakpointsInSource.end();)
+    {
+        if (funcBreakpointLines.find(it->first) == funcBreakpointLines.end())
+            it = breakpointsInSource.erase(it);
+        else
+            ++it;
     }
-
-    std::unordered_set<int> removedLines;
-    for (auto &b : breakpointsInSource)
-        if (unchangedLines.find(b.first) == unchangedLines.end())
-            removedLines.insert(b.first);
-
-    for (int line : removedLines)
-        breakpointsInSource.erase(line);
 
     // Export breakpoints
 
@@ -643,11 +640,24 @@ HRESULT Breakpoints::SetFunctionBreakpoints(
 {
     std::lock_guard<std::mutex> lock(m_breakpointsMutex);
 
-    // Clean all previous function breakpoints
-    for  (auto &fb : funcBreakpoints)
+    // Remove old breakpoints
+    std::unordered_set<std::string> funcBreakpointFuncs;
+    for (const auto &fb : funcBreakpoints)
     {
-        if (m_funcBreakpoints.find(fb.func) == m_funcBreakpoints.end())
-            m_funcBreakpoints.erase(fb.func);
+        std::string fullFuncName("");
+        if (fb.module != "")
+        {
+            fullFuncName = fb.module + "!";
+        }
+        fullFuncName += fb.func + fb.params;
+        funcBreakpointFuncs.insert(fullFuncName);
+    }
+    for (auto it = m_funcBreakpoints.begin(); it != m_funcBreakpoints.end();)
+    {
+        if (funcBreakpointFuncs.find(it->first) == funcBreakpointFuncs.end())
+            it = m_funcBreakpoints.erase(it);
+        else
+            ++it;
     }
 
     if (funcBreakpoints.empty())