tberghammer created this revision. tberghammer added a reviewer: jasonmolenda. tberghammer added a subscriber: lldb-commits.
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. Note: I would prefer to get rid of this looping stack detection because the implementation is still a bit flaky and rely on the logic in UnwindLLDB::GetOneMoreFrame to stop the infinite loop in case of a looping stack, but I don't know how big the user impact will be in the cases where the unwind go wrong and start looping http://reviews.llvm.org/D12699 Files: source/Plugins/Process/Utility/RegisterContextLLDB.cpp Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -634,28 +634,30 @@ 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) - { - // 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) + 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 (next_next_frame_cfa == m_cfa) + { + // We have a loop in the stack unwind + return true; + } } } return false; } - bool RegisterContextLLDB::IsFrameZero () const {
Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -634,28 +634,30 @@ 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) - { - // 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) + 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 (next_next_frame_cfa == m_cfa) + { + // We have a loop in the stack unwind + return true; + } } } return false; } - bool RegisterContextLLDB::IsFrameZero () const {
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits