Search code examples
lldb

lldb attaching to a process on OS X from an ssh session


How can I lldb attach to a running process when I ssh into OS X? I can't debug this particular app from a terminal window because changing windows will change some UI state that I'm trying to debug.

When I attach lldb from an ssh session it says "attach failed: lost connection".

EDIT: It's not ssh that is disconnecting. I'm not being disconnected from ssh, it's just that lldb won't attach while I'm in an ssh session.


Solution

  • The security policy for debugging on OS X requires that an admin user on the main console authenticate to allow debugging on that machine. That it is not possible to do that remotely is on purpose. One way to do this is to start up Xcode and debug something (doesn't matter what) on the machine you are ssh'ing into. That will put up a "do you want to turn on debugging on this machine" dialog, which an admin user must authenticate.

    You can also enable debugging by running the tool:

     > /usr/sbin/DevToolsSecurity --enable
    

    but again, that will put up a GUI confirm dialog so you have to have access to the console to authenticate.

    It is also possible to manually edit the security policies on the target system to not require authentication for debugging, but I only know that that is possible, not how to do it...