printStackTrace prints formatted call stack to the user defined buffer, always terminating the buffer with 0. Uses stack frame to find out the caller function address and the map file to find out the function name.
Library requires that the executable has proper map file. The map file
must be in the same directory as the exe and the map file must have
.map
extension. From MS Visual Studio map file creation can
be enabled by checking 'Generate mapfile' box from 'Link' tab of 'Project
Settings' dialog (ALT+F7).
The output is printed only in debug build (_DEBUG is defined). In release build the user buffer receives only terminating 0, or error message if the map file is missing. The library could be used also in release build, but as it requires special options (frame pointer omission optimization must be disabled) the release build usage is not currently enabled.
Namespaces and other scopes get printed as they appear in a map file (a bit cleanup is done tho), so for example class name and namespaces get printed after the function name.
Example output:
_mainCRTStartup (403fa9) _main (4011ff) testfunc1 (4011b1) testfunc2.nspace (401161) testfunc3.MyClass.nspace (40110a) internalError (40105f) printStackTrace (401360)
Copyright (c) 2001 Jani Kajala
Permission to use, copy, modify, distribute and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation. Jani Kajala makes no representations about the suitability
of this software for any purpose. It is provided "as is" without express
or implied warranty.