[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53772] trunk/blender/source/creator/ creator.c: Add terminate call for crash handler for windows.

Antony Riakiotakis kalast at gmail.com
Sun Jan 13 16:01:39 CET 2013


Revision: 53772
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53772
Author:   psy-fi
Date:     2013-01-13 15:01:34 +0000 (Sun, 13 Jan 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/creator/creator.c

Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c	2013-01-13 14:52:31 UTC (rev 53771)
+++ trunk/blender/source/creator/creator.c	2013-01-13 15:01:34 UTC (rev 53772)
@@ -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 void blender_crash_handler_backtrace(FILE *fp)
 {
+#define SIZE 100
 #ifndef WIN32
-#define SIZE 100
 	void *buffer[SIZE];
 	int nptrs;
 	char **strings;
@@ -464,12 +467,38 @@
 	}
 
 	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 @@
 #ifndef WIN32
 	kill(getpid(), signum);
 #else
-	/* force crash on windows for now */
-	*((void **)NULL) = NULL;
+	TerminateProcess(GetCurrentProcess(), signum);
 #endif
 }
 




More information about the Bf-blender-cvs mailing list