Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

lldb

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.

like image 862
bratsche Avatar asked Dec 01 '14 22:12

bratsche


People also ask

Does LLDB work on Linux?

It is known to work on macOS, Linux, FreeBSD, NetBSD and Windows, and supports i386, x86-64, and ARM instruction sets. LLDB is the default debugger for Xcode 5 and later. Android Studio also uses LLDB for debug.

Is LLDB better than GDB?

The main difference between LLDB and GDB is that in LLDB, the programmer can debug programs written in C, Objective C and C++ while, in GDB, the programmer can debug programs written in Ada, C, C++, Objective C, Pascal, FORTRAN and Go.

Can LLDB connect to Gdbserver?

LLDB supports GDB server that QEMU uses, so you can do the same thing with the previous section, but with some command modification as LLDB has some commands that are different than GDB You can run QEMU to listen for a "GDB connection" before it starts executing any code to debug it.

What does LLDB mean in Xcode?

lldb is the default debugger in Xcode on macOS and supports debugging C, Objective-C and C++ on the desktop and iOS devices and simulator. All of the code in the LLDB project is available under the Apache 2.0 License with LLVM exceptions.


1 Answers

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...

like image 109
Jim Ingham Avatar answered Jan 23 '23 03:01

Jim Ingham