I was able to log crashes using NSSetUncaughtExceptionHandler.
But I found it hard to log SIGTRAP crashes in the watchOS Extension app.
The code that I successfully used in iOS to log crashes doesn't work with the watchOS Extension app project.
#include
...
struct sigaction signalAction = {{0}};
signalAction.sa_flags = SA_SIGINFO | SA_ONSTACK;
sigemptyset(&signalAction.sa_mask);
signalAction.sa_sigaction = &handleCrash;
sigaction(SIGTRAP, &signalAction, NULL)
...
static void handleCrash(int sigNumber, siginfo_t* info, void* uContext) {
printf("signal - crash detected");
}
The above block of code works fine in iOS projects, when I tried the same in watchOS, handleCrash() static function is not executed.
The sigaction() function returns 0 in the watchOS project - which is a success criterion, but even then the handleCrash() function is not invoked when a SIGTRAP crash is thrown.
Any help in the right direction is appreciated.
Thanks a ton in advance.