[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
Mon Sep 13 20:48:13 PDT 2021
vadimcn created this revision.
vadimcn added a reviewer: jingham.
vadimcn added a project: LLDB.
Herald added a subscriber: JDevlieghere.
vadimcn requested review of this revision.
Herald added a subscriber: lldb-commits.
Setting an address breakpoint unconditionally creates a location, however that location may not necessarily have a resolved site (e.g. if the process hasn't been launched yet). Before this patch, LLDB wouldn't try to re-resolve such breakpoints.
Repository:
rG LLVM Github Monorepo
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.372392.patch
Type: text/x-patch
Size: 3350 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210914/b085529f/attachment-0001.bin>
More information about the lldb-commits
mailing list