From 5a87c0fb37b5f37f3c8b5f3a48b7e8fcea02a7d7 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 6 Jan 2014 23:39:35 +0000 Subject: [PATCH] Update the checks in EmulateInstructionARM::GetFramePointerRegisterNumber and EmulateInstructionARM::GetFramePointerDWARFRegisterNumber to recognize the Apple arm convention (of using r7 for the frame pointer, regardless of thumb or arm) even if the OS does not match Darwin/MacOSX/iOS. Also corrects the behavior for thumb code on non-Apple platforms. llvm-svn: 198648 --- .../Instruction/ARM/EmulateInstructionARM.cpp | 52 +++++++++++++++++----- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp index ebeec10..f1cb41d 100644 --- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -289,37 +289,65 @@ EmulateInstructionARM::GetRegisterInfo (uint32_t reg_kind, uint32_t reg_num, Reg uint32_t EmulateInstructionARM::GetFramePointerRegisterNumber () const { - if (m_opcode_mode == eModeThumb) + bool is_apple = false; + if (m_arch.GetTriple().getVendor() == llvm::Triple::Apple) + is_apple = true; + switch (m_arch.GetTriple().getOS()) { - switch (m_arch.GetTriple().getOS()) - { case llvm::Triple::Darwin: case llvm::Triple::MacOSX: case llvm::Triple::IOS: - return 7; + is_apple = true; + break; default: break; - } } - return 11; + + /* On Apple iOS et al, the frame pointer register is always r7. + * Typically on other ARM systems, thumb code uses r7; arm code uses r11. + */ + + uint32_t fp_regnum = 11; + + if (is_apple) + fp_regnum = 7; + + if (m_opcode_mode == eModeThumb) + fp_regnum = 7; + + return fp_regnum; } uint32_t EmulateInstructionARM::GetFramePointerDWARFRegisterNumber () const { - if (m_opcode_mode == eModeThumb) + bool is_apple = false; + if (m_arch.GetTriple().getVendor() == llvm::Triple::Apple) + is_apple = true; + switch (m_arch.GetTriple().getOS()) { - switch (m_arch.GetTriple().getOS()) - { case llvm::Triple::Darwin: case llvm::Triple::MacOSX: case llvm::Triple::IOS: - return dwarf_r7; + is_apple = true; + break; default: break; - } } - return dwarf_r11; + + /* On Apple iOS et al, the frame pointer register is always r7. + * Typically on other ARM systems, thumb code uses r7; arm code uses r11. + */ + + uint32_t fp_regnum = dwarf_r11; + + if (is_apple) + fp_regnum = dwarf_r7; + + if (m_opcode_mode == eModeThumb) + fp_regnum = dwarf_r7; + + return fp_regnum; } // Push Multiple Registers stores multiple registers to the stack, storing to -- 2.7.4