我想在 Xcode 调试器模式下使用“plcrashreporter”库。
我将“plcrashreporter”添加到我的 testAPP 并运行,因为这段代码 if (debugger_should_exit())
,testAPP 崩溃。我知道是因为调试器捕获所有崩溃而不是 CrashReporter 执行它.然后我直接通过模拟器打开应用程序。它成功了。
但是,不能在Xcode中调试,很不方便。我猜Debugger上的demo是crash的原因是作者做了debugger_should_exit()
之类的操作。可能也用了falg P_TRACED
。我尝试修改了相关的地方,也崩溃了,而且控制台日志:
[PLCrashReport] PLCrashMachExceptionForward:648: Unsupported exception behavior: 0x1 (MACH_EXCEPTION_CODES=true)
[PLCrashReport] plframe_cursor_read_compact_unwind:66: Could not find a loaded image for the current frame pc: 0x7fff6224f35b
[PLCrashReport] grow:121: WARNING: Growing the AsyncAllocator free list via vm_allocate(). Increasing the initial size of this allocator is recommended.
[PLCrashReport] plcrash_writer_write_signal:1143: Warning -- unhandled signal sicode (signo=9, code=0). This is a bug.
我发现一个应用程序已经解决了这个问题,但我不知道如何解决。请帮助我,谢谢。
最佳答案
您是希望通过应用程序进行调试还是仅查看日志?
您可以运行更改运行模式以禁用 Debug模式,这将允许您查看应用程序的日志输出。因为现在禁用了 Debug模式,所以 PLCrashReporter 现在将运行。您可以格式化打印的崩溃报告并查看其日志内容。
guard let crashData = try? crashReporter.loadPendingCrashReportDataAndReturnError(), let reportData = try? PLCrashReport(data: crashData), !report.isKind(of: NSNull.classForCoder()) else {
crashReporter.purgePendingCrashReport()
return
}
let crash: NSString = PLCrashReportTextFormatter.stringValue(for: reportData, with: PLCrashReportTextFormatiOS)! as NSString
print("Crash report:\n \(crash)")
关于ios - 如何在 Xcode 调试中使用 "PLCrashreporter",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41827671/