[llvm-branch-commits] [lldb] 13ee00d - [debugserver] Use dlsym for posix_spawnattr_setarchpref_np

Jonas Devlieghere via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Dec 5 14:11:32 PST 2020


Author: Jonas Devlieghere
Date: 2020-12-05T14:06:45-08:00
New Revision: 13ee00d0c95a4eede96ba9520146a01930af2a0a

URL: https://github.com/llvm/llvm-project/commit/13ee00d0c95a4eede96ba9520146a01930af2a0a
DIFF: https://github.com/llvm/llvm-project/commit/13ee00d0c95a4eede96ba9520146a01930af2a0a.diff

LOG: [debugserver] Use dlsym for posix_spawnattr_setarchpref_np

The @available check did not work as I thought it did. Use good old
dlsym instead.

Added: 
    

Modified: 
    lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Removed: 
    


################################################################################
diff  --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index 232a0d25a38a..386c5e42306a 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -3273,9 +3273,14 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
     bool slice_preference_set = false;
 
     if (cpu_subtype != 0) {
-      if (@available(macOS 10.16, ios 10.14, watchos 7.0, tvos 14.0, *)) {
-        err.SetError(posix_spawnattr_setarchpref_np(&attr, 1, &cpu_type,
-                                                    &cpu_subtype, &ocount));
+      typedef int (*posix_spawnattr_setarchpref_np_t)(
+          posix_spawnattr_t *, size_t, cpu_type_t *, cpu_subtype_t *, size_t *);
+      posix_spawnattr_setarchpref_np_t posix_spawnattr_setarchpref_np_fn =
+          (posix_spawnattr_setarchpref_np_t)dlsym(
+              RTLD_DEFAULT, "posix_spawnattr_setarchpref_np");
+      if (posix_spawnattr_setarchpref_np_fn) {
+        err.SetError((*posix_spawnattr_setarchpref_np)(&attr, 1, &cpu_type,
+                                                       &cpu_subtype, &ocount));
         slice_preference_set = err.Success();
         if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
           err.LogThreaded(


        


More information about the llvm-branch-commits mailing list