Merge pull request #342 from Pan7/MiniDump

MiniDump for msvc
This commit is contained in:
Timothee "TTimo" Besset 2016-04-23 15:58:37 -05:00
commit b60ab94a52
2 changed files with 75 additions and 5 deletions

View file

@ -414,7 +414,7 @@ void error_redirect( const gchar *domain, GLogLevelFlags log_level, const gchar
#define GETTEXT_PACKAGE "radiant"
#define LOCALEDIR "lang"
int main( int argc, char* argv[] ) {
int mainRadiant( int argc, char* argv[] ) {
const char *libgl;
int i, j, k;
@ -923,6 +923,76 @@ int main( int argc, char* argv[] ) {
return 0;
}
#if defined( _WIN32 ) && defined( _MSC_VER )
#include <dbghelp.h>
#include <shellapi.h>
#include <shlobj.h>
#include <strsafe.h> //StringCchPrintf
int GenerateDump( EXCEPTION_POINTERS* pExceptionPointers ) {
BOOL bMiniDumpSuccessful;
char szPath[MAX_PATH];
char szFileName[MAX_PATH];
char szAppName[] = "GTKRadiant";
char* szVersion = RADIANT_VERSION;
DWORD dwBufferSize = MAX_PATH;
HANDLE hDumpFile;
SYSTEMTIME stLocalTime;
MINIDUMP_EXCEPTION_INFORMATION ExpParam;
GetLocalTime( &stLocalTime );
GetTempPath( dwBufferSize, szPath );
StringCchPrintf( szFileName, MAX_PATH, "%s%s", szPath, szAppName );
CreateDirectory( szFileName, NULL );
StringCchPrintf( szFileName, MAX_PATH, "%s%s\\%s-%s-%04d%02d%02d-%02d%02d%02d.dmp",
szPath, szAppName, szAppName, szVersion,
stLocalTime.wYear, stLocalTime.wMonth, stLocalTime.wDay,
stLocalTime.wHour, stLocalTime.wMinute, stLocalTime.wSecond );
hDumpFile = CreateFile(szFileName, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_WRITE|FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
ExpParam.ThreadId = GetCurrentThreadId();
ExpParam.ExceptionPointers = pExceptionPointers;
ExpParam.ClientPointers = TRUE;
bMiniDumpSuccessful = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
hDumpFile, MiniDumpWithDataSegs, &ExpParam, NULL, NULL);
return EXCEPTION_EXECUTE_HANDLER;
}
#endif
int main( int argc, char* argv[] ) {
#if defined( _WIN32 ) && defined( _MSC_VER )
__try {
return mainRadiant( argc, argv );
} __except( GenerateDump( GetExceptionInformation() ) ) {
char szPath[MAX_PATH];
char szText[MAX_PATH];
char szFileName[MAX_PATH];
char szAppName[] = "GTKRadiant";
SYSTEMTIME stLocalTime;
DWORD dwBufferSize = MAX_PATH;
GetLocalTime( &stLocalTime );
GetTempPath( dwBufferSize, szPath );
StringCchPrintf( szFileName, MAX_PATH, "%s%s", szPath, szAppName );
StringCchPrintf( szText, MAX_PATH, _("Application crashed!\nCreated a dump file in: \n%s"), szFileName );
MessageBox( NULL, szText, NULL, MB_ICONERROR );
}
#else
return mainRadiant( argc, argv );
#endif
}
// ydnar: quick and dirty fix, just make the buffer bigger
#define BIG_PATH_MAX 4096

View file

@ -84,7 +84,7 @@
</ClCompile>
<Link>
<AdditionalOptions>/STACK:8388608 %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>Ws2_32.lib;glib-2.0.lib;gobject-2.0.lib;intl.lib;gtk-win32-2.0.lib;gdk-win32-2.0.lib;pango-1.0.lib;pangoft2-1.0.lib;gdkglext-win32-1.0.lib;gtkglext-win32-1.0.lib;libxml2_a.lib;mathlib.lib;synapse.lib;l_net.lib;cmdlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Ws2_32.lib;glib-2.0.lib;gobject-2.0.lib;intl.lib;gtk-win32-2.0.lib;gdk-win32-2.0.lib;pango-1.0.lib;pangoft2-1.0.lib;gdkglext-win32-1.0.lib;gtkglext-win32-1.0.lib;libxml2_a.lib;mathlib.lib;synapse.lib;l_net.lib;cmdlib.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\..\gtk-2.24.10\lib;$(SolutionDir)\..\libxml2-2.9.2/win32/bin.msvc;$(SolutionDir)\..\gtkglext-1.2.0\lib;$(SolutionDir)\build\$(Configuration)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
@ -106,7 +106,7 @@
</ClCompile>
<Link>
<AdditionalOptions>/STACK:8388608 %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>Ws2_32.lib;glib-2.0.lib;gobject-2.0.lib;intl.lib;gtk-win32-2.0.lib;gdk-win32-2.0.lib;pango-1.0.lib;pangoft2-1.0.lib;gdkglext-win32-1.0.lib;gtkglext-win32-1.0.lib;libxml2_a.lib;mathlib.lib;synapse.lib;l_net.lib;cmdlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Ws2_32.lib;glib-2.0.lib;gobject-2.0.lib;intl.lib;gtk-win32-2.0.lib;gdk-win32-2.0.lib;pango-1.0.lib;pangoft2-1.0.lib;gdkglext-win32-1.0.lib;gtkglext-win32-1.0.lib;libxml2_a.lib;mathlib.lib;synapse.lib;l_net.lib;cmdlib.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\..\gtk-2.24.10\lib;$(SolutionDir)\..\libxml2-2.9.2/win32/bin.msvc;$(SolutionDir)\..\gtkglext-1.2.0\lib;$(SolutionDir)\build\$(Configuration)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
@ -124,7 +124,7 @@
</ClCompile>
<Link>
<AdditionalOptions>/STACK:8388608 %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>Ws2_32.lib;glib-2.0.lib;gobject-2.0.lib;intl.lib;gtk-win32-2.0.lib;gdk-win32-2.0.lib;pango-1.0.lib;pangoft2-1.0.lib;gdkglext-win32-1.0.lib;gtkglext-win32-1.0.lib;libxml2_a.lib;mathlib.lib;synapse.lib;l_net.lib;cmdlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Ws2_32.lib;glib-2.0.lib;gobject-2.0.lib;intl.lib;gtk-win32-2.0.lib;gdk-win32-2.0.lib;pango-1.0.lib;pangoft2-1.0.lib;gdkglext-win32-1.0.lib;gtkglext-win32-1.0.lib;libxml2_a.lib;mathlib.lib;synapse.lib;l_net.lib;cmdlib.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\..\gtk-2.24.10\lib;$(SolutionDir)\..\libxml2-2.9.2/win32/bin.msvc;$(SolutionDir)\..\gtkglext-1.2.0\lib;$(SolutionDir)\build\$(Configuration)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
@ -146,7 +146,7 @@
</ClCompile>
<Link>
<AdditionalOptions>/STACK:8388608 %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>Ws2_32.lib;glib-2.0.lib;gobject-2.0.lib;intl.lib;gtk-win32-2.0.lib;gdk-win32-2.0.lib;pango-1.0.lib;pangoft2-1.0.lib;gdkglext-win32-1.0.lib;gtkglext-win32-1.0.lib;libxml2_a.lib;mathlib.lib;synapse.lib;l_net.lib;cmdlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Ws2_32.lib;glib-2.0.lib;gobject-2.0.lib;intl.lib;gtk-win32-2.0.lib;gdk-win32-2.0.lib;pango-1.0.lib;pangoft2-1.0.lib;gdkglext-win32-1.0.lib;gtkglext-win32-1.0.lib;libxml2_a.lib;mathlib.lib;synapse.lib;l_net.lib;cmdlib.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\..\gtk-2.24.10\lib;$(SolutionDir)\..\libxml2-2.9.2/win32/bin.msvc;$(SolutionDir)\..\gtkglext-1.2.0\lib;$(SolutionDir)\build\$(Configuration)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>