English 中文(简体)
Is this kind of crash report useless?
原标题:

I tried use "PLCrashReport" to collect the crash info then make the app more stable, but turns out that the report is like this(dont even has a call stack,how am I suppose to use it?):

The "Exception:" part,Exception: (null): (null), which should be "exceptionName" and "exceptionReason", at most time are "null", dont know why, sometimes there will be a normal value but also I think not quite useful...

Crashed on 2009-11-13 23:43:04 +0800 - Signal SIGSEGV (code SEGV_ACCERR, address=0xffffffffc0f4186b)

  • Exception: (null): (null) - Thread 0:

    • Crashed: 1
    • Stack (54 frames):, 806128664, 807756495, 816280840, 816247 068, 817901396, 807756495, 816280840, 817911108, 816247068, 816285160, 816406620, 807756495, 806130012, 119241, 812165747, 812164839 , 812379009, 818127880, 807885435, 807923065, 818122176, 818130772, 816625560, 816626608, 816627024, 816641892, 816651496, 816654628 , 816654224, 146455, 807923363, 816119156, 816119004, 818227300, 807923363, 816119156, 816119004, 816524332, 816525956, 816521588, 816212028, 816151252, 816147980, 827758796, 827769116, 837343488, 821391952, 807840887, 807836793, 807834407, 827752032, 816118388, 816157144, 20421
最佳回答

I haven t used it but I m pretty sure you re not getting any detail because you had a segmentation fault that took out everything down to the registers. The PLCrashReport instance can t report because it died along with everything else.

The PLCrashReport instances runs within the Application itself so if the app goes down hard you won t get any detail.

问题回答

What s a stack trace?

Whenever one of your methods gets called, it puts this onto the stack. A stack trace is a way of finding out which class and method your app crashed in, which often narrows down the bug to a single line.

Of course to do this, the stack trace needs to be readable, rather than a whole load of hex numbers.

Check out atos.

To prevent this happening again, you could interpret this Call Stack using atos. See the Stack Traces page of the Cocoa Dev wiki for a discussion and code on how to convert these numbers into meaningful methods.

You ll need to figure out a way of integrating this with the crash reporter. I use UKCrashReporter and I ve modified Uli s code so that if there s an uncaught exception it adds the readable stack trace onto the crash report.

Code Sample

I ve taken inspiration from the ESStackTrace class and here s what I do:

-(void)logAndSaveStackTrace {
    NSString *stackTrace = [[self userInfo] objectForKey:NSStackTraceKey];
    NSString *atosCommand;
    if (stackTrace) {
        // If the stack trace key is present, pull out the addresses and convert to method names using atos.
        atosCommand = [NSString stringWithFormat:@"/usr/bin/atos -p %d %@ | tail -n +3 | head -n +%d | c++filt | cat -n",
                         [[NSProcessInfo processInfo] processIdentifier],
                         stackTrace,
                         ([[stackTrace componentsSeparatedByString:@"  "] count] - 4)];

    } else {
        // If there isn t a stack trace key or it s nil, try and work out the stack using the internal callStackReturn addresses method.
        NSArray *stackTraceArray = [self callStackReturnAddresses];
        atosCommand = [NSString stringWithFormat:@"/usr/bin/atos -p %d %@",
                       [[NSProcessInfo processInfo] processIdentifier],
                       [stackTraceArray componentsJoinedByString:@" "]];
    }

    NSString *readableStackTrace = [ShellTask executeShellCommandSynchronously:atosCommand];

    NSString *exceptionMessageForCrashReport = [NSString stringWithFormat:@"An exception of type %s occured.
%s
Stack trace:
%@", 
                                                [[self name] cStringUsingEncoding:NSUTF8StringEncoding], 
                                                [[self reason] cStringUsingEncoding:NSUTF8StringEncoding],
                                                readableStackTrace];

    [[NSUserDefaults standardUserDefaults] setObject:exceptionMessageForCrashReport forKey:@"uncaughtExceptionReport"];
    [[NSUserDefaults standardUserDefaults] synchronize];

    // Log the exception to the console too.
    NSLog(@"%@", exceptionMessageForCrashReport);
}

Dependencies Ahoy!

Of course, one of the problems with this approach is that you re introducing a dependency on atos. I ve been told that it s installed as standard on 10.5 and later, but this might be wrong. Eventually I m going to make a little installer which adds atos if my app can t find it.





相关问题
Ruby Interpreter crashes with a certain word

Ok, this one s a little ridiculous, and I m almost afraid no one will believe me. But here it goes: I have written a Ruby Rails application that handles content for tons of domains. Now I know this ...

Java HotSpot error

Curious if anyone could help out in regards to a Java HotSpot dump...saw some reference to head over to the Sun Forums, figured I would try here first...below is the dump... # # An unexpected error ...

NSOperation performSelectorOnMainThread crashes

I m calling a NSOperation from a Subview of a NavigationController. MyOperation *op = [[MyOperation alloc] target:self action:@selector(didFinishOperation)]; The Operation loads some data from a ...

Is this kind of crash report useless?

I tried use "PLCrashReport" to collect the crash info then make the app more stable, but turns out that the report is like this(dont even has a call stack,how am I suppose to use it?): The "Exception:...

Xcode crashes with divide by zero

I downloaded urlcache.zip from http://developer.apple.com/iphone/library/samplecode/URLCache/index.html#//apple_ref/doc/uid/DTS40008061 I opened the project in xcode and clicked on urlcacheconection....

热门标签