xcode 如何在附加到 iOS 的 lldb 中手动生成核心转储(或等效的)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17872684/
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
How can I manually generate a core dump (or equivalent) in lldb attached to iOS
提问by stokastic
Sometimes I'm trying to track down a really rare bug in an iOS app. I'll hit it in the debugger after hours of trying to repro only to have xcode or lldb crash on me while I'm debugging (usually if I'm stepping through C++ code). This is beyond infuriating.
有时我试图在 iOS 应用程序中追踪一个非常罕见的错误。经过数小时的尝试重新编译后,我会在调试器中点击它,只是在调试时 xcode 或 lldb 崩溃(通常是在我单步执行 C++ 代码时)。这实在是太令人气愤了。
With gdb you can use generate-core-dump
to create a core dump of the file so that I can re-load it in gdb and at least look at all of the memory. What I want is the ability to do something similar in lldb so that when xcode crashes (as it always tends to do at the worst times) I can recover my debugging session without having to reproduce the crash.
使用 gdb,您可以generate-core-dump
创建文件的核心转储,以便我可以在 gdb 中重新加载它并至少查看所有内存。我想要的是能够在 lldb 中做类似的事情,这样当 xcode 崩溃时(因为它总是在最糟糕的时候这样做)我可以恢复我的调试会话而不必重现崩溃。
The app is running on a non-jailbroken iPhone, so I don't have much access to the OS to do something like dump the memory from there.
该应用程序在未越狱的 iPhone 上运行,因此我无法访问操作系统以执行诸如从那里转储内存之类的操作。
One possible answer is to just use gdb instead of lldb, but I think that causes some other problems that I'm not remembering at the moment, plus it doesn't have some of the features that are useful in lldb.
一个可能的答案是只使用 gdb 而不是 lldb,但我认为这会导致一些我目前不记得的其他问题,而且它没有一些在 lldb 中有用的功能。
回答by Jason Molenda
UPDATE: Xcode 6, released fall of 2014, includes a new process save-core
command in lldb -- lldb can now generate a coredump of a user process. e.g. (lldb) process save-core /tmp/corefile
and wait a little bit.
更新:2014 年秋季发布的 Xcode 6process save-core
在 lldb 中包含一个新命令——lldb 现在可以生成用户进程的核心转储。例如(lldb) process save-core /tmp/corefile
,稍等一下。
The original answer for Xcode 5 and earlier lldb's, was:
Xcode 5 和更早版本的 lldb 的原始答案是:
This feature isn't implemented in lldb yet. This feature isn't implemented in the Apple version of gdb, either, for that matter.
此功能尚未在 lldb 中实现。就此而言,此功能也未在 Apple 版本的 gdb 中实现。
While not a commonly requested feature, it is something other people have said would be useful as well. Hopefully someone will be sufficiently motivated to add that capability to lldb. I'm not sure how well it would work on an iOS device because it's going to involve gigantic amounts of data being transferred up to the Mac over a protocol that isn't very efficient for large data transfers - I expect it would be remarkably slow.
虽然不是普遍要求的功能,但其他人认为它也很有用。希望有人有足够的动力将这种功能添加到 lldb。我不确定它在 iOS 设备上的运行效果如何,因为它将涉及通过对大数据传输效率不高的协议将大量数据传输到 Mac - 我预计它会非常慢.
The core file can be opened with lldb -c /tmp/corefile
核心文件可以用 lldb -c /tmp/corefile 打开
回答by Technologeeks
It's worth noting that the process explorer tool for iOS can generate core dumps of any PID (assuming you have root or it's the same UID as you), without impacting the process.
值得注意的是,iOS 的进程浏览器工具可以生成任何 PID 的核心转储(假设您有 root 或与您具有相同的 UID),而不会影响进程。