diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /mp/src/utils/common/tools_minidump.cpp | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/utils/common/tools_minidump.cpp')
| -rw-r--r-- | mp/src/utils/common/tools_minidump.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/mp/src/utils/common/tools_minidump.cpp b/mp/src/utils/common/tools_minidump.cpp new file mode 100644 index 00000000..a0c84209 --- /dev/null +++ b/mp/src/utils/common/tools_minidump.cpp @@ -0,0 +1,61 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include <windows.h>
+#include <dbghelp.h>
+#include "tier0/minidump.h"
+#include "tools_minidump.h"
+
+static bool g_bToolsWriteFullMinidumps = false;
+static ToolsExceptionHandler g_pCustomExceptionHandler = NULL;
+
+
+// --------------------------------------------------------------------------------- //
+// Internal helpers.
+// --------------------------------------------------------------------------------- //
+
+static LONG __stdcall ToolsExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo )
+{
+ // Non VMPI workers write a minidump and show a crash dialog like normal.
+ int iType = MiniDumpNormal;
+ if ( g_bToolsWriteFullMinidumps )
+ iType = MiniDumpWithDataSegs | MiniDumpWithIndirectlyReferencedMemory;
+
+ WriteMiniDumpUsingExceptionInfo( ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo, (MINIDUMP_TYPE)iType );
+ return EXCEPTION_CONTINUE_SEARCH;
+}
+
+
+static LONG __stdcall ToolsExceptionFilter_Custom( struct _EXCEPTION_POINTERS *ExceptionInfo )
+{
+ // Run their custom handler.
+ g_pCustomExceptionHandler( ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo );
+ return EXCEPTION_EXECUTE_HANDLER; // (never gets here anyway)
+}
+
+
+// --------------------------------------------------------------------------------- //
+// Interface functions.
+// --------------------------------------------------------------------------------- //
+
+void EnableFullMinidumps( bool bFull )
+{
+ g_bToolsWriteFullMinidumps = bFull;
+}
+
+
+void SetupDefaultToolsMinidumpHandler()
+{
+ SetUnhandledExceptionFilter( ToolsExceptionFilter );
+}
+
+
+void SetupToolsMinidumpHandler( ToolsExceptionHandler fn )
+{
+ g_pCustomExceptionHandler = fn;
+ SetUnhandledExceptionFilter( ToolsExceptionFilter_Custom );
+}
|