]> git.saurik.com Git - wxWidgets.git/blame - include/wx/unix/stackwalk.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / unix / stackwalk.h
CommitLineData
eaff0f0d
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/unix/stackwalk.h
3// Purpose: declaration of wxStackWalker for Unix
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 2005-01-19
eaff0f0d
VZ
7// Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_UNIX_STACKWALK_H_
12#define _WX_UNIX_STACKWALK_H_
13
14// ----------------------------------------------------------------------------
15// wxStackFrame
16// ----------------------------------------------------------------------------
17
18class WXDLLIMPEXP_BASE wxStackFrame : public wxStackFrameBase
19{
a82c2299
RR
20 friend class wxStackWalker;
21
eaff0f0d
VZ
22public:
23 // arguments are the stack depth of this frame, its address and the return
24 // value of backtrace_symbols() for it
25 //
26 // NB: we don't copy syminfo pointer so it should have lifetime at least as
27 // long as ours
a82c2299 28 wxStackFrame(size_t level = 0, void *address = NULL, const char *syminfo = NULL)
eaff0f0d
VZ
29 : wxStackFrameBase(level, address)
30 {
eaff0f0d
VZ
31 m_syminfo = syminfo;
32 }
33
34protected:
35 virtual void OnGetName();
a82c2299
RR
36
37 // optimized for the 2 step initialization done by wxStackWalker
38 void Set(const wxString &name, const wxString &filename, const char* syminfo,
39 size_t level, size_t numLine, void *address)
40 {
41 m_level = level;
42 m_name = name;
43 m_filename = filename;
44 m_syminfo = syminfo;
45
46 m_line = numLine;
47 m_address = address;
48 }
eaff0f0d
VZ
49
50private:
51 const char *m_syminfo;
eaff0f0d
VZ
52};
53
54// ----------------------------------------------------------------------------
55// wxStackWalker
56// ----------------------------------------------------------------------------
57
58class WXDLLIMPEXP_BASE wxStackWalker : public wxStackWalkerBase
59{
60public:
61 // we need the full path to the program executable to be able to use
62 // addr2line, normally we can retrieve it from wxTheApp but if wxTheApp
63 // doesn't exist or doesn't have the correct value, the path may be given
64 // explicitly
14bdf093
VZ
65 wxStackWalker(const char *argv0 = NULL)
66 {
67 ms_exepath = wxString::FromAscii(argv0);
68 }
eaff0f0d 69
a82c2299
RR
70 ~wxStackWalker()
71 {
72 FreeStack();
73 }
74
52499582 75 virtual void Walk(size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
4db307e1 76#if wxUSE_ON_FATAL_EXCEPTION
52499582 77 virtual void WalkFromException(size_t maxDepth = wxSTACKWALKER_MAX_DEPTH) { Walk(2, maxDepth); }
4db307e1 78#endif // wxUSE_ON_FATAL_EXCEPTION
eaff0f0d
VZ
79
80 static const wxString& GetExePath() { return ms_exepath; }
81
a82c2299
RR
82
83 // these two may be used to save the stack at some point (fast operation)
84 // and then process it later (slow operation)
85 void SaveStack(size_t maxDepth);
86 void ProcessFrames(size_t skip);
87 void FreeStack();
88
eaff0f0d 89private:
a82c2299
RR
90 int InitFrames(wxStackFrame *arr, size_t n, void **addresses, char **syminfo);
91
eaff0f0d 92 static wxString ms_exepath;
a82c2299
RR
93 static void *ms_addresses[];
94 static char **ms_symbols;
95 static int m_depth;
eaff0f0d
VZ
96};
97
98#endif // _WX_UNIX_STACKWALK_H_