Browse Source

Automatische Fehler speicherabbilder erzeugung hinzugefügt

kolja 6 years ago
parent
commit
a939647612
3 changed files with 33 additions and 2 deletions
  1. 1 1
      Model2D.cpp
  2. 3 1
      Vec2.h
  3. 29 0
      main.h

+ 1 - 1
Model2D.cpp

@@ -549,7 +549,7 @@ bool Model2DData::split( Vertex pos, Vertex dir, char *polygonName, Polygon2D &p
                             offset2 = ( point.x - pos.x ) / dir.x;
                         else
                             offset2 = ( point.y - pos.y ) / dir.y;
-                        if( needOne && min( abs( bo1 ), abs( bo1 - 1 ) ) + min( abs( bo2 ), bo2 - 1 ) > min( abs( offset1 ), abs( offset1 - 1 ) ) + min( abs( offset2 ), abs( offset2 - 1 ) ) )
+                        if( needOne && MIN( abs( bo1 ), abs( bo1 - 1 ) ) + MIN( abs( bo2 ), bo2 - 1 ) > MIN( abs( offset1 ), abs( offset1 - 1 ) ) + MIN( abs( offset2 ), abs( offset2 - 1 ) ) )
                         {
                             bo1 = offset1;
                             bo2 = offset2;

+ 3 - 1
Vec2.h

@@ -14,6 +14,8 @@ namespace Framework
         T y; // y Komponente des Vektors
         // Konstruktor
         inline Vec2()
+            : x( 0 ),
+              y( 0 )
         {}
         // Konstruktor
         //  x: X Komponente des Vektors
@@ -120,7 +122,7 @@ namespace Framework
         // Errechnet die Länge des Vektors
         inline T getLength() const
         {
-            return sqrt( getLengthSq() );
+            return (T)sqrt( getLengthSq() );
         }
         // Errechnet das Skalarprodukt zwischen zwei Vektoren
         //  r: Der andere Vektor

+ 29 - 0
main.h

@@ -13,6 +13,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <Windows.h>
+#include <DbgHelp.h>
 
 #define KSGStart __stdcall
 
@@ -37,10 +38,38 @@ namespace Framework
     __declspec( dllexport ) void releaseFramework();
 }
 
+typedef BOOL(WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
+
+void createMinidump(struct _EXCEPTION_POINTERS* apExceptionInfo)
+{
+	HMODULE mhLib = ::LoadLibrary("dbghelp.dll");
+	MINIDUMPWRITEDUMP pDump = (MINIDUMPWRITEDUMP)::GetProcAddress(mhLib, "MiniDumpWriteDump");
+
+	HANDLE  hFile = ::CreateFile("error_core_memory_dump.dmp", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
+		FILE_ATTRIBUTE_NORMAL, NULL);
+
+	_MINIDUMP_EXCEPTION_INFORMATION ExInfo;
+	ExInfo.ThreadId = ::GetCurrentThreadId();
+	ExInfo.ExceptionPointers = apExceptionInfo;
+	ExInfo.ClientPointers = FALSE;
+
+	pDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL);
+	::CloseHandle(hFile);
+}
+
+LONG WINAPI unhandledHandler(struct _EXCEPTION_POINTERS* apExceptionInfo)
+{
+	createMinidump(apExceptionInfo);
+	return EXCEPTION_CONTINUE_SEARCH;
+}
+
+
 int WINAPI WinMain( _In_ HINSTANCE hinst, _In_opt_ HINSTANCE hpinst, _In_ LPSTR cmd, int _In_ show )
 {
 #ifdef _DEBUG
     _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+#else
+	SetUnhandledExceptionFilter(unhandledHandler);
 #endif
     Framework::initFramework();
     Framework::Startparam stp;