]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/stackwalk.h
supporting clang memory management annotations
[wxWidgets.git] / include / wx / msw / stackwalk.h
CommitLineData
7beafee9
VZ
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
5ff14574
PC
15#include "wx/arrstr.h"
16
7beafee9
VZ
17// these structs are declared in windows headers
18struct _CONTEXT;
19struct _EXCEPTION_POINTERS;
20
21// and these in dbghelp.h
22struct _SYMBOL_INFO;
23
24// ----------------------------------------------------------------------------
25// wxStackFrame
26// ----------------------------------------------------------------------------
27
28class WXDLLIMPEXP_BASE wxStackFrame : public wxStackFrameBase
29{
30private:
31 wxStackFrame *ConstCast() const
5c33522f 32 { return const_cast<wxStackFrame *>(this); }
7beafee9
VZ
33
34 size_t DoGetParamCount() const { return m_paramTypes.GetCount(); }
35
36public:
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
58protected:
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 {
5c33522f 68 return reinterpret_cast<size_t>(m_address);
7beafee9
VZ
69 }
70
71private:
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
86class WXDLLIMPEXP_BASE wxStackWalker : public wxStackWalkerBase
87{
88public:
eaff0f0d
VZ
89 // we don't use ctor argument, it is for compatibility with Unix version
90 // only
91 wxStackWalker(const char * WXUNUSED(argv0) = NULL) { }
7beafee9 92
52499582 93 virtual void Walk(size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
4db307e1 94#if wxUSE_ON_FATAL_EXCEPTION
52499582 95 virtual void WalkFromException(size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
4db307e1 96#endif // wxUSE_ON_FATAL_EXCEPTION
7beafee9
VZ
97
98
99 // enumerate stack frames from the given context
52499582
FM
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);
7beafee9
VZ
102};
103
104#endif // _WX_MSW_STACKWALK_H_
105