/[pcsx2_0.9.7]/trunk/3rdparty/wxWidgets/include/wx/msw/debughlp.h
ViewVC logotype

Contents of /trunk/3rdparty/wxWidgets/include/wx/msw/debughlp.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (show annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (9 years, 10 months ago) by william
File MIME type: text/plain
File size: 8863 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/wrapdbgh.h
3 // Purpose: wraps dbghelp.h standard file
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 2005-01-08 (extracted from msw/crashrpt.cpp)
7 // RCS-ID: $Id: debughlp.h 31443 2005-01-18 10:10:23Z ABX $
8 // Copyright: (c) 2003-2005 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MSW_DEBUGHLPH_H_
13 #define _WX_MSW_DEBUGHLPH_H_
14
15 #include "wx/dynlib.h"
16
17 #include "wx/msw/wrapwin.h"
18 #ifndef __WXWINCE__
19 #include <imagehlp.h>
20 #endif // __WXWINCE__
21 #include "wx/msw/private.h"
22
23 // we need to determine whether we have the declarations for the function in
24 // debughlp.dll version 5.81 (at least) and we check for DBHLPAPI to test this
25 //
26 // reasons:
27 // - VC6 version of imagehlp.h doesn't define it
28 // - VC7 one does
29 // - testing for compiler version doesn't work as you can install and use
30 // the new SDK headers with VC6
31 //
32 // in any case, the user may override by defining wxUSE_DBGHELP himself
33 #ifndef wxUSE_DBGHELP
34 #ifdef DBHLPAPI
35 #define wxUSE_DBGHELP 1
36 #else
37 #define wxUSE_DBGHELP 0
38 #endif
39 #endif
40
41 #if wxUSE_DBGHELP
42
43 // ----------------------------------------------------------------------------
44 // wxDbgHelpDLL: dynamically load dbghelp.dll functions
45 // ----------------------------------------------------------------------------
46
47 // wrapper for some functions from dbghelp.dll
48 //
49 // MT note: this class is not MT safe and should be only used from a single
50 // thread at a time (this is so because dbghelp.dll is not MT-safe
51 // itself anyhow)
52 class wxDbgHelpDLL
53 {
54 public:
55 // some useful constants not present in debughlp.h (stolen from DIA SDK)
56 enum BasicType
57 {
58 BASICTYPE_NOTYPE = 0,
59 BASICTYPE_VOID = 1,
60 BASICTYPE_CHAR = 2,
61 BASICTYPE_WCHAR = 3,
62 BASICTYPE_INT = 6,
63 BASICTYPE_UINT = 7,
64 BASICTYPE_FLOAT = 8,
65 BASICTYPE_BCD = 9,
66 BASICTYPE_BOOL = 10,
67 BASICTYPE_LONG = 13,
68 BASICTYPE_ULONG = 14,
69 BASICTYPE_CURRENCY = 25,
70 BASICTYPE_DATE = 26,
71 BASICTYPE_VARIANT = 27,
72 BASICTYPE_COMPLEX = 28,
73 BASICTYPE_BIT = 29,
74 BASICTYPE_BSTR = 30,
75 BASICTYPE_HRESULT = 31,
76 BASICTYPE_MAX
77 };
78
79 enum SymbolTag
80 {
81 SYMBOL_TAG_NULL,
82 SYMBOL_TAG_EXE,
83 SYMBOL_TAG_COMPILAND,
84 SYMBOL_TAG_COMPILAND_DETAILS,
85 SYMBOL_TAG_COMPILAND_ENV,
86 SYMBOL_TAG_FUNCTION,
87 SYMBOL_TAG_BLOCK,
88 SYMBOL_TAG_DATA,
89 SYMBOL_TAG_ANNOTATION,
90 SYMBOL_TAG_LABEL,
91 SYMBOL_TAG_PUBLIC_SYMBOL,
92 SYMBOL_TAG_UDT,
93 SYMBOL_TAG_ENUM,
94 SYMBOL_TAG_FUNCTION_TYPE,
95 SYMBOL_TAG_POINTER_TYPE,
96 SYMBOL_TAG_ARRAY_TYPE,
97 SYMBOL_TAG_BASE_TYPE,
98 SYMBOL_TAG_TYPEDEF,
99 SYMBOL_TAG_BASE_CLASS,
100 SYMBOL_TAG_FRIEND,
101 SYMBOL_TAG_FUNCTION_ARG_TYPE,
102 SYMBOL_TAG_FUNC_DEBUG_START,
103 SYMBOL_TAG_FUNC_DEBUG_END,
104 SYMBOL_TAG_USING_NAMESPACE,
105 SYMBOL_TAG_VTABLE_SHAPE,
106 SYMBOL_TAG_VTABLE,
107 SYMBOL_TAG_CUSTOM,
108 SYMBOL_TAG_THUNK,
109 SYMBOL_TAG_CUSTOM_TYPE,
110 SYMBOL_TAG_MANAGED_TYPE,
111 SYMBOL_TAG_DIMENSION,
112 SYMBOL_TAG_MAX
113 };
114
115 enum DataKind
116 {
117 DATA_UNKNOWN,
118 DATA_LOCAL,
119 DATA_STATIC_LOCAL,
120 DATA_PARAM,
121 DATA_OBJECT_PTR, // "this" pointer
122 DATA_FILE_STATIC,
123 DATA_GLOBAL,
124 DATA_MEMBER,
125 DATA_STATIC_MEMBER,
126 DATA_CONSTANT,
127 DATA_MAX
128 };
129
130 enum UdtKind
131 {
132 UDT_STRUCT,
133 UDT_CLASS,
134 UDT_UNION,
135 UDT_MAX
136 };
137
138
139 // function types
140 typedef DWORD (WINAPI *SymGetOptions_t)();
141 typedef DWORD (WINAPI *SymSetOptions_t)(DWORD);
142 typedef BOOL (WINAPI *SymInitialize_t)(HANDLE, LPSTR, BOOL);
143 typedef BOOL (WINAPI *SymRefreshModuleList_t)(HANDLE);
144 typedef BOOL (WINAPI *StackWalk_t)(DWORD, HANDLE, HANDLE, LPSTACKFRAME,
145 LPVOID, PREAD_PROCESS_MEMORY_ROUTINE,
146 PFUNCTION_TABLE_ACCESS_ROUTINE,
147 PGET_MODULE_BASE_ROUTINE,
148 PTRANSLATE_ADDRESS_ROUTINE);
149 typedef BOOL (WINAPI *SymFromAddr_t)(HANDLE, DWORD64, PDWORD64, PSYMBOL_INFO);
150 typedef LPVOID (WINAPI *SymFunctionTableAccess_t)(HANDLE, DWORD);
151 typedef DWORD (WINAPI *SymGetModuleBase_t)(HANDLE, DWORD);
152 typedef BOOL (WINAPI *SymGetLineFromAddr_t)(HANDLE, DWORD,
153 PDWORD, PIMAGEHLP_LINE);
154 typedef BOOL (WINAPI *SymSetContext_t)(HANDLE, PIMAGEHLP_STACK_FRAME,
155 PIMAGEHLP_CONTEXT);
156 typedef BOOL (WINAPI *SymEnumSymbols_t)(HANDLE, ULONG64, PCSTR,
157 PSYM_ENUMERATESYMBOLS_CALLBACK, PVOID);
158 typedef BOOL (WINAPI *SymGetTypeInfo_t)(HANDLE, DWORD64, ULONG,
159 IMAGEHLP_SYMBOL_TYPE_INFO, PVOID);
160 typedef BOOL (WINAPI *SymCleanup_t)(HANDLE);
161 typedef BOOL (WINAPI *EnumerateLoadedModules_t)(HANDLE, PENUMLOADED_MODULES_CALLBACK, PVOID);
162 typedef BOOL (WINAPI *MiniDumpWriteDump_t)(HANDLE, DWORD, HANDLE,
163 MINIDUMP_TYPE,
164 CONST PMINIDUMP_EXCEPTION_INFORMATION,
165 CONST PMINIDUMP_USER_STREAM_INFORMATION,
166 CONST PMINIDUMP_CALLBACK_INFORMATION);
167
168 #define wxDO_FOR_ALL_SYM_FUNCS(what) \
169 what(SymGetOptions); \
170 what(SymSetOptions); \
171 what(SymInitialize); \
172 what(StackWalk); \
173 what(SymFromAddr); \
174 what(SymFunctionTableAccess); \
175 what(SymGetModuleBase); \
176 what(SymGetLineFromAddr); \
177 what(SymSetContext); \
178 what(SymEnumSymbols); \
179 what(SymGetTypeInfo); \
180 what(SymCleanup); \
181 what(EnumerateLoadedModules); \
182 what(MiniDumpWriteDump)
183
184 #define wxDECLARE_SYM_FUNCTION(func) static func ## _t func
185
186 wxDO_FOR_ALL_SYM_FUNCS(wxDECLARE_SYM_FUNCTION);
187
188 // load all functions from DLL, return true if ok
189 static bool Init();
190
191 // *PCSX2* Should be called before performing a stack trace, as apps may load/unload plugins during
192 // program execution.
193 static bool RefreshModuleList(HANDLE hProcess);
194
195 // return the string with the error message explaining why Init() failed
196 static const wxString& GetErrorMessage();
197
198 // log error returned by the given function to debug output
199 static void LogError(const wxChar *func);
200
201 // return textual representation of the value of given symbol
202 static wxString DumpSymbol(PSYMBOL_INFO pSymInfo, void *pVariable);
203
204 // return the name of the symbol with given type index
205 static wxString GetSymbolName(PSYMBOL_INFO pSymInfo);
206
207 private:
208 // Declared separately since it requires an especially new version of WinDbgHlp
209 // (v6.5 or later).
210 wxDECLARE_SYM_FUNCTION(SymRefreshModuleList);
211
212 static bool DoInit();
213
214 static bool BindFunctions(const wxDynamicLibrary& dllDbgHelp);
215
216 // dereference the given symbol, i.e. return symbol which is not a
217 // pointer/reference any more
218 //
219 // if ppData != NULL, dereference the pointer as many times as we
220 // dereferenced the symbol
221 //
222 // return the tag of the dereferenced symbol
223 static SymbolTag DereferenceSymbol(PSYMBOL_INFO pSymInfo, void **ppData);
224
225 static wxString DumpField(PSYMBOL_INFO pSymInfo,
226 void *pVariable,
227 unsigned level);
228
229 static wxString DumpBaseType(BasicType bt, DWORD64 length, void *pVariable);
230
231 static wxString DumpUDT(PSYMBOL_INFO pSymInfo,
232 void *pVariable,
233 unsigned level = 0);
234 };
235
236 #undef wxDECLARE_SYM_FUNCTION
237
238 #endif // wxUSE_DBGHELP
239
240 #endif // _WX_MSW_DEBUGHLPH_H_
241

  ViewVC Help
Powered by ViewVC 1.1.22