Reputation: 13918
In Mac OS, an application that causes a signal (through a null pointer exception or something similar) normally shows the standard Mac OS crash dialog, including a nice stack trace of where the signal happened. If you have the crash report, this makes it easy for you to find out where the problem occurred in your code and fix it.
This stack trace is easy to look up and figure out where the execution was where it crashed.
However, the standard Mac OS crash report prompts the user to send it to Apple, which is not useful because users will just press the button and assume we got the crash report when in fact we didn't. I want to instead show my own crash report with stack trace that tells the user to email it to me instead, or auto-submits it to a web form, or something similar.
How can I get the stack trace for a signal like this? I've tried the following:
Installed uncaught exception handler - no change, I still get the regular Mac OS crash dialog.
@try / @catch around the program - no change, I still get the regular Mac OS crash dialog.
Install signal handlers using signal() that throw an exception when called - I can catch the exception and get the call stack from it, but the stack trace shows the signal handler and is less helpful than the stack trace I see in the Mac OS error, above.
The line numbered 3 in this image is where the signal handler is called - it doesn't give the same stack trace as the standard crash report, even if you ignore the obvious "here's where I'm throwing an exception" bit.
How can I duplicate the behavior of the standard crash report where it gives me the call stack from which the signal was generated?
Upvotes: 3
Views: 2832
Reputation: 6161
I highly recommend PLCrashReporter. It handles uncaught exceptions and fatal signals and generates a crash report similar to the one you see in the Apple crash dialog. There are various services you can pay to do the analytics of the crashes (group by version and common callstack). Or you can run a server yourself. One open source service is QuicyKit.
Upvotes: 3