Change the looping stack detection code

In some special case (e.g. signal handlers, hand written assembly) it is
valid to have 2 stack frame with the same CFA value. This CL change the
looping stack detection code to report a loop only if at least 3
consecutive frames have the same CFA.

Differential revision: http://reviews.llvm.org/D12699

llvm-svn: 247133
This commit is contained in:
Tamas Berghammer 2015-09-09 10:26:50 +00:00
parent eb882fc1f8
commit 025103cc61
1 changed files with 16 additions and 14 deletions

View File

@ -634,28 +634,30 @@ bool
RegisterContextLLDB::CheckIfLoopingStack ()
{
// If we have a bad stack setup, we can get the same CFA value multiple times -- or even
// more devious, we can actually oscillate between two CFA values. Detect that here and
// more devious, we can actually oscillate between two CFA values. Detect that here and
// break out to avoid a possible infinite loop in lldb trying to unwind the stack.
addr_t next_frame_cfa;
addr_t next_next_frame_cfa = LLDB_INVALID_ADDRESS;
if (GetNextFrame().get() && GetNextFrame()->GetCFA(next_frame_cfa))
// To detect when we have the same CFA value multiple times, we compare the CFA of the current
// frame with the 2nd next frame because in some specail case (e.g. signal hanlders, hand
// written assembly without ABI compiance) we can have 2 frames with the same CFA (in theory we
// can have arbitrary number of frames with the same CFA, but more then 2 is very very unlikely)
RegisterContextLLDB::SharedPtr next_frame = GetNextFrame();
if (next_frame)
{
if (next_frame_cfa == m_cfa)
RegisterContextLLDB::SharedPtr next_next_frame = next_frame->GetNextFrame();
addr_t next_next_frame_cfa = LLDB_INVALID_ADDRESS;
if (next_next_frame && next_next_frame->GetCFA(next_next_frame_cfa))
{
// We have a loop in the stack unwind
return true;
}
if (GetNextFrame()->GetNextFrame().get() && GetNextFrame()->GetNextFrame()->GetCFA(next_next_frame_cfa)
&& next_next_frame_cfa == m_cfa)
{
// We have a loop in the stack unwind
return true;
if (next_next_frame_cfa == m_cfa)
{
// We have a loop in the stack unwind
return true;
}
}
}
return false;
}
bool
RegisterContextLLDB::IsFrameZero () const
{