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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:56:55  来源:igfitidea点击:

Terminal command-line debug of iOS Simulator apps?

iosxcodemacosdebugginglldb

提问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:

所以:

  1. Run the iOS Simulator, having already gotten your app into it.
  2. In a terminal window:
  1. 运行 iOS 模拟器,已经让您的应用程序进入其中。
  2. 在终端窗口中:
    % gdb
    ...
    (gdb) attach --waitfor 'Name Of Your App'
  1. Launch your app from the simulator Springboard.
  2. gdb should attach to the process beforemain()is executed. So you can set some breakpoints, or whatever. Then:
  1. 从模拟器 Springboard 启动您的应用程序。
  2. gdb 应该main()执行之前附加到进程。所以你可以设置一些断点,或者其他什么。然后:
    (gdb) continue

The procedure for lldbis 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)人,我很感激。:-)