mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-28 16:11:29 +00:00
Unwind past an interrupt handler correctly on arm or at pc==0
Fix RegisterContextLLDB::InitializeNonZerothFrame so that it will fetch a FullUnwindPlan instead of falling back to the architectural default unwind plan -- GetFullUnwindPlan knows how to spot a jmp 0x0 that results in a fault, which may be the case when we see a trap handler on the stack. Fix RegisterContextLLDB::SavedLocationForRegister so that when the pc value is requested from a trap handler frame, where we have a complete register context available to us, don't provide the Return Address register (lr) instead of the pc. We have an actual pc value here, and it's pointing to the instruction that faulted. Differential revision: https://reviews.llvm.org/D75007 <rdar://problem/59416588>
This commit is contained in:
parent
e6f9cb025c
commit
edc4f4c9c9
@ -328,9 +328,13 @@ void RegisterContextLLDB::InitializeNonZerothFrame() {
|
||||
|
||||
// If we don't have a Module for some reason, we're not going to find
|
||||
// symbol/function information - just stick in some reasonable defaults and
|
||||
// hope we can unwind past this frame.
|
||||
// hope we can unwind past this frame. If we're above a trap handler,
|
||||
// we may be at a bogus address because we jumped through a bogus function
|
||||
// pointer and trapped, so don't force the arch default unwind plan in that
|
||||
// case.
|
||||
ModuleSP pc_module_sp(m_current_pc.GetModule());
|
||||
if (!m_current_pc.IsValid() || !pc_module_sp) {
|
||||
if ((!m_current_pc.IsValid() || !pc_module_sp) &&
|
||||
above_trap_handler == false) {
|
||||
UnwindLogMsg("using architectural default unwind method");
|
||||
|
||||
// Test the pc value to see if we know it's in an unmapped/non-executable
|
||||
@ -1203,9 +1207,13 @@ RegisterContextLLDB::SavedLocationForRegister(
|
||||
// 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(),
|
||||
|
Loading…
Reference in New Issue
Block a user