X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/297ebe6b9749bba3ad8e7adb004f1ed390895c9c..87b8de0fceca302c88ab3cfac1e7498646c6cc93:/samples/console/console.cpp diff --git a/samples/console/console.cpp b/samples/console/console.cpp index 3e7e57defe..382148a1ca 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -74,6 +74,7 @@ #define TEST_SCOPEGUARD #define TEST_SNGLINST // #define TEST_SOCKETS --FIXME! (RN) + #define TEST_STACKWALKER #define TEST_STDPATHS #define TEST_STREAMS #define TEST_TEXTSTREAM @@ -84,7 +85,7 @@ #define TEST_WCHAR #define TEST_ZIP #else // #if TEST_ALL - #define TEST_DLLLOADER + #define TEST_STACKWALKER #endif // some tests are interactive, define this to run them @@ -433,7 +434,7 @@ static void TestDllListLoaded() for ( size_t n = 0; n < count; ++n ) { const wxDynamicLibraryDetails& details = dlls[n]; - printf("%-45s", details.GetPath().c_str()); + printf("%-45s", details.GetPath().mb_str()); void *addr; size_t len; @@ -443,7 +444,7 @@ static void TestDllListLoaded() (unsigned long)addr, (unsigned long)((char *)addr + len)); } - printf(" %s\n", details.GetVersion().c_str()); + printf(" %s\n", details.GetVersion().mb_str()); } } @@ -2629,6 +2630,75 @@ static void TestFtpUpload() #endif // TEST_FTP +// ---------------------------------------------------------------------------- +// stack backtrace +// ---------------------------------------------------------------------------- + +#ifdef TEST_STACKWALKER + +#if wxUSE_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 // wxUSE_STACKWALKER + +#endif // TEST_STACKWALKER + // ---------------------------------------------------------------------------- // standard paths // ---------------------------------------------------------------------------- @@ -4332,6 +4402,12 @@ int main(int argc, char **argv) TestScopeGuard(); #endif +#ifdef TEST_STACKWALKER +#if wxUSE_STACKWALKER + TestStackWalk(argv[0]); +#endif +#endif // TEST_STACKWALKER + #ifdef TEST_STDPATHS TestStandardPaths(); #endif