$szTitle = "wxstackwalker"; include "./_header.inc"; ?>
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::onassertfailure 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
members
wxstackwalker::wxstackwalker
wxstackwalker::~wxstackwalker
wxstackwalker::onstackframe
wxstackwalker::walk
wxstackwalker::walkfromexception
wxstackwalker()
constructor does nothing, use walk() to walk the stack.
~wxstackwalker()
destructor does nothing neither but should be virtual as this class is used as a base one.
void onstackframe(const wxstackframe& frame)
this function must be overrided to process the given frame.
void walk(size_t skip = 1, size_t maxdepth = 200)
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).
up to maxdepth frames are walked from the innermost to the outermost one.
void walkfromexception()
enumerate stack frames from the location of uncaught exception. this method can only be called from wxapp::onfatalexception().
include "./_footer.inc"; ?>