1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/unix/stackwalk.h
3 // Purpose: declaration of wxStackWalker for Unix
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIX_STACKWALK_H_
13 #define _WX_UNIX_STACKWALK_H_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 class WXDLLIMPEXP_BASE wxStackFrame
: public wxStackFrameBase
21 friend class wxStackWalker
;
24 // arguments are the stack depth of this frame, its address and the return
25 // value of backtrace_symbols() for it
27 // NB: we don't copy syminfo pointer so it should have lifetime at least as
29 wxStackFrame(size_t level
= 0, void *address
= NULL
, const char *syminfo
= NULL
)
30 : wxStackFrameBase(level
, address
)
36 virtual void OnGetName();
38 // optimized for the 2 step initialization done by wxStackWalker
39 void Set(const wxString
&name
, const wxString
&filename
, const char* syminfo
,
40 size_t level
, size_t numLine
, void *address
)
44 m_filename
= filename
;
52 const char *m_syminfo
;
55 // ----------------------------------------------------------------------------
57 // ----------------------------------------------------------------------------
59 class WXDLLIMPEXP_BASE wxStackWalker
: public wxStackWalkerBase
62 // we need the full path to the program executable to be able to use
63 // addr2line, normally we can retrieve it from wxTheApp but if wxTheApp
64 // doesn't exist or doesn't have the correct value, the path may be given
66 wxStackWalker(const char *argv0
= NULL
)
68 ms_exepath
= wxString::FromAscii(argv0
);
76 virtual void Walk(size_t skip
= 1, size_t maxDepth
= 200);
77 virtual void WalkFromException() { Walk(2); }
79 static const wxString
& GetExePath() { return ms_exepath
; }
82 // these two may be used to save the stack at some point (fast operation)
83 // and then process it later (slow operation)
84 void SaveStack(size_t maxDepth
);
85 void ProcessFrames(size_t skip
);
89 int InitFrames(wxStackFrame
*arr
, size_t n
, void **addresses
, char **syminfo
);
91 static wxString ms_exepath
;
92 static void *ms_addresses
[];
93 static char **ms_symbols
;
97 #endif // _WX_UNIX_STACKWALK_H_