Xcode lldb can't attach to MacOS system program /bin/cp - "Not allowed to attach to process."

0

When I try to use LLDB included with Xcode 12.4 to run the Unix cp command on either macOS Catalina 10.15.7 and Big Sur 11.2.2, LLDB freezes for several seconds when I start the process, then fails with the following error:

error: process exited with status -1 (attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries when the attached failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.))

In Console, I see 10 copies of the same error from the LLDB debugserver engine server process just as promised, of form:

error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 44753, &task ) => err = 0x00000005 ((os/kern) failure)

Attaching to the process while it's running, either from the lldb command line or from the Xcode IDE, produces the same error message, as does trying to run the debugger and debugged process using sudo lldb.

What can I do to fix this issue?


Full transcript of the terminal session:

$ lldb --version
lldb-1200.0.44.2
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)

$ lldb cp /etc/profile ~/scratchfile.txt
(lldb) target create "cp"
Current executable set to 'cp' (x86_64).
(lldb) settings set -- target.run-args  "/etc/profile" "/Users/me/scratchfile.txt"
(lldb) run
error: process exited with status -1 (attach failed (Not allowed to attach to process.  Look in the console messages (Console.app), near the debugserver entries when the attached failed.  The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.))
xcode
debugging
lldb

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0