xcode iOS模拟器应用程序的终端命令行调试?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10112164/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Terminal command-line debug of iOS Simulator apps?
提问by hotpaw2
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?
是否可以在 Mac OS X 下的终端命令行中使用 GDB 或 LLDB 来调试在 iOS 模拟器上运行的应用程序?(例如,不是来自 Xcode 的 GUI 或控制台,而是使用外部命令行或进程)。如果是这样,如何?
回答by Mark Granoff
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.
您需要在模拟器的 Springboard 中安装该应用程序;您无法从 Xcode 在模拟器中启动应用程序,然后期望能够将 gdb 的命令行实例附加到它。
So:
所以:
- Run the iOS Simulator, having already gotten your app into it.
- In a terminal window:
- 运行 iOS 模拟器,已经让您的应用程序进入其中。
- 在终端窗口中:
% 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:
- 从模拟器 Springboard 启动您的应用程序。
- gdb 应该在
main()
执行之前附加到进程。所以你可以设置一些断点,或者其他什么。然后:
(gdb) continue
The procedure for lldb
is similar:
过程lldb
类似:
% 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. :-)
我不确定你为什么想要或需要这样做,但作为一个旧的命令行 gdb(和 dbx)人,我很感激。:-)