[Lldb-commits] [lldb] [lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (PR #134397)
Felipe de Azevedo Piovezan via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 4 08:05:44 PDT 2025
https://github.com/felipepiovezan created https://github.com/llvm/llvm-project/pull/134397
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 PlatformDarwing thing, so in the future we should look into moving them there.
>From a1e12d075a3f47b6af21fa251d60a28e84c2ee07 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan <fpiovezan at apple.com>
Date: Fri, 4 Apr 2025 07:56:38 -0700
Subject: [PATCH] [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 PlatformDarwing thing, so in
the future we should look into moving them there.
---
.../Process/gdb-remote/ProcessGDBRemote.cpp | 3 +++
.../TestBreakpointsThreadInit.py | 20 +++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 68360788c96e6..d7e8c2ce7944e 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3410,6 +3410,9 @@ Status ProcessGDBRemote::DisableWatchpoint(WatchpointSP wp_sp, bool notify) {
void ProcessGDBRemote::Clear() {
m_thread_list_real.Clear();
m_thread_list.Clear();
+ if (m_thread_create_bp_sp)
+ if (TargetSP target_sp = m_target_wp.lock())
+ target_sp->RemoveBreakpointByID(m_thread_create_bp_sp->GetID());
}
Status ProcessGDBRemote::DoSignal(int signo) {
diff --git a/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
index 1c6fd4f91c73e..bf667f6f7d336 100644
--- a/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
+++ b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
@@ -35,3 +35,23 @@ def test_internal_bps_resolved(self):
for bp in bps:
num_resolved += bp.GetNumResolvedLocations()
self.assertGreater(num_resolved, 0)
+
+ @skipUnlessDarwin
+ def test_internal_bps_deleted_on_relaunch(self):
+ self.build()
+
+ source_file = lldb.SBFileSpec("main.c")
+ target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+ self, "initial hello", source_file
+ )
+
+ self.runCmd("break list --internal")
+ output = self.res.GetOutput()
+ self.assertEqual(output.count("thread-creation"), 1)
+
+ process.Kill()
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ self.runCmd("break list --internal")
+ output = self.res.GetOutput()
+ self.assertEqual(output.count("thread-creation"), 1)
More information about the lldb-commits
mailing list