Contents Up Previous Next

wxStackWalker

wxStackWalker allows an application to enumerate, or walk, the stack frames (the function callstack). It is mostly useful in only two situations: inside wxApp::OnFatalException function to programmatically get the location of the crash and, in debug builds, in wxApp::OnAssert to report the caller of the failed assert.

wxStackWalker works by repeatedly calling the OnStackFrame method for each frame in the stack, so to use it you must derive your own class from it and override this method.

This class will not return anything except raw stack frame addresses if the debug information is not available. Under Win32 this means that the PDB file matching the program being executed should be present. Note that if you use Microsoft Visual C++ compiler, you can create PDB files even for the programs built in release mode and it doesn't affect the program size (at least if you don't forget to add /opt:ref option which is suppressed by using /debug linker option by default but should be always enabled for release builds). Under Unix, you need to compile your program with debugging information (usually using -g compiler and linker options) to get the file and line numbers information, however function names should be available even without it. Of course, all this is only true if you build using a recent enough version of GNU libc which provides the backtrace() function needed to walk the stack.

debugging overview for how to make it available.

Derived from

No base class

Include files

<wx/stackwalk.h>

Only available if wxUSE_STACKWALKER is 1, currently only implemented for Win32 and Unix versions using recent version of GNU libc.

See also

wxStackFrame

Members

wxStackWalker::wxStackWalker
wxStackWalker::~wxStackWalker
wxStackWalker::OnStackFrame
wxStackWalker::Walk
wxStackWalker::WalkFromException


wxStackWalker::wxStackWalker

wxStackWalker()

Constructor does nothing, use Walk() to walk the stack.


wxStackWalker::~wxStackWalker

~wxStackWalker()

Destructor does nothing neither but should be virtual as this class is used as a base one.


wxStackWalker::OnStackFrame

void OnStackFrame(const wxStackFrame& frame)

This function must be overrided to process the given frame.


wxStackWalker::Walk

void Walk(size_t skip = 1)

Enumerate stack frames from the current location, skipping the initial number of them (this can be useful when Walk() is called from some known location and you don't want to see the first few frames anyhow; also notice that Walk() frame itself is not included if skip >= 1).


wxStackWalker::WalkFromException

void WalkFromException()

Enumerate stack frames from the location of uncaught exception. This method can only be called from wxApp::OnFatalException().