VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlMiniDumper.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2014 VT MAK
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 // Note that this class is based on Andy Pennel's work on Code Project's minidump.
11 // See http://codeplex.codeplex.com/license for more information
12 
13 #pragma once
14 
15 #ifdef WIN32
16 
17 #include <vlutil/vlMachineTypes.h>
18 
19 // Preprocessor Directive which allows reuse in MAK RTI applications and VR-Link based applications.
20 #ifdef DtUSE_UTILITIES_NAMESPACE
21 #define DtMiniDumper Dt ## MAKRti ## MiniDumper
22 #endif
23 
24 #if _MSC_VER < 1300
25 # define DECLSPEC_DEPRECATED
26 // VC6: change this path to your Platform SDK headers
27 # include "M:\\dev7\\vs\\devtools\\common\\win32sdk\\include\\dbghelp.h" // must be XP version of file
28 #else
29 // VC7: ships with updated headers
30 #define _WINSOCKAPI_
31 #include <windows.h>
32 # include "dbghelp.h"
33 #endif
34 
35 // based on dbghelp.h
36 typedef BOOL (WINAPI* MINIDUMPWRITEDUMP)( HANDLE hProcess, DWORD dwPid, HANDLE hFile,
37  MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
38  CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
39  CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam );
40 
41 class DT_DLL_VLUTIL DtMiniDumper
42 {
43 public:
44 
45  DtMiniDumper( const char* szAppName );
46 
47 private:
48 
49  static LONG WINAPI TopLevelFilter( struct _EXCEPTION_POINTERS* pExceptionInfo );
50 
51  static char* m_szAppName;
52 
53 };
54 
55 #define DtINIT_MINIDUMPER( execName ) DtMiniDumper miniDump( execName );
56 
57 #else // WIN32
58 
59 #include <stdio.h>
60 #include <execinfo.h>
61 #include <signal.h>
62 #include <stdlib.h>
63 
64 void DtErrorHandler( int sig )
65 {
66  void* array[50];
67  size_t size;
68 
69  // get void*'s for all entries on the stack
70  size = backtrace( array, 50 );
71 
72  // print out all the frames to stderr
73  fprintf( stderr, "Error: signal %d:\n", sig );
74  backtrace_symbols_fd( array, size, 2 );
75  exit( 1 );
76 }
77 
78 #define DtINIT_MINIDUMPER( unused ) signal( SIGSEGV, DtErrorHandler );
79 
80 #endif

Document ID: Generated on Fri May 15 06:36:13 EDT 2015 from SVN revision 153263
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)