From c6b8be742d1197ad24f0d1735db36892a6b4c1aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20S=C3=A1ez?= Date: Tue, 4 Mar 2014 16:40:41 +0100 Subject: [PATCH] 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? --- OpenChange/MAPIStoreSOGo.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/OpenChange/MAPIStoreSOGo.m b/OpenChange/MAPIStoreSOGo.m index dba78b5f1..97d1d7d7c 100644 --- a/OpenChange/MAPIStoreSOGo.m +++ b/OpenChange/MAPIStoreSOGo.m @@ -49,6 +49,7 @@ #include #include +#include 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;