Skip to content

Commit e7689b6

Browse files
[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear
Currently, these breakpoints are being accumulated every time a new process if created (e.g. through a `run`). Depending on the circumstances, the old breakpoints are even left enabled, interfering with subsequent processes. This is addressed by removing the breakpoints in ProcessGDBRemote::Clear Note that these breakpoints are more of a PlatformDarwin thing, so in the future we should look into moving them there.
1 parent 5fbd065 commit e7689b6

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3410,6 +3410,9 @@ Status ProcessGDBRemote::DisableWatchpoint(WatchpointSP wp_sp, bool notify) {
34103410
void ProcessGDBRemote::Clear() {
34113411
m_thread_list_real.Clear();
34123412
m_thread_list.Clear();
3413+
if (m_thread_create_bp_sp)
3414+
if (TargetSP target_sp = m_target_wp.lock())
3415+
target_sp->RemoveBreakpointByID(m_thread_create_bp_sp->GetID());
34133416
}
34143417

34153418
Status ProcessGDBRemote::DoSignal(int signo) {

lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,23 @@ def test_internal_bps_resolved(self):
3535
for bp in bps:
3636
num_resolved += bp.GetNumResolvedLocations()
3737
self.assertGreater(num_resolved, 0)
38+
39+
@skipUnlessDarwin
40+
def test_internal_bps_deleted_on_relaunch(self):
41+
self.build()
42+
43+
source_file = lldb.SBFileSpec("main.c")
44+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
45+
self, "initial hello", source_file
46+
)
47+
48+
self.runCmd("break list --internal")
49+
output = self.res.GetOutput()
50+
self.assertEqual(output.count("thread-creation"), 1)
51+
52+
process.Kill()
53+
self.runCmd("run", RUN_SUCCEEDED)
54+
55+
self.runCmd("break list --internal")
56+
output = self.res.GetOutput()
57+
self.assertEqual(output.count("thread-creation"), 1)

0 commit comments

Comments
 (0)