diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-03-03 15:39:15 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-03-03 15:39:15 +0300 |
commit | d58a15c0a603a83a416f84def21d5603653e3cba (patch) | |
tree | bf925292c812b13f9f7d1bb3080cca17c4dcc8d0 /source/blender/blenlib/intern/system.c | |
parent | b42a3d24853195150130df513353c034ac528933 (diff) |
Windows: Add stacktrace support when unhandled exception occurs.
We need to register the exception handler slightly differently here, as
well as adding DbgHelp as a library, but according to docs it should be
supported in recent Windows editions (Win XP included even).
We can try it first and revert if there are issues.
Diffstat (limited to 'source/blender/blenlib/intern/system.c')
-rw-r--r-- | source/blender/blenlib/intern/system.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c index d83077e0e78..b6b0f14a4e2 100644 --- a/source/blender/blenlib/intern/system.c +++ b/source/blender/blenlib/intern/system.c @@ -27,10 +27,13 @@ #include "BLI_system.h" +#include "MEM_guardedalloc.h" + /* for backtrace */ #if defined(__linux__) || defined(__APPLE__) # include <execinfo.h> -#elif defined(_MSV_VER) +#elif defined(WIN32) +# include <windows.h> # include <DbgHelp.h> #endif @@ -97,17 +100,18 @@ void BLI_system_backtrace(FILE *fp) #elif defined(_MSC_VER) (void)fp; -#if 0 +#if defined WIN32 #define MAXSYMBOL 256 - unsigned short i; +#define SIZE 100 + unsigned short i; void *stack[SIZE]; unsigned short nframes; - SYMBOL_INFO *symbolinfo; + SYMBOL_INFO *symbolinfo; HANDLE process; process = GetCurrentProcess(); - SymInitialize(process, NULL, true); + SymInitialize(process, NULL, TRUE); nframes = CaptureStackBackTrace(0, SIZE, stack, NULL); symbolinfo = MEM_callocN(sizeof(SYMBOL_INFO) + MAXSYMBOL * sizeof(char), "crash Symbol table"); @@ -122,6 +126,7 @@ void BLI_system_backtrace(FILE *fp) MEM_freeN(symbolinfo); #undef MAXSYMBOL +#undef SIZE #endif /* ------------------ */ |