From 2c9b3131193fc908c81eb2dc2f23a30c83cc64f4 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 31 Mar 2005 16:26:49 +0000 Subject: [PATCH] Frames to skip now honoured for Unix stackwalking Limited depth to 10 for assert dialog git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33217 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/appbase.cpp | 12 +++++++++++- src/unix/stackwalk.cpp | 7 +++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index ef32e59f1d..0f2c5edd34 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -772,7 +772,17 @@ void ShowAssertDialog(const wxChar *szFile, StackDump dump; dump.Walk(5); // don't show OnAssert() call itself - const wxString& stackTrace = dump.GetStackTrace(); + wxString stackTrace = dump.GetStackTrace(); + + const int maxLines = 10; + // Don't show more than maxLines or we could get an enormous dialog + int count = stackTrace.Freq(wxT('\n')); + if (count > maxLines) + { + int i; + for (i = 0; i < count - maxLines; i++) + stackTrace = stackTrace.BeforeLast(wxT('\n')); + } if ( !stackTrace.empty() ) { msg << _T("\n\nCall stack:\n") diff --git a/src/unix/stackwalk.cpp b/src/unix/stackwalk.cpp index 9ad52db9e6..b8b92ef924 100644 --- a/src/unix/stackwalk.cpp +++ b/src/unix/stackwalk.cpp @@ -221,9 +221,12 @@ void wxStackWalker::Walk(size_t skip) char **symbols = backtrace_symbols(addresses, depth); - for ( int n = 0; n < depth; n++ ) + if (skip > (size_t) depth) + skip = (size_t) depth; + + for ( int n = skip; n < depth; n++ ) { - wxStackFrame frame(n, addresses[n], symbols[n]); + wxStackFrame frame(n, addresses[n-skip], symbols[n-skip]); OnStackFrame(frame); } }