diff options
4 files changed, 22 insertions, 75 deletions
diff --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h index ae2fbf0db93..22e90ddf85c 100644 --- a/lldb/include/lldb/Core/EmulateInstruction.h +++ b/lldb/include/lldb/Core/EmulateInstruction.h @@ -57,7 +57,7 @@ /// Instruction Set Architecture (ISA) will be emulated. /// /// Subclasses at the very least should implement the instructions that -/// save and restore regiters onto the stack and adjustment to the stack +/// save and restore registers onto the stack and adjustment to the stack /// pointer. By just implementing a few instructions for an ISA that are /// the typical prologue opcodes, you can then generate CFI using a /// class that will soon be available. @@ -68,15 +68,15 @@ /// Implmenting all of the instructions allows for emulation of opcodes /// for breakpoint traps and will pave the way for "thread centric" /// debugging. The current debugging model is "process centric" where -/// all threads must be stopped when any thread is stopped since when -/// hitting software breakpoints once must disable the breakpoint by +/// all threads must be stopped when any thread is stopped; when +/// hitting software breakpoints we must disable the breakpoint by /// restoring the original breakpoint opcde, single stepping and /// restoring the breakpoint trap. If all threads were allowed to run /// then other threads could miss the breakpoint. /// /// This class centralizes the code that usually is done in separate /// code paths in a debugger (single step prediction, finding save -/// restore locations of registers for unwinding stack frame variables, +/// restore locations of registers for unwinding stack frame variables) /// and emulating the intruction is just a bonus. //---------------------------------------------------------------------- @@ -98,7 +98,7 @@ public: // Read an instruciton opcode from memory eContextReadOpcode, - // Usually used for writing a register value whose source value in an + // Usually used for writing a register value whose source value is an // immediate eContextImmediate, diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index 9ec2e64e0e8..9ca35fa9506 100644 --- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -538,10 +538,10 @@ ABIMacOSX_arm::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) UnwindPlan::Row row; - // Our previous Call Frame Address is the stack pointer + // Our Call Frame Address is the stack pointer value row.SetCFARegister (sp_reg_num); - // Our previous PC is in the LR + // The previous PC is in the LR row.SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); unwind_plan.AppendRow (row); @@ -554,36 +554,15 @@ ABIMacOSX_arm::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) bool ABIMacOSX_arm::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) { - uint32_t reg_kind = unwind_plan.GetRegisterKind(); - uint32_t fp_reg_num = LLDB_INVALID_REGNUM; - uint32_t sp_reg_num = LLDB_INVALID_REGNUM; - uint32_t pc_reg_num = LLDB_INVALID_REGNUM; - - switch (reg_kind) - { - case eRegisterKindDWARF: - case eRegisterKindGCC: - fp_reg_num = dwarf_r7; // apple uses r7 for all frames. Normal arm uses r11 - sp_reg_num = dwarf_sp; - pc_reg_num = dwarf_pc; - break; - - case eRegisterKindGeneric: - fp_reg_num = LLDB_REGNUM_GENERIC_FP; - sp_reg_num = LLDB_REGNUM_GENERIC_SP; - pc_reg_num = LLDB_REGNUM_GENERIC_PC; - break; - } - - if (fp_reg_num == LLDB_INVALID_REGNUM || - sp_reg_num == LLDB_INVALID_REGNUM || - pc_reg_num == LLDB_INVALID_REGNUM) - return false; + uint32_t fp_reg_num = dwarf_r7; // apple uses r7 for all frames. Normal arm uses r11; + uint32_t sp_reg_num = dwarf_sp; + uint32_t pc_reg_num = dwarf_pc; UnwindPlan::Row row; const int32_t ptr_size = 4; - unwind_plan.SetRegisterKind (eRegisterKindGeneric); + unwind_plan.Clear (); + unwind_plan.SetRegisterKind (eRegisterKindDWARF); row.SetCFARegister (fp_reg_num); row.SetCFAOffset (2 * ptr_size); row.SetOffset (0); @@ -601,7 +580,7 @@ ABIMacOSX_arm::RegisterIsVolatile (const RegisterInfo *reg_info) { if (reg_info) { - // Volatile registers include: ebx, ebp, esi, edi, esp, eip + // Volatile registers include: r0, r1, r2, r3, r9, r12, r13 const char *name = reg_info->name; if (name[0] == 'r') { diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index f5cd7ca7dff..2998e6bbf82 100644 --- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -820,47 +820,15 @@ ABIMacOSX_i386::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) bool ABIMacOSX_i386::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) { - uint32_t reg_kind = unwind_plan.GetRegisterKind(); - uint32_t fp_reg_num = LLDB_INVALID_REGNUM; - uint32_t sp_reg_num = LLDB_INVALID_REGNUM; - uint32_t pc_reg_num = LLDB_INVALID_REGNUM; + uint32_t fp_reg_num = dwarf_ebp; + uint32_t sp_reg_num = dwarf_esp; + uint32_t pc_reg_num = dwarf_eip; - switch (reg_kind) - { - case eRegisterKindDWARF: - fp_reg_num = dwarf_ebp; - sp_reg_num = dwarf_esp; - pc_reg_num = dwarf_eip; - break; - - case eRegisterKindGCC: - fp_reg_num = gcc_ebp; - sp_reg_num = gcc_esp; - pc_reg_num = gcc_eip; - break; - - case eRegisterKindGDB: - fp_reg_num = gdb_ebp; - sp_reg_num = gdb_esp; - pc_reg_num = gdb_eip; - break; - - case eRegisterKindGeneric: - fp_reg_num = LLDB_REGNUM_GENERIC_FP; - sp_reg_num = LLDB_REGNUM_GENERIC_SP; - pc_reg_num = LLDB_REGNUM_GENERIC_PC; - break; - } - - if (fp_reg_num == LLDB_INVALID_REGNUM || - sp_reg_num == LLDB_INVALID_REGNUM || - pc_reg_num == LLDB_INVALID_REGNUM) - return false; - UnwindPlan::Row row; const int32_t ptr_size = 4; - unwind_plan.SetRegisterKind (eRegisterKindGeneric); + unwind_plan.Clear (); + unwind_plan.SetRegisterKind (eRegisterKindDWARF); row.SetCFARegister (fp_reg_num); row.SetCFAOffset (2 * ptr_size); row.SetOffset (0); diff --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp index 37ddfb1a998..6d2b0a54b6a 100644 --- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp +++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp @@ -30,7 +30,7 @@ using namespace lldb_private; //----------------------------------------------------------------------------------------------- -// UnwindAssemblyParser_x86 method definitions +// UnwindAssemblyInstEmulation method definitions //----------------------------------------------------------------------------------------------- bool @@ -71,9 +71,6 @@ UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& const uint32_t addr_byte_size = m_arch.GetAddressByteSize(); const bool show_address = true; const bool show_bytes = true; - // Initialize the CFA with a known value. In the 32 bit case - // it will be 0x80000000, and in the 64 bit case 0x8000000000000000. - // We use the address byte size to be safe for any future addresss sizes m_inst_emulator_ap->GetRegisterInfo (unwind_plan.GetRegisterKind(), unwind_plan.GetInitialCFARegister(), m_cfa_reg_info); @@ -82,6 +79,9 @@ UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& m_register_values.clear(); m_pushed_regs.clear(); + // Initialize the CFA with a known value. In the 32 bit case + // it will be 0x80000000, and in the 64 bit case 0x8000000000000000. + // We use the address byte size to be safe for any future addresss sizes m_initial_sp = (1ull << ((addr_byte_size * 8) - 1)); RegisterValue cfa_reg_value; cfa_reg_value.SetUInt (m_initial_sp, m_cfa_reg_info.byte_size); |