From 4455a1643dab180c7ddc3bcce7ccae6763137dae Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 23 Feb 2012 11:37:53 +0000 Subject: Added cmdline parameters "/cdg" and "/cdf" for crashdump flags "globals" and "full memory" git-svn-id: http://mc-server.googlecode.com/svn/trunk@322 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/main.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/main.cpp b/source/main.cpp index c84980853..f19a88210 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -73,7 +73,7 @@ pMiniDumpWriteDump g_WriteMiniDump; // The function in dbghlp DLL that creates char g_DumpFileName[MAX_PATH]; // Filename of the dump file; hes to be created before the dump handler kicks in char g_ExceptionStack[128 * 1024]; // Substitute stack, just in case the handler kicks in because of "insufficient stack space" -MINIDUMP_TYPE DumpFlags = MiniDumpNormal; // By default dump only the stack and some helpers +MINIDUMP_TYPE g_DumpFlags = MiniDumpNormal; // By default dump only the stack and some helpers @@ -102,7 +102,7 @@ LONG WINAPI LastChanceExceptionFilter(__in struct _EXCEPTION_POINTERS * a_Except // Write the dump file: HANDLE dumpFile = CreateFile(g_DumpFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - g_WriteMiniDump(GetCurrentProcess(), GetCurrentProcessId(), dumpFile, DumpFlags, (a_ExceptionInfo) ? &ExcInformation : NULL, NULL, NULL); + g_WriteMiniDump(GetCurrentProcess(), GetCurrentProcessId(), dumpFile, g_DumpFlags, (a_ExceptionInfo) ? &ExcInformation : NULL, NULL, NULL); CloseHandle(dumpFile); // Revert to old stack: @@ -139,6 +139,21 @@ int main( int argc, char **argv ) { _snprintf_s(g_DumpFileName, ARRAYCOUNT(g_DumpFileName), _TRUNCATE, "crash_mcs_%x.dmp", GetCurrentProcessId()); SetUnhandledExceptionFilter(LastChanceExceptionFilter); + + // Parse arguments for minidump flags: + for (int i = 0; i < argc; i++) + { + if (stricmp(argv[i], "/cdg") == 0) + { + // Add globals to the dump + g_DumpFlags = (MINIDUMP_TYPE)(g_DumpFlags | MiniDumpWithDataSegs); + } + else if (stricmp(argv[i], "/cdf") == 0) + { + // Add full memory to the dump (HUUUGE file) + g_DumpFlags = (MINIDUMP_TYPE)(g_DumpFlags | MiniDumpWithFullMemory); + } + } // for i - argv[] } #endif // _WIN32 && !_WIN64 // End of dump-file magic -- cgit v1.2.3