Skip to content

Commit 5dcf5cc

Browse files
[lldb] Remove unfiltered stop reason propagation from StopInfoMachException (#122817)
In the presence of OS plugins, StopInfoMachException currently propagates breakpoint stop reasons even if those breakpoints were not intended for a specific thread, effectively removing our ability to set thread-specific breakpoints. This was originally added in [1], but the motivation provided in the comment does not seem strong enough to remove the ability to set thread-specific breakpoints. The only way to break thread specific breakpoints would be if a user set such a breakpoint and _then_ loaded an OS plugin, a scenario which we would likely not want to support. [1]: swiftlang@ab745c2#diff-8ec6e41b1dffa7ac4b5841aae24d66442ef7ebc62c8618f89354d84594f91050R501
1 parent e511b3e commit 5dcf5cc

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -780,13 +780,8 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException(
780780
// but if it is for another thread, we can just report no reason. We
781781
// don't need to worry about stepping over the breakpoint here, that
782782
// will be taken care of when the thread resumes and notices that
783-
// there's a breakpoint under the pc. If we have an operating system
784-
// plug-in, we might have set a thread specific breakpoint using the
785-
// operating system thread ID, so we can't make any assumptions about
786-
// the thread ID so we must always report the breakpoint regardless
787-
// of the thread.
788-
if (bp_site_sp->ValidForThisThread(thread) ||
789-
thread.GetProcess()->GetOperatingSystem() != nullptr)
783+
// there's a breakpoint under the pc.
784+
if (bp_site_sp->ValidForThisThread(thread))
790785
return StopInfo::CreateStopReasonWithBreakpointSiteID(
791786
thread, bp_site_sp->GetID());
792787
else if (is_trace_if_actual_breakpoint_missing)

lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py

+9
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,12 @@ def run_python_os_step(self):
219219
6,
220220
"Make sure we stepped from line 5 to line 6 in main.c",
221221
)
222+
223+
thread_bp_number = lldbutil.run_break_set_by_source_regexp(
224+
self, "Set tid-specific breakpoint here", num_expected_locations=1
225+
)
226+
breakpoint = target.FindBreakpointByID(thread_bp_number)
227+
# This breakpoint should not be hit.
228+
breakpoint.SetThreadID(123)
229+
process.Continue()
230+
self.assertState(process.GetState(), lldb.eStateExited)

lldb/test/API/functionalities/plugins/python_os_plugin/main.c

+2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
int main (int argc, char const *argv[], char const *envp[])
44
{
55
puts("stop here"); // Set breakpoint here
6+
puts("hello");
7+
puts("Set tid-specific breakpoint here");
68
return 0;
79
}

0 commit comments

Comments
 (0)