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) 2015 VT MAK
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vlutil/vlMachineTypes.h>
13 
14 // Preprocessor Directive which allows reuse in MAK RTI applications and VR-Link based applications.
15 #ifdef DtUSE_UTILITIES_NAMESPACE
16 #define DtMiniDumper Dt ## MAKRti ## MiniDumper
17 #endif
18 
19 #ifdef WIN32
20 
21 #if _MSC_VER < 1300
22 # define DECLSPEC_DEPRECATED
23 // VC6: change this path to your Platform SDK headers
24 # include "M:\\dev7\\vs\\devtools\\common\\win32sdk\\include\\dbghelp.h" // must be XP version of file
25 #else
26 // VC7: ships with updated headers
27 #define _WINSOCKAPI_
28 #include <windows.h>
29 # include "dbghelp.h"
30 #endif
31 
32 // based on dbghelp.h
33 typedef BOOL (WINAPI* MINIDUMPWRITEDUMP)( HANDLE hProcess, DWORD dwPid, HANDLE hFile,
34  MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
35  CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
36  CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam );
37 
43 {
44 public:
45 
47  DtMiniDumper( const char* szAppName, bool promptUser = true );
48 
49 protected:
50 
53  static LONG WINAPI TopLevelFilter( struct _EXCEPTION_POINTERS* pExceptionInfo );
54 
55 protected:
56 
57  static char* m_szAppName;
58  static bool myPrompt;
59 
60 };
61 
62 #define DtINIT_MINIDUMPER( execName ) DtMiniDumper miniDump( execName );
63 #define DtINIT_MINIDUMPER_NO_PROMPT( execName ) DtMiniDumper miniDump( execName, false );
64 
65 #define DtSILENTLY_CRASH( unused ) \
66 { \
67  ::SetUnhandledExceptionFilter(0); \
68  SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); \
69 }
70 #else // WIN32
71 
72 #include <map>
73 #include <string>
74 #include <signal.h>
75 #include <execinfo.h>
76 #include <ucontext.h>
77 
83 {
84 public:
85 
87  static void printCallStack( int sig, siginfo_t* info, void* secret );
88 
89 protected:
90 
93  static void initializeAddressSpace();
94 
96  static void objFileAndNameFromStack( char* stackEntry,
97  std::string& objFile, std::string& objFileName );
98 
100  static std::string lookupFileInfo( const std::string& objFile,
101  unsigned long offset );
102 
103 private:
104 
106  DtMiniDumper();
107 
108 protected:
109 
111  typedef std::map<std::string,unsigned long> AddressSpaceMap;
112 
115 
116 };
117 
119 typedef void (*SigActionCb)( int, siginfo_t*, void* );
120 
121 #define DtINIT_MINIDUMPER( unused ) \
122 { \
123  struct sigaction sa; \
124  sa.sa_sigaction = (SigActionCb) DtMiniDumper::printCallStack; \
125  sa.sa_flags = SA_SIGINFO; \
126  sigemptyset( &sa.sa_mask ); \
127  sigaction( SIGSEGV, &sa, 0 ); \
128 }
129 
130 // TODO
131 #define DtINIT_MINIDUMPER_NO_PROMPT( unused ) \
132 { \
133  struct sigaction sa; \
134  sa.sa_sigaction = (SigActionCb) DtMiniDumper::printCallStack; \
135  sa.sa_flags = SA_SIGINFO; \
136  sigemptyset( &sa.sa_mask ); \
137  sigaction( SIGSEGV, &sa, 0 ); \
138 }
139 
140 // TODO
141 #define DtSILENTLY_CRASH( unused ) \
142 { \
143 }
144 #endif
void(* SigActionCb)(int, siginfo_t *, void *)
Definition: vlMiniDumper.h:119
This class contains the logic necesary for printing a stack trace.
Definition: vlMiniDumper.h:82
static AddressSpaceMap myAddressSpaceMap
Maps loaded object file names to base addresses in memory.
Definition: vlMiniDumper.h:114
std::map< std::string, unsigned long > AddressSpaceMap
Definition: vlMiniDumper.h:111
This file contains typedefs for machine dependant types.
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109

Document ID: Generated on Tue Aug 10 00:12:31 EDT 2021 from SVN revision 232765
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)