Applied wxStackWalker improvement part of
item #1591718, [wxGTK] Native assert dialog and optimized stack walker git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43346 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -18,30 +18,38 @@
|
||||
|
||||
class WXDLLIMPEXP_BASE wxStackFrame : public wxStackFrameBase
|
||||
{
|
||||
friend class wxStackWalker;
|
||||
|
||||
public:
|
||||
// arguments are the stack depth of this frame, its address and the return
|
||||
// value of backtrace_symbols() for it
|
||||
//
|
||||
// NB: we don't copy syminfo pointer so it should have lifetime at least as
|
||||
// long as ours
|
||||
wxStackFrame(size_t level, void *address, const char *syminfo)
|
||||
wxStackFrame(size_t level = 0, void *address = NULL, const char *syminfo = NULL)
|
||||
: wxStackFrameBase(level, address)
|
||||
{
|
||||
m_hasName =
|
||||
m_hasLocation = false;
|
||||
|
||||
m_syminfo = syminfo;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void OnGetName();
|
||||
virtual void OnGetLocation();
|
||||
|
||||
// optimized for the 2 step initialization done by wxStackWalker
|
||||
void Set(const wxString &name, const wxString &filename, const char* syminfo,
|
||||
size_t level, size_t numLine, void *address)
|
||||
{
|
||||
m_level = level;
|
||||
m_name = name;
|
||||
m_filename = filename;
|
||||
m_syminfo = syminfo;
|
||||
|
||||
m_line = numLine;
|
||||
m_address = address;
|
||||
}
|
||||
|
||||
private:
|
||||
const char *m_syminfo;
|
||||
|
||||
bool m_hasName,
|
||||
m_hasLocation;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -60,13 +68,30 @@ public:
|
||||
ms_exepath = wxString::FromAscii(argv0);
|
||||
}
|
||||
|
||||
virtual void Walk(size_t skip = 1);
|
||||
~wxStackWalker()
|
||||
{
|
||||
FreeStack();
|
||||
}
|
||||
|
||||
virtual void Walk(size_t skip = 1, size_t maxDepth = 200);
|
||||
virtual void WalkFromException() { Walk(2); }
|
||||
|
||||
static const wxString& GetExePath() { return ms_exepath; }
|
||||
|
||||
|
||||
// these two may be used to save the stack at some point (fast operation)
|
||||
// and then process it later (slow operation)
|
||||
void SaveStack(size_t maxDepth);
|
||||
void ProcessFrames(size_t skip);
|
||||
void FreeStack();
|
||||
|
||||
private:
|
||||
int InitFrames(wxStackFrame *arr, size_t n, void **addresses, char **syminfo);
|
||||
|
||||
static wxString ms_exepath;
|
||||
static void *ms_addresses[];
|
||||
static char **ms_symbols;
|
||||
static int m_depth;
|
||||
};
|
||||
|
||||
#endif // _WX_UNIX_STACKWALK_H_
|
||||
|
Reference in New Issue
Block a user