]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/stackwalk.h
57eeca97610321940977b2ba2f50e278b85b195f
[wxWidgets.git] / include / wx / msw / stackwalk.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/stackwalk.h
3 // Purpose: wxStackWalker for MSW
4 // Author: Vadim Zeitlin
5 // Modified by: Suzumizaki-kimitaka 2013-04-09
6 // Created: 2005-01-08
7 // Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_MSW_STACKWALK_H_
12 #define _WX_MSW_STACKWALK_H_
13
14 #include "wx/arrstr.h"
15
16 // these structs are declared in windows headers
17 struct _CONTEXT;
18 struct _EXCEPTION_POINTERS;
19
20 // and these in dbghelp.h
21 struct _SYMBOL_INFO;
22 struct _SYMBOL_INFOW;
23
24 // ----------------------------------------------------------------------------
25 // wxStackFrame
26 // ----------------------------------------------------------------------------
27
28 class WXDLLIMPEXP_BASE wxStackFrame : public wxStackFrameBase
29 {
30 private:
31 wxStackFrame *ConstCast() const
32 { return const_cast<wxStackFrame *>(this); }
33
34 size_t DoGetParamCount() const { return m_paramTypes.GetCount(); }
35
36 public:
37 wxStackFrame(size_t level, void *address, size_t addrFrame)
38 : wxStackFrameBase(level, address)
39 {
40 m_hasName =
41 m_hasLocation = false;
42
43 m_addrFrame = addrFrame;
44 }
45
46 virtual size_t GetParamCount() const
47 {
48 ConstCast()->OnGetParam();
49 return DoGetParamCount();
50 }
51
52 virtual bool
53 GetParam(size_t n, wxString *type, wxString *name, wxString *value) const;
54
55 // callback used by OnGetParam(), don't call directly
56 #ifdef UNICODE
57 void OnParam(_SYMBOL_INFOW * pSymInfo);
58 #else
59 void OnParam(_SYMBOL_INFO * pSymInfo);
60 #endif
61
62 protected:
63 virtual void OnGetName();
64 virtual void OnGetLocation();
65
66 void OnGetParam();
67
68
69 // helper for debug API: it wants to have addresses as DWORDs
70 size_t GetSymAddr() const
71 {
72 return reinterpret_cast<size_t>(m_address);
73 }
74
75 private:
76 bool m_hasName,
77 m_hasLocation;
78
79 size_t m_addrFrame;
80
81 wxArrayString m_paramTypes,
82 m_paramNames,
83 m_paramValues;
84 };
85
86 // ----------------------------------------------------------------------------
87 // wxStackWalker
88 // ----------------------------------------------------------------------------
89
90 class WXDLLIMPEXP_BASE wxStackWalker : public wxStackWalkerBase
91 {
92 public:
93 // we don't use ctor argument, it is for compatibility with Unix version
94 // only
95 wxStackWalker(const char * WXUNUSED(argv0) = NULL) { }
96
97 virtual void Walk(size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
98 #if wxUSE_ON_FATAL_EXCEPTION
99 virtual void WalkFromException(size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
100 #endif // wxUSE_ON_FATAL_EXCEPTION
101
102
103 // enumerate stack frames from the given context
104 void WalkFrom(const _CONTEXT *ctx, size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
105 void WalkFrom(const _EXCEPTION_POINTERS *ep, size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
106 };
107
108 #endif // _WX_MSW_STACKWALK_H_
109