简体   繁体   English

没有崩溃的崩溃日志?

[英]Crash log without crash?

Hey this may be a stupid question but I couldn't find the answer anywhere, apologies if the answer is easily found and if my research skills are pants. 嘿,这可能是一个愚蠢的问题,但是我找不到任何答案,如果很容易找到答案,并且我的研究技能很差,我深表歉意。

anyway is it possible to generate a crash report when an app doesn't crash? 无论如何,当应用程序不崩溃时,是否有可能生成崩溃报告? so say if a user encounters a bug could there be an option to allow them to generate a crash report which can then be sent to me? 这么说,如果用户遇到错误,是否可以选择允许他们生成崩溃报告,然后将其发送给我? also how would I go about doing this? 我还要怎么做呢?

Thanks for any help :) 谢谢你的帮助 :)

I have used it couple of times when I had to print stack trace: 我不得不打印堆栈跟踪时使用了几次:

+ (NSArray *)backtrace
{
    void* callstack[128];
    int frames = backtrace(callstack, 128);
    char **strs = backtrace_symbols(callstack, frames);

    int i;
    NSMutableArray *backtrace = [NSMutableArray arrayWithCapacity:frames];
    for (
        i = UncaughtExceptionHandlerSkipAddressCount;
        i < UncaughtExceptionHandlerSkipAddressCount +
            UncaughtExceptionHandlerReportAddressCount;
        i++)
    {
        [backtrace addObject:[NSString stringWithUTF8String:strs[i]]];
    }
    free(strs);

    return backtrace;
} 

"When an application crashes on the iPhone, it disappears without telling the user what happened. However, it is possible to add exception and signal handling to your applications so that an error message can be displayed to the user or you can save changes. It is even possible to try to recover from this situation without crashing at all." “当应用程序在iPhone上崩溃时,它会消失而不通知用户发生了什么。但是,可以向您的应用程序添加异常和信号处理,从而可以向用户显示错误消息或保存更改。它甚至有可能尝试从这种情况中恢复而不会崩溃。” Look at http://cocoawithlove.com/2010/05/handling-unhandled-exceptions-and.html 看看http://cocoawithlove.com/2010/05/handling-unhandled-exceptions-and.html

Here's what I use for my stacktraces: 这是我用于堆栈跟踪的内容:

        NSArray *callStackArray = [exception callStackReturnAddresses];
        int frameCount = [callStackArray count];
        void *backtraceFrames[frameCount];

        for (int i=0; i < frameCount; i++) {
            backtraceFrames[i] = (void *)[[callStackArray objectAtIndex:i] unsignedIntegerValue];
        }

        char **strs = backtrace_symbols(backtraceFrames, frameCount);

        NSMutableArray *backtraceArray = [NSMutableArray arrayWithCapacity:frameCount];
        for (int i = 0; i < frameCount; i++) {
            NSString *entry = [NSString stringWithUTF8String:strs[i]];
            [backtraceArray addObject:entry];
        }
        free(strs);

You just have to make sure you don't do any harm to your app: http://landonf.bikemonkey.org/2011/09/14 . 您只需要确保对您的应用程序没有任何损害即可: http : //landonf.bikemonkey.org/2011/09/14 You could also use PLCrashReporter to handle all your crashes or if you're lazy like me, use a service like Crittercism 您也可以使用PLCrashReporter处理所有崩溃,或者,如果像我一样懒,请使用Crittercism之类的服务

I used to use backtrace_symbols for handling my crashes too, but then I found out that it could be dangerous since the method is not async-safe. 我曾经也使用backtrace_symbols来处理崩溃,但是后来我发现这很危险,因为该方法不是异步安全的。 I've since looked at a bunch of crash reporting solutions and went with Crittercism for my apps and it's been pretty sweet! 从那以后,我查看了许多崩溃报告解决方案,并为我的应用程序选择了Crittercism ,这真是太好了!

I suggest you check out TestFlight SDK released a few days ago. 我建议您查看几天前发布的TestFlight SDK It has some awesome features like remote logging and even live crash reports. 它具有一些很棒的功能,例如远程日志记录甚至实时崩溃报告。

For an ad hoc version, you could just call the function abort(), or throw and exception of some kind. 对于临时版本,您可以仅调用函数abort(),或引发某种异常。

An App Store version will not be allowed to ship if it crashes at all during testing. 如果在测试过程中完全崩溃,则不允许发布App Store版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM