jasonmolenda created this revision. jasonmolenda added a project: LLDB. Herald added a subscriber: kristof.beyls.
On targets with a return address register (e.g. $lr on arm), when the unwinder is asked to fetch the caller's pc, we rewrite that to fetch the return address value. However, when we're in a trap handler -- either from an interrupt or an async signal -- we will have a full register context for the frame that was interrupted/trapped. The unwinder correctly allows you to fetch volatile registers when you're above a trap handler. But we are still rewriting the "fetch the pc" request when the trap handler is asked to find the caller's saved pc. This is incorrect, and results in lldb showing the wrong function that was interrupted/faulted. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D75007 Files: lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Index: lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -1203,9 +1203,13 @@ // If we're fetching the saved pc and this UnwindPlan defines a // ReturnAddress register (e.g. lr on arm), look for the return address // register number in the UnwindPlan's row. + // If this is a trap handler frame, we have access to the complete + // register context when the interrupt/async signal was received, so + // we need to fetch the actual saved $pc value. if (pc_regnum.IsValid() && pc_regnum == regnum && m_full_unwind_plan_sp->GetReturnAddressRegister() != - LLDB_INVALID_REGNUM) { + LLDB_INVALID_REGNUM && + m_frame_type != eTrapHandlerFrame) { return_address_reg.init( m_thread, m_full_unwind_plan_sp->GetRegisterKind(),
Index: lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -1203,9 +1203,13 @@ // If we're fetching the saved pc and this UnwindPlan defines a // ReturnAddress register (e.g. lr on arm), look for the return address // register number in the UnwindPlan's row. + // If this is a trap handler frame, we have access to the complete + // register context when the interrupt/async signal was received, so + // we need to fetch the actual saved $pc value. if (pc_regnum.IsValid() && pc_regnum == regnum && m_full_unwind_plan_sp->GetReturnAddressRegister() != - LLDB_INVALID_REGNUM) { + LLDB_INVALID_REGNUM && + m_frame_type != eTrapHandlerFrame) { return_address_reg.init( m_thread, m_full_unwind_plan_sp->GetRegisterKind(),
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits