Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2013-01-13 19:01:34 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-01-13 19:01:34 +0400
commit4f938bbbfe6e1a5d57e98e60c37c47582d904dc1 (patch)
treeaf8c3fa49419a71c1561a1d077051de80e879056 /source/creator
parentf561fb5e7afe18a22a98d9fbad34c06d86bc3d39 (diff)
Add terminate call for crash handler for windows. Also add inactive code
to do backtrace flushing. This code will need DbgHelp.lib which we may want to only include for debug builds if at all.
Diffstat (limited to 'source/creator')
-rw-r--r--source/creator/creator.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 70123187721..68a4866a381 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -46,16 +46,19 @@
#else
# include <unistd.h> /* getpid */
#endif
-/* for backtrace */
-#ifndef WIN32
-# include <execinfo.h>
-#endif
#ifdef WIN32
# include <Windows.h>
# include "utfconv.h"
#endif
+/* for backtrace */
+#ifdef WIN32
+# include <DbgHelp.h>
+#else
+# include <execinfo.h>
+#endif
+
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
@@ -446,8 +449,8 @@ static int set_fpe(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(dat
static void blender_crash_handler_backtrace(FILE *fp)
{
-#ifndef WIN32
#define SIZE 100
+#ifndef WIN32
void *buffer[SIZE];
int nptrs;
char **strings;
@@ -464,12 +467,38 @@ static void blender_crash_handler_backtrace(FILE *fp)
}
free(strings);
-#undef SIZE
-#else /* WIN32 */
- /* TODO */
+#else /* WIN32 */
(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
+#endif
+#undef SIZE
}
+
static void blender_crash_handler(int signum)
{
@@ -534,8 +563,7 @@ static void blender_crash_handler(int signum)
#ifndef WIN32
kill(getpid(), signum);
#else
- /* force crash on windows for now */
- *((void **)NULL) = NULL;
+ TerminateProcess(GetCurrentProcess(), signum);
#endif
}