Is it possible to use GDB or LLDB from the Terminal command-line under Mac OS X to debug apps running on the iOS Simulator? (e.g. not from within Xcode's GUI or console, but using an external command-line or process). If so, how?
Asked
Active
Viewed 8,871 times
1 Answers
31
You'll need to have the app already in the simulator's Springboard; you can't launch the app in the simulator from Xcode and then expect to be able to have a command line instance of gdb attach to it.
So:
- Run the iOS Simulator, having already gotten your app into it.
- In a terminal window:
% gdb ... (gdb) attach --waitfor 'Name Of Your App'
- Launch your app from the simulator Springboard.
- gdb should attach to the process before
main()
is executed. So you can set some breakpoints, or whatever. Then:
(gdb) continue
The procedure for lldb
is similar:
% lldb (lldb) process attach -n 'Name Of Your App' --waitfor <launch your app in the simulator> (lldb) continue
I am not sure why you'd want or need to do this, but as an old command line gdb (and dbx) guy, I can appreciate it. :-)

Heath Borders
- 30,998
- 16
- 147
- 256

Mark Granoff
- 16,878
- 2
- 59
- 61
-
So nifty. Hat off to you, sir! – Jacob Oscarson Oct 10 '12 at 11:43
-
1Use `xcrun simctl` commands to install the app on the simulator, then launch it. – tboyce12 Aug 02 '17 at 22:25
-
To answer the question of why you might want to do this: in my case it's to investigate iOS CI issues, replicating the console-driven CI process locally and stopping the app at particular points of interest. – Robin Macharg Feb 02 '20 at 08:58