Really fix stack dumps for asserts and wxStackWalker::Walk() calls.
The code apparently tried to compensate for the wrong "skip" values used in the calls to wxStackWalker::Walk() by skipping too much in Walk() itself which was wrong as it dropped the frames that should have been shown. Fix this by skipping only the one extra (compared to Walk() itself) frame we add in wxStackWalker Unix implementation and not 3 of them and do skip more frames when calling Walk() from assert failure handlers. Also fix the wrong number of frames used in ProcessFrames(): we must not subtract the number of skipped frames, they were already skipped. Closes #14690. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72546 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -953,7 +953,7 @@ wxString wxAppTraitsBase::GetAssertStackTrace()
|
|||||||
static const int maxLines = 20;
|
static const int maxLines = 20;
|
||||||
|
|
||||||
StackDump dump;
|
StackDump dump;
|
||||||
dump.Walk(2, maxLines); // don't show OnAssert() call itself
|
dump.Walk(8, maxLines); // 8 is chosen to hide all OnAssert() calls
|
||||||
stackTrace = dump.GetStackTrace();
|
stackTrace = dump.GetStackTrace();
|
||||||
|
|
||||||
const int count = stackTrace.Freq(wxT('\n'));
|
const int count = stackTrace.Freq(wxT('\n'));
|
||||||
|
@@ -335,7 +335,7 @@ static void get_stackframe_callback(void* p)
|
|||||||
{
|
{
|
||||||
StackDump* dump = static_cast<StackDump*>(p);
|
StackDump* dump = static_cast<StackDump*>(p);
|
||||||
// skip over frames up to including wxOnAssert()
|
// skip over frames up to including wxOnAssert()
|
||||||
dump->ProcessFrames(3);
|
dump->ProcessFrames(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxDEBUG_LEVEL && wxUSE_STACKWALKER
|
#endif // wxDEBUG_LEVEL && wxUSE_STACKWALKER
|
||||||
|
@@ -182,17 +182,18 @@ void wxStackWalker::ProcessFrames(size_t skip)
|
|||||||
if (!ms_symbols || !m_depth)
|
if (!ms_symbols || !m_depth)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// we have 3 more "intermediate" frames which the calling code doesn't know
|
// we are another level down from Walk(), so adjust the number of stack
|
||||||
// about, account for them
|
// frames to skip accordingly
|
||||||
skip += 1;
|
skip += 1;
|
||||||
|
|
||||||
// call addr2line only once since this call may be very slow
|
// call addr2line only once since this call may be very slow
|
||||||
// (it has to load in memory the entire EXE of this app which may be quite
|
// (it has to load in memory the entire EXE of this app which may be quite
|
||||||
// big, especially if it contains debug info and is compiled statically!)
|
// big, especially if it contains debug info and is compiled statically!)
|
||||||
int towalk = InitFrames(frames, m_depth - skip, &ms_addresses[skip], &ms_symbols[skip]);
|
int numFrames = InitFrames(frames, m_depth - skip,
|
||||||
|
&ms_addresses[skip], &ms_symbols[skip]);
|
||||||
|
|
||||||
// now do user-defined operations on each frame
|
// now do user-defined operations on each frame
|
||||||
for ( int n = 0; n < towalk - (int)skip; n++ )
|
for ( int n = 0; n < numFrames; n++ )
|
||||||
OnStackFrame(frames[n]);
|
OnStackFrame(frames[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user