Skip to content

[lldb] Update PlatformDarwin list of libraries with thread functions #127922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

felipepiovezan
Copy link
Contributor

Recent versions of the system changed where these functions live.

@llvmbot
Copy link
Member

llvmbot commented Feb 19, 2025

@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)

Changes

Recent versions of the system changed where these functions live.


Full diff: https://github.com/llvm/llvm-project/pull/127922.diff

4 Files Affected:

  • (modified) lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (+2-2)
  • (added) lldb/test/API/macosx/thread_start_bps/Makefile (+3)
  • (added) lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py (+40)
  • (added) lldb/test/API/macosx/thread_start_bps/main.c (+5)
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 51e9a6d81b839..6212bc0dc8385 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -651,8 +651,8 @@ BreakpointSP PlatformDarwin::SetThreadCreationBreakpoint(Target &target) {
       "start_wqthread", "_pthread_wqthread", "_pthread_start",
   };
 
-  static const char *g_bp_modules[] = {"libsystem_c.dylib",
-                                       "libSystem.B.dylib"};
+  static const char *g_bp_modules[] = {
+      "libsystem_c.dylib", "libSystem.B.dylib, libsystem_pthread.dylib"};
 
   FileSpecList bp_modules;
   for (size_t i = 0; i < std::size(g_bp_modules); i++) {
diff --git a/lldb/test/API/macosx/thread_start_bps/Makefile b/lldb/test/API/macosx/thread_start_bps/Makefile
new file mode 100644
index 0000000000000..10495940055b6
--- /dev/null
+++ b/lldb/test/API/macosx/thread_start_bps/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
new file mode 100644
index 0000000000000..a0e24f041f7f0
--- /dev/null
+++ b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
@@ -0,0 +1,40 @@
+"""Test that we get thread names when interrupting a process."""
+
+import time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestInterruptThreadNames(TestBase):
+    @skipUnlessDarwin
+    def test_internal_bps_resolved(self):
+        self.build()
+
+        source_file = lldb.SBFileSpec("main.c")
+        target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+            self, "initial hello", source_file
+        )
+
+        thread_start_func_names = [
+            "start_wqthread",
+            "_pthread_wqthread",
+            "_pthread_start",
+        ]
+        known_module_names = [
+            "libsystem_c.dylib",
+            "libSystem.B.dylib",
+            "libsystem_pthread.dylib",
+        ]
+        bps = []
+        for func in thread_start_func_names:
+            for module in known_module_names:
+                bps.append(target.BreakpointCreateByName(func, module))
+
+        thread.StepOver()
+
+        num_resolved = 0
+        for bp in bps:
+            num_resolved += bp.GetNumResolvedLocations()
+        self.assertGreater(num_resolved, 0)
diff --git a/lldb/test/API/macosx/thread_start_bps/main.c b/lldb/test/API/macosx/thread_start_bps/main.c
new file mode 100644
index 0000000000000..1a0af000b5b04
--- /dev/null
+++ b/lldb/test/API/macosx/thread_start_bps/main.c
@@ -0,0 +1,5 @@
+#include <stdio.h>
+int main() {
+  puts("initial hello");
+  puts("hello from the other side");
+}

@felipepiovezan felipepiovezan force-pushed the felipe/platform_darwin_thread_locations branch from ed7c035 to 6d77076 Compare February 19, 2025 23:42
Recent versions of the system changed where these functions live.
@felipepiovezan felipepiovezan force-pushed the felipe/platform_darwin_thread_locations branch from 6d77076 to 300120e Compare February 19, 2025 23:44
@felipepiovezan felipepiovezan merged commit 81bc28d into llvm:main Feb 20, 2025
7 checks passed
@felipepiovezan felipepiovezan deleted the felipe/platform_darwin_thread_locations branch February 20, 2025 16:26
felipepiovezan added a commit to felipepiovezan/llvm-project that referenced this pull request Feb 20, 2025
…lvm#127922)

Recent versions of the system changed where these functions live.

(cherry picked from commit 81bc28d)
felipepiovezan added a commit to swiftlang/llvm-project that referenced this pull request Feb 20, 2025
…thread_locations_cherrypick

[cherry-pick][lldb] Update PlatformDarwin list of libraries with thread functions (llvm#127922)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants