diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-11-18 02:20:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-11-18 02:20:56 +0300 |
commit | 94f0d18470fc454b456f711c9d040a7fef6780fb (patch) | |
tree | 77c3a62ac3f906a1517370351056e2fa4ebb598f /source/creator/creator.c | |
parent | 1e5d5085675afd1c3d6e0191e668449217f733ed (diff) |
BLI_assert: print a backtrace with the error
Add BLI_system_backtrace()
Diffstat (limited to 'source/creator/creator.c')
-rw-r--r-- | source/creator/creator.c | 70 |
1 files changed, 1 insertions, 69 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c index be03ffe0bda..f872398300a 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -48,13 +48,6 @@ # include "utfconv.h" #endif -/* for backtrace */ -#if defined(__linux__) || defined(__APPLE__) -# include <execinfo.h> -#elif defined(_MSV_VER) -# include <DbgHelp.h> -#endif - #include <stdlib.h> #include <stddef.h> #include <string.h> @@ -515,73 +508,12 @@ static int set_fpe(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(dat return 0; } -#if defined(__linux__) || defined(__APPLE__) - -/* Unix */ static void blender_crash_handler_backtrace(FILE *fp) { -#define SIZE 100 - void *buffer[SIZE]; - int nptrs; - char **strings; - int i; - fputs("\n# backtrace\n", fp); - - /* include a backtrace for good measure */ - nptrs = backtrace(buffer, SIZE); - strings = backtrace_symbols(buffer, nptrs); - for (i = 0; i < nptrs; i++) { - fputs(strings[i], fp); - fputc('\n', fp); - } - - free(strings); -#undef SIZE + BLI_system_backtrace(fp); } -#elif defined(_MSC_VER) - -static void blender_crash_handler_backtrace(FILE *fp) -{ - (void)fp; - -#if 0 -#define MAXSYMBOL 256 - unsigned short i; - void *stack[SIZE]; - unsigned short nframes; - SYMBOL_INFO *symbolinfo; - HANDLE process; - - process = GetCurrentProcess(); - - SymInitialize(process, NULL, true); - - nframes = CaptureStackBackTrace(0, SIZE, stack, NULL); - symbolinfo = MEM_callocN(sizeof(SYMBOL_INFO) + MAXSYMBOL * sizeof(char), "crash Symbol table"); - symbolinfo->MaxNameLen = MAXSYMBOL - 1; - symbolinfo->SizeOfStruct = sizeof(SYMBOL_INFO); - - for (i = 0; i < nframes; i++) { - SymFromAddr(process, ( DWORD64 )( stack[ i ] ), 0, symbolinfo); - - fprintf(fp, "%u: %s - 0x%0X\n", nframes - i - 1, symbolinfo->Name, symbolinfo->Address); - } - - MEM_freeN(symbolinfo); -#endif -} - -#else /* non msvc/osx/linux */ - -static void blender_crash_handler_backtrace(FILE *fp) -{ - (void)fp; -} - -#endif - static void blender_crash_handler(int signum) { |