]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/stackwalk.h
Implement monitoring of file descriptors in wxMotif event loop.
[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 #include "wx/arrstr.h"
16
17 // these structs are declared in windows headers
18 struct _CONTEXT;
19 struct _EXCEPTION_POINTERS;
20
21 // and these in dbghelp.h
22 struct _SYMBOL_INFO;
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 void OnParam(_SYMBOL_INFO *pSymInfo);
57
58 protected:
59 virtual void OnGetName();
60 virtual void OnGetLocation();
61
62 void OnGetParam();
63
64
65 // helper for debug API: it wants to have addresses as DWORDs
66 size_t GetSymAddr() const
67 {
68 return reinterpret_cast<size_t>(m_address);
69 }
70
71 private:
72 bool m_hasName,
73 m_hasLocation;
74
75 size_t m_addrFrame;
76
77 wxArrayString m_paramTypes,
78 m_paramNames,
79 m_paramValues;
80 };
81
82 // ----------------------------------------------------------------------------
83 // wxStackWalker
84 // ----------------------------------------------------------------------------
85
86 class WXDLLIMPEXP_BASE wxStackWalker : public wxStackWalkerBase
87 {
88 public:
89 // we don't use ctor argument, it is for compatibility with Unix version
90 // only
91 wxStackWalker(const char * WXUNUSED(argv0) = NULL) { }
92
93 virtual void Walk(size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
94 #if wxUSE_ON_FATAL_EXCEPTION
95 virtual void WalkFromException(size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
96 #endif // wxUSE_ON_FATAL_EXCEPTION
97
98
99 // enumerate stack frames from the given context
100 void WalkFrom(const _CONTEXT *ctx, size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
101 void WalkFrom(const _EXCEPTION_POINTERS *ep, size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
102 };
103
104 #endif // _WX_MSW_STACKWALK_H_
105