[Lldb-commits] [lldb] 5dcf5cc - [lldb] Remove unfiltered stop reason propagation from StopInfoMachException (#122817)

via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 14 11:26:01 PST 2025


Author: Felipe de Azevedo Piovezan
Date: 2025-01-14T11:25:58-08:00
New Revision: 5dcf5cc0e0b462be99d1ae3d993ec11b039097b8

URL: https://github.com/llvm/llvm-project/commit/5dcf5cc0e0b462be99d1ae3d993ec11b039097b8
DIFF: https://github.com/llvm/llvm-project/commit/5dcf5cc0e0b462be99d1ae3d993ec11b039097b8.diff

LOG: [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]:
https://github.com/swiftlang/llvm-project/commit/ab745c2ad865c07f3905482fd071ef36c024713a#diff-8ec6e41b1dffa7ac4b5841aae24d66442ef7ebc62c8618f89354d84594f91050R501

Added: 
    

Modified: 
    lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
    lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
    lldb/test/API/functionalities/plugins/python_os_plugin/main.c

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index d08e99f4844de3..698ba0f0f720f6 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -780,13 +780,8 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException(
         // but if it is for another thread, we can just report no reason.  We
         // don't need to worry about stepping over the breakpoint here, that
         // will be taken care of when the thread resumes and notices that
-        // there's a breakpoint under the pc. If we have an operating system
-        // plug-in, we might have set a thread specific breakpoint using the
-        // operating system thread ID, so we can't make any assumptions about
-        // the thread ID so we must always report the breakpoint regardless
-        // of the thread.
-        if (bp_site_sp->ValidForThisThread(thread) ||
-            thread.GetProcess()->GetOperatingSystem() != nullptr)
+        // there's a breakpoint under the pc.
+        if (bp_site_sp->ValidForThisThread(thread))
           return StopInfo::CreateStopReasonWithBreakpointSiteID(
               thread, bp_site_sp->GetID());
         else if (is_trace_if_actual_breakpoint_missing)

diff  --git a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
index 479c94c2315407..3ad7539018d5d8 100644
--- a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
+++ b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
@@ -219,3 +219,12 @@ def run_python_os_step(self):
             6,
             "Make sure we stepped from line 5 to line 6 in main.c",
         )
+
+        thread_bp_number = lldbutil.run_break_set_by_source_regexp(
+            self, "Set tid-specific breakpoint here", num_expected_locations=1
+        )
+        breakpoint = target.FindBreakpointByID(thread_bp_number)
+        # This breakpoint should not be hit.
+        breakpoint.SetThreadID(123)
+        process.Continue()
+        self.assertState(process.GetState(), lldb.eStateExited)

diff  --git a/lldb/test/API/functionalities/plugins/python_os_plugin/main.c b/lldb/test/API/functionalities/plugins/python_os_plugin/main.c
index faa6dd58ecd62b..deb80027c5e6c2 100644
--- a/lldb/test/API/functionalities/plugins/python_os_plugin/main.c
+++ b/lldb/test/API/functionalities/plugins/python_os_plugin/main.c
@@ -3,5 +3,7 @@
 int main (int argc, char const *argv[], char const *envp[])
 {
     puts("stop here"); // Set breakpoint here
+    puts("hello");
+    puts("Set tid-specific breakpoint here");
     return 0;
 }


        


More information about the lldb-commits mailing list