Remove all lines containing cvs/svn "$Id$" keyword.
[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 // 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
23 // ----------------------------------------------------------------------------
24 // wxStackFrame
25 // ----------------------------------------------------------------------------
26
27 class WXDLLIMPEXP_BASE wxStackFrame : public wxStackFrameBase
28 {
29 private:
30 wxStackFrame *ConstCast() const
31 { return const_cast<wxStackFrame *>(this); }
32
33 size_t DoGetParamCount() const { return m_paramTypes.GetCount(); }
34
35 public:
36 wxStackFrame(size_t level, void *address, size_t addrFrame)
37 : wxStackFrameBase(level, address)
38 {
39 m_hasName =
40 m_hasLocation = false;
41
42 m_addrFrame = addrFrame;
43 }
44
45 virtual size_t GetParamCount() const
46 {
47 ConstCast()->OnGetParam();
48 return DoGetParamCount();
49 }
50
51 virtual bool
52 GetParam(size_t n, wxString *type, wxString *name, wxString *value) const;
53
54 // callback used by OnGetParam(), don't call directly
55 void OnParam(_SYMBOL_INFO *pSymInfo);
56
57 protected:
58 virtual void OnGetName();
59 virtual void OnGetLocation();
60
61 void OnGetParam();
62
63
64 // helper for debug API: it wants to have addresses as DWORDs
65 size_t GetSymAddr() const
66 {
67 return reinterpret_cast<size_t>(m_address);
68 }
69
70 private:
71 bool m_hasName,
72 m_hasLocation;
73
74 size_t m_addrFrame;
75
76 wxArrayString m_paramTypes,
77 m_paramNames,
78 m_paramValues;
79 };
80
81 // ----------------------------------------------------------------------------
82 // wxStackWalker
83 // ----------------------------------------------------------------------------
84
85 class WXDLLIMPEXP_BASE wxStackWalker : public wxStackWalkerBase
86 {
87 public:
88 // we don't use ctor argument, it is for compatibility with Unix version
89 // only
90 wxStackWalker(const char * WXUNUSED(argv0) = NULL) { }
91
92 virtual void Walk(size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
93 #if wxUSE_ON_FATAL_EXCEPTION
94 virtual void WalkFromException(size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
95 #endif // wxUSE_ON_FATAL_EXCEPTION
96
97
98 // enumerate stack frames from the given context
99 void WalkFrom(const _CONTEXT *ctx, size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
100 void WalkFrom(const _EXCEPTION_POINTERS *ep, size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
101 };
102
103 #endif // _WX_MSW_STACKWALK_H_
104