QuincyKit / PLCrashReporter:提供描述*之前*崩溃 [英] QuincyKit/PLCrashReporter: provide description *before* the crash

查看:338
本文介绍了QuincyKit / PLCrashReporter:提供描述*之前*崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用QuincyKit,它运行在PLCrashReporter之上,发现我的iOS应用程序中的生产崩溃,并获得日志。有时,它会极大地帮助我调试,如果我有一些变量从几个调用栈级别以上的崩溃点。喜欢,什么记录ID它崩溃,如果记录处理代码是许多层次的嵌套深。

I'm using QuincyKit, which runs on top of PLCrashReporter, to discover production crashes in my iOS app, and to obtain logs. Sometimes, it'd tremendously help me debug if I had some variables from several call stack levels above the crash point. Like, what record ID did it crash on, if the record processing code is many levels of nesting deep.

问题是 - 有一种方法提供某种上下文字符串被插入到崩溃日志中作为生成时的描述?我设置它进入一个调用堆栈为一个记录,我会在退出时清除它。更好的是,如果它是非持久性的(即在内存中) - 写入非易失性存储器一直都会对电池造成影响。恐怕。

The question is - is there a way to provide some kind of context string that gets inserted into a crash log as description at generation time? I'd set it upon entry into a call stack for a record, I'd clear it upon exit. Better if it's non-persistent (i. e. in memory) - writing to the nonvolatile storage all the time would be taxing on the battery, I'm afraid.

推荐答案

找到了一个有限的解决方法。我使用从捆绑ID导出的名称的共享内存块以存储上下文字符串。该块在正确关闭时清零。然后我覆盖我的Quincy代理中的 -crashReportDescription ,以便它提供共享内存内容(如果有的话)作为描述。如果最后一个应用程序关闭是一个崩溃,它只是非空。

Found a limited workaround. I use a shared memory block with a name that's derived from bundle ID to store the context string. The block is cleared on proper shutdown. Then I override -crashReportDescription in my Quincy delegate so that it provides the shared memory contents, if any, as description. It is only nonempty if the last app shutdown was a crash.

这种方法显然有缺陷。如果他们说,在崩溃和下一个应用程序启动之间重新启动设备,共享内存信息丢失。

There are obviously flaws with this approach. If they, say, restart the device between the crash and the next app startup, the shared memory info is lost.

编辑:在第一个版本的设计,使用一个私人的,名为UIPasteboard而不是共享内存。原来是相当的性能打击。共享内存速度快了几个数量级。

in the first version of the design, I used a private, named UIPasteboard instead of shared memory. That turned out to be quite a performance hit. Shared memory is orders of magnitude faster.

EDIT2:但是它们在iOS 7中打破了共享内存,所以UIPasteboard回来了。 Bummer。

but then they broke shared memory in iOS 7, so UIPasteboard is back. Bummer.

EDIT3:找到另一种方法,不太优雅,但它适用于iOS 7.我将上下文字符串存储在一个简单的静态内存块。我在PLCrashReporter中放置一个自定义崩溃处理程序与 [[PLCrashReporter sharedReporter] setCrashCallbacks:] 。在处理程序中,我写出一个文件的上下文(如果有)。在应用程序启动时,我读取该文件,并提供 -crashReportDescription 中的内容(如果有)。走开,UIPasteboard。

found another approach, less elegant but it works in iOS 7. I store my context string in a plain static memory block. I place a custom crash handler within PLCrashReporter with [[PLCrashReporter sharedReporter] setCrashCallbacks:]. In the handler, I write out said context (if any) to a file. On app startup, I read said file, and provide the contents (if any) in -crashReportDescription. Go away, UIPasteboard.

这篇关于QuincyKit / PLCrashReporter:提供描述*之前*崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆