[Lldb-commits] [PATCH] D45554: Make sure deleting all breakpoints clears their sites first

Eugene Zemtsov via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 12 20:00:11 PDT 2018


eugene updated this revision to Diff 142319.
eugene added a comment.

Got rid of the printf in the test


https://reviews.llvm.org/D45554

Files:
  packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c
  source/Breakpoint/BreakpointList.cpp


Index: source/Breakpoint/BreakpointList.cpp
===================================================================
--- source/Breakpoint/BreakpointList.cpp
+++ source/Breakpoint/BreakpointList.cpp
@@ -99,7 +99,7 @@
 
 void BreakpointList::RemoveAllowed(bool notify) {
   std::lock_guard<std::recursive_mutex> guard(m_mutex);
-  
+
   bp_collection::iterator pos, end = m_breakpoints.end();
   if (notify) {
     for (pos = m_breakpoints.begin(); pos != end; ++pos) {
@@ -116,10 +116,12 @@
   }
   pos = m_breakpoints.begin();
   while ( pos != end) {
-      if((*pos)->AllowDelete())
-        pos = m_breakpoints.erase(pos);
-      else
-        pos++;
+    auto bp = *pos;
+    if (bp->AllowDelete()) {
+      bp->ClearAllBreakpointSites();
+      pos = m_breakpoints.erase(pos);
+    } else
+      pos++;
   }
 }
 
Index: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c
===================================================================
--- packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c
+++ packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c
@@ -9,5 +9,9 @@
 
 int main (int argc, char const *argv[])
 {
+    // Add a body to the function, so we can set more than one
+    // breakpoint in it.
+    static volatile int var = 0;
+    var++;
     return 0; // Set break point at this line.
 }
Index: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -45,6 +45,25 @@
         self.addTearDownHook(
             lambda: self.runCmd("settings clear auto-confirm"))
 
+    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
+    def test_delete_all_breakpoints(self):
+        """Test that deleting all breakpoints works."""
+        self.build()
+        exe = self.getBuildArtifact("a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        lldbutil.run_break_set_by_symbol(self, "main")
+        lldbutil.run_break_set_by_file_and_line(
+            self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        self.runCmd("breakpoint delete")
+        self.runCmd("process continue")
+        self.expect("process status", PROCESS_STOPPED,
+                    patterns=['Process .* exited with status = 0'])
+
+
     def breakpoint_command_sequence(self):
         """Test a sequence of breakpoint command add, list, and delete."""
         exe = self.getBuildArtifact("a.out")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45554.142319.patch
Type: text/x-patch
Size: 2823 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180413/599fb35c/attachment-0001.bin>


More information about the lldb-commits mailing list