diff --git a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp --- a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp +++ b/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(); diff --git a/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py b/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py --- a/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py +++ b/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)