]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/stackwalk.h
b003181bc880aefb5f430da3824bd0d6e3c67a2a
[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:
6 // Created: 2005-01-08
7 // RCS-ID: $Id$
8 // Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MSW_STACKWALK_H_
13 #define _WX_MSW_STACKWALK_H_
14
15 // these structs are declared in windows headers
16 struct _CONTEXT;
17 struct _EXCEPTION_POINTERS;
18
19 // and these in dbghelp.h
20 struct _SYMBOL_INFO;
21
22 // ----------------------------------------------------------------------------
23 // wxStackFrame
24 // ----------------------------------------------------------------------------
25
26 class WXDLLIMPEXP_BASE wxStackFrame : public wxStackFrameBase
27 {
28 private:
29 wxStackFrame *ConstCast() const
30 { return wx_const_cast(wxStackFrame *, this); }
31
32 size_t DoGetParamCount() const { return m_paramTypes.GetCount(); }
33
34 public:
35 wxStackFrame(size_t level, void *address, size_t addrFrame)
36 : wxStackFrameBase(level, address)
37 {
38 m_hasName =
39 m_hasLocation = false;
40
41 m_addrFrame = addrFrame;
42 }
43
44 virtual size_t GetParamCount() const
45 {
46 ConstCast()->OnGetParam();
47 return DoGetParamCount();
48 }
49
50 virtual bool
51 GetParam(size_t n, wxString *type, wxString *name, wxString *value) const;
52
53 // callback used by OnGetParam(), don't call directly
54 void OnParam(_SYMBOL_INFO *pSymInfo);
55
56 protected:
57 virtual void OnGetName();
58 virtual void OnGetLocation();
59
60 void OnGetParam();
61
62
63 // helper for debug API: it wants to have addresses as DWORDs
64 size_t GetSymAddr() const
65 {
66 return wx_reinterpret_cast(size_t, m_address);
67 }
68
69 private:
70 bool m_hasName,
71 m_hasLocation;
72
73 size_t m_addrFrame;
74
75 wxArrayString m_paramTypes,
76 m_paramNames,
77 m_paramValues;
78 };
79
80 // ----------------------------------------------------------------------------
81 // wxStackWalker
82 // ----------------------------------------------------------------------------
83
84 class WXDLLIMPEXP_BASE wxStackWalker : public wxStackWalkerBase
85 {
86 public:
87 wxStackWalker() { }
88
89 virtual void Walk(size_t skip = 1);
90 virtual void WalkFromException();
91
92
93 // enumerate stack frames from the given context
94 void WalkFrom(const _CONTEXT *ctx, size_t skip = 1);
95 void WalkFrom(const _EXCEPTION_POINTERS *ep, size_t skip = 1);
96 };
97
98 #endif // _WX_MSW_STACKWALK_H_
99