+// ----------------------------------------------------------------------------
+// stack backtrace
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_STACKWALKER
+
+#include "wx/stackwalk.h"
+
+class StackDump : public wxStackWalker
+{
+public:
+ StackDump(const char *argv0)
+ : wxStackWalker(argv0)
+ {
+ }
+
+ virtual void Walk()
+ {
+ wxPuts(_T("Stack dump:"));
+
+ wxStackWalker::Walk();
+ }
+
+protected:
+ virtual void OnStackFrame(const wxStackFrame& frame)
+ {
+ printf("[%2d] ", frame.GetLevel());
+
+ wxString name = frame.GetName();
+ if ( !name.empty() )
+ {
+ printf("%-20.40s", name.mb_str());
+ }
+ else
+ {
+ printf("0x%08lx", (unsigned long)frame.GetAddress());
+ }
+
+ if ( frame.HasSourceLocation() )
+ {
+ printf("\t%s:%d",
+ frame.GetFileName().mb_str(),
+ frame.GetLine());
+ }
+
+ puts("");
+
+ wxString type, val;
+ for ( size_t n = 0; frame.GetParam(n, &type, &name, &val); n++ )
+ {
+ printf("\t%s %s = %s\n", type.mb_str(), name.mb_str(), val.mb_str());
+ }
+ }
+};
+
+static void TestStackWalk(const char *argv0)
+{
+ wxPuts(_T("*** Testing wxStackWalker ***\n"));
+
+ StackDump dump(argv0);
+ dump.Walk();
+}
+
+#endif // TEST_STACKWALKER
+