[Lldb-commits] [PATCH] D109738: [lldb] Fix bug 38317 - Address breakpoints don't work if set before the process launches

Vadim Chugunov via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 14 23:12:32 PDT 2021


vadimcn updated this revision to Diff 372636.
vadimcn added a comment.

Added patch context.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109738/new/

https://reviews.llvm.org/D109738

Files:
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py


Index: lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
===================================================================
--- lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
+++ lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
@@ -79,10 +79,33 @@
         process = target.Launch(launch_info, error)
         self.assertTrue(process, PROCESS_IS_VALID)
 
-        thread = get_threads_stopped_at_breakpoint(process, breakpoint)
+        threads = get_threads_stopped_at_breakpoint(process, breakpoint)
         self.assertEqual(
             len(threads), 1,
             "There should be a thread stopped at our breakpoint")
 
         # The hit count for the breakpoint should now be 2.
         self.assertEquals(breakpoint.GetHitCount(), 2)
+
+        process.Kill()
+
+        # Create a breakpoint again, this time using the load address
+        load_address = address.GetLoadAddress(target)
+
+        # Re-create the target to make sure that nothing is cached
+        target = self.createTestTarget()
+        breakpoint = target.BreakpointCreateByAddress(load_address)
+
+        launch_info.Clear()
+        launch_info.SetLaunchFlags(flags)
+
+        process = target.Launch(launch_info, error)
+        self.assertTrue(process, PROCESS_IS_VALID)
+
+        threads = get_threads_stopped_at_breakpoint(process, breakpoint)
+        self.assertEqual(
+            len(threads), 1,
+            "There should be a thread stopped at our breakpoint")
+
+        # The hit count for the breakpoint should be 1.
+        self.assertEquals(breakpoint.GetHitCount(), 1)
Index: lldb/source/Breakpoint/BreakpointResolverAddress.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -97,8 +97,12 @@
   bool re_resolve = false;
   if (m_addr.GetSection() || m_module_filespec)
     re_resolve = true;
-  else if (GetBreakpoint()->GetNumLocations() == 0)
-    re_resolve = true;
+  else {
+    BreakpointSP breakpoint = GetBreakpoint();
+    if (breakpoint->GetNumLocations() == 0 ||
+        breakpoint->GetNumResolvedLocations() < breakpoint->GetNumLocations())
+      re_resolve = true;
+  }
 
   if (re_resolve)
     BreakpointResolver::ResolveBreakpoint(filter);
@@ -110,8 +114,12 @@
   bool re_resolve = false;
   if (m_addr.GetSection())
     re_resolve = true;
-  else if (GetBreakpoint()->GetNumLocations() == 0)
-    re_resolve = true;
+  else {
+    BreakpointSP breakpoint = GetBreakpoint();
+    if (breakpoint->GetNumLocations() == 0 ||
+        breakpoint->GetNumResolvedLocations() < breakpoint->GetNumLocations())
+      re_resolve = true;
+  }
 
   if (re_resolve)
     BreakpointResolver::ResolveBreakpointInModules(filter, modules);
@@ -151,7 +159,7 @@
       BreakpointLocationSP loc_sp = breakpoint.GetLocationAtIndex(0);
       lldb::addr_t cur_load_location =
           m_addr.GetLoadAddress(&breakpoint.GetTarget());
-      if (cur_load_location != m_resolved_addr) {
+      if (cur_load_location != m_resolved_addr || !loc_sp->IsResolved()) {
         m_resolved_addr = cur_load_location;
         loc_sp->ClearBreakpointSite();
         loc_sp->ResolveBreakpointSite();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109738.372636.patch
Type: text/x-patch
Size: 3350 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210915/55dd5fa8/attachment.bin>


More information about the lldb-commits mailing list