FS2_Open
Open source remastering of the Freespace 2 engine
mspdb_callstack.h
Go to the documentation of this file.
1 /* This file contains debugging utilities used only under VC2005+
2  * Maintained by: portej05 (please run patches past him before committing here!)
3  */
4 
5 /* You will need to define PDB_DEBUGGING in order to use these functions
6  * Important note:
7  * When you call SCP_DumpStack, your thread will be suspended until the stack is dumped
8  * If you've got more than a single thread
9  */
10 
11 /* Things you should be using from this header
12  * SCP_IDumpHandler - implement this in order to receive symbols from DumpStack
13  */
14 
15 #ifndef _MSPDB_CALLSTACK_H_INCLUDED_
16 #define _MSPDB_CALLSTACK_H_INCLUDED_
17 
18 #if defined(PDB_DEBUGGING)
19 
20 /* Must have windows.h */
21 #include <windows.h>
22 
23 #ifndef PURE
24 # define PURE = 0
25 #endif
26 
27 /* PUBLIC - use these */
28 
29 /* This interface will be used by the stack tracing code
30  * to return symbols
31  */
32 class SCP_IDumpHandler abstract
33 {
34 public:
35  virtual bool ResolveSymbols( ) PURE;
36  virtual void OnBegin( ) PURE;
37  virtual void OnEntry( void* address, const char* module, const char* symbol ) PURE;
38  virtual void OnError( const char* error ) PURE;
39  virtual void OnEnd( ) PURE;
40 };
41 
42 extern HRESULT SCP_DumpStack( SCP_IDumpHandler* pISH );
43 
44 /* INTERNAL - please don't use these */
45 #define SCP_MSPDBCS_MAX_SYMBOL_LENGTH 1000
46 #define SCP_MSPDBCS_MAX_MODULE_LENGTH _MAX_PATH
47 #define SCP_MSPDBCS_MAX_STACK_FRAMES 100 /* arbitrary */
48 
49 struct SCP_mspdbcs_SDumpStackThreadInfo
50 {
51  HANDLE hThread;
52  HANDLE hProcess;
53  SCP_IDumpHandler* pIDS;
54 };
55 
56 struct SCP_mspdbcs_SDumpStackSymbolInfo
57 {
58  ULONG_PTR dwAddress;
59  DWORD64 dwOffset; /* Will be truncated to DWORD under Win32 */
60  char szModule[ SCP_MSPDBCS_MAX_MODULE_LENGTH ];
61  char szSymbol[ SCP_MSPDBCS_MAX_SYMBOL_LENGTH ];
62 };
63 
64 /* INTERNAL FUNCTIONS */
65 extern BOOL SCP_mspdbcs_ResolveSymbol( HANDLE hProcess, UINT_PTR dwAddress, SCP_mspdbcs_SDumpStackThreadInfo& siSymbol );
66 extern LPVOID __stdcall SCP_mspdbcs_FunctionTableAccess( HANDLE hProcess, DWORD64 dwPCAddress );
67 extern DWORD64 __stdcall SCP_mspdbcs_GetModuleBase( HANDLE hProcess, DWORD64 returnAddress );
68 extern DWORD WINAPI SCP_mspdbcs_DumpStackThread( LPVOID pv );
69 
70 #endif // PDB_DEBUGGING
71 
72 /* Initialisation */
73 extern void SCP_mspdbcs_Initialise( );
74 extern void SCP_mspdbcs_Cleanup( );
75 
76 #endif // _MSPDB_CALLSTACK_H_INCLUDED_
#define WINAPI
Definition: config.h:76
void SCP_mspdbcs_Cleanup()
unsigned long DWORD
Definition: config.h:90
long HRESULT
Definition: vddraw.h:115
int BOOL
Definition: config.h:80
void SCP_mspdbcs_Initialise()
typedef LPVOID
Definition: vddraw.h:119
#define __stdcall
Definition: config.h:73
void * HANDLE
Definition: config.h:106
GLuint address
Definition: Glext.h:8864