use execinfo.h to get backtrace

Really poor backtrace because it will only have the frames from oc side,
I don't know why callStackSymbols is returning null, compilation flags?
pull/49/head
Jesús García Sáez 2014-03-04 16:40:41 +01:00 committed by Julio García
parent a77863947f
commit c6b8be742d
1 changed files with 12 additions and 1 deletions

View File

@ -49,6 +49,7 @@
#include <mapistore/mapistore.h>
#include <mapistore/mapistore_errors.h>
#include <execinfo.h>
static Class MAPIStoreContextK = Nil;
static BOOL leakDebugging = NO;
@ -69,8 +70,18 @@ sogo_backend_unexpected_error()
static enum mapistore_error
sogo_backend_handle_objc_exception(NSException *e, const char *fn_name, const int line_no)
{
NSLog(@"[SOGo: %s:%d] - EXCEPTION: %@, reason: %@, stackframe: %@",
NSLog(@"[SOGo: %s:%d] - EXCEPTION: %@, reason: %@, backtrace: %@",
fn_name, line_no, e.name, e.reason, [e callStackSymbols]);
if (![e callStackSymbols])
{
void *frames[128];
int i, len = backtrace(frames, 128);
char **symbols = backtrace_symbols(frames, len);
NSLog(@"Backtrace using execinfo.h:");
for (i = 0; i < len; ++i)
NSLog(@"\t%s", symbols[i]);
free(symbols);
}
if ([[e name] isEqual:@"NotImplementedException"])
{
return MAPISTORE_ERR_NOT_IMPLEMENTED;