summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-05-23 18:04:09 +0000
committerGreg Clayton <gclayton@apple.com>2011-05-23 18:04:09 +0000
commit8d400e1750b7383422147c32e25435ed54f15290 (patch)
tree5b33a29c36f44680037cae90c6a9b4ab6f439ee0 /lldb/source/Plugins
parentfeb961b86a260009a241a2c4ff742fe8c8384bcb (diff)
downloadbcm5719-llvm-8d400e1750b7383422147c32e25435ed54f15290.tar.gz
bcm5719-llvm-8d400e1750b7383422147c32e25435ed54f15290.zip
Fixed an issue in the EmulateInstructionARM there the IT opcode was trying to
parse NOP instructions. I added the new table entries for the NOP for the plain NOP, Yield, WFE, WFI, and SEV variants. Modified the opcode emulation function EmulateInstructionARM::EmulateMOVRdSP(...) to notify us when it is creating a frame. Also added an abtract way to detect the frame pointer register for both the standard ARM ABI and for Darwin. Fixed GDBRemoteRegisterContext::WriteAllRegisterValues(...) to correctly be able to individually write register values back if case the 'G' packet is not implemented or returns an error. Modified the StopInfoMachException to "trace" stop reasons. On ARM we currently use the BVR/BCR register pairs to say "stop when the PC is not equal to the current PC value", and this results in a EXC_BREAKPOINT mach exception that has 0x102 in the code. Modified debugserver to create the short option string from long option definitions to make sure it doesn't get out of date. The short option string was missing many of the newer short option values due to a modification of the long options defs, and not modifying the short option string. llvm-svn: 131911
Diffstat (limited to 'lldb/source/Plugins')
-rw-r--r--lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp46
-rw-r--r--lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h11
-rw-r--r--lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp10
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp6
4 files changed, 64 insertions, 9 deletions
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index a08adc866c9..9e45bc4b0a0 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -42,9 +42,10 @@ using namespace lldb_private;
// A8.6.50
// Valid return values are {1, 2, 3, 4}, with 0 signifying an error condition.
-static unsigned short CountITSize(unsigned ITMask) {
+static uint32_t
+CountITSize (uint32_t ITMask) {
// First count the trailing zeros of the IT mask.
- unsigned TZ = llvm::CountTrailingZeros_32(ITMask);
+ uint32_t TZ = llvm::CountTrailingZeros_32(ITMask);
if (TZ > 3)
{
printf("Encoding error: IT Mask '0000'\n");
@@ -54,7 +55,7 @@ static unsigned short CountITSize(unsigned ITMask) {
}
// Init ITState. Note that at least one bit is always 1 in mask.
-bool ITSession::InitIT(unsigned short bits7_0)
+bool ITSession::InitIT(uint32_t bits7_0)
{
ITCounter = CountITSize(Bits32(bits7_0, 3, 0));
if (ITCounter == 0)
@@ -138,6 +139,7 @@ uint32_t ITSession::GetCond()
#define ARMV5J_ABOVE (ARMv5TEJ|ARMv6|ARMv6K|ARMv6T2|ARMv7|ARMv8)
#define ARMV6_ABOVE (ARMv6|ARMv6K|ARMv6T2|ARMv7|ARMv8)
#define ARMV6T2_ABOVE (ARMv6T2|ARMv7|ARMv8)
+#define ARMV7_ABOVE (ARMv7|ARMv8)
#define No_VFP 0
#define VFPv1 (1u << 1)
@@ -274,6 +276,24 @@ EmulateInstructionARM::GetRegisterInfo (uint32_t reg_kind, uint32_t reg_num, Reg
return false;
}
+uint32_t
+EmulateInstructionARM::GetFramePointerRegisterNumber () const
+{
+ if (m_opcode_mode == eModeThumb || m_arch.GetTriple().getOS() == llvm::Triple::Darwin)
+ return 7;
+ else
+ return 11;
+}
+
+uint32_t
+EmulateInstructionARM::GetFramePointerDWARFRegisterNumber () const
+{
+ if (m_opcode_mode == eModeThumb || m_arch.GetTriple().getOS() == llvm::Triple::Darwin)
+ return dwarf_r7;
+ else
+ return dwarf_r11;
+}
+
// Push Multiple Registers stores multiple registers to the stack, storing to
// consecutive memory locations ending just below the address in SP, and updates
// SP to point to the start of the stored data.
@@ -630,7 +650,10 @@ EmulateInstructionARM::EmulateMOVRdSP (const uint32_t opcode, const ARMEncoding
}
EmulateInstruction::Context context;
- context.type = EmulateInstruction::eContextRegisterPlusOffset;
+ if (Rd == GetFramePointerRegisterNumber())
+ context.type = EmulateInstruction::eContextSetFramePointer;
+ else
+ context.type = EmulateInstruction::eContextRegisterPlusOffset;
RegisterInfo sp_reg;
GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg);
context.SetRegisterPlusOffset (sp_reg, 0);
@@ -2153,6 +2176,13 @@ EmulateInstructionARM::EmulateIT (const uint32_t opcode, const ARMEncoding encod
return true;
}
+bool
+EmulateInstructionARM::EmulateNop (const uint32_t opcode, const ARMEncoding encoding)
+{
+ // NOP, nothing to do...
+ return true;
+}
+
// Branch causes a branch to a target address.
bool
EmulateInstructionARM::EmulateB (const uint32_t opcode, const ARMEncoding encoding)
@@ -12377,7 +12407,13 @@ EmulateInstructionARM::GetThumbOpcodeForInstruction (const uint32_t opcode, uint
//----------------------------------------------------------------------
// If Then makes up to four following instructions conditional.
//----------------------------------------------------------------------
- { 0xffffff00, 0x0000bf00, ARMvAll, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateIT, "it{<x>{<y>{<z>}}} <firstcond>"},
+ // The next 5 opcode _must_ come before the if then instruction
+ { 0xffffffff, 0x0000bf00, ARMV6T2_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateNop, "nop"},
+ { 0xffffffff, 0x0000bf10, ARMV7_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateNop, "nop YIELD (yield hint)"},
+ { 0xffffffff, 0x0000bf20, ARMV7_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateNop, "nop WFE (wait for event hint)"},
+ { 0xffffffff, 0x0000bf30, ARMV7_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateNop, "nop WFI (wait for interrupt hint)"},
+ { 0xffffffff, 0x0000bf40, ARMV7_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateNop, "nop SEV (send event hint)"},
+ { 0xffffff00, 0x0000bf00, ARMV6T2_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateIT, "it{<x>{<y>{<z>}}} <firstcond>"},
//----------------------------------------------------------------------
// Branch instructions
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
index dbafe6924d8..d5ce73c5a98 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
@@ -25,7 +25,7 @@ public:
~ITSession() {}
// InitIT - Initializes ITCounter/ITState.
- bool InitIT(unsigned short bits7_0);
+ bool InitIT(uint32_t bits7_0);
// ITAdvance - Updates ITCounter/ITState as IT Block progresses.
void ITAdvance();
@@ -370,6 +370,11 @@ protected:
const char *name;
} ARMOpcode;
+ uint32_t
+ GetFramePointerRegisterNumber () const;
+
+ uint32_t
+ GetFramePointerDWARFRegisterNumber () const;
static ARMOpcode*
GetARMOpcodeForInstruction (const uint32_t opcode, uint32_t isa_mask);
@@ -461,6 +466,10 @@ protected:
bool
EmulateIT (const uint32_t opcode, const ARMEncoding encoding);
+ // NOP
+ bool
+ EmulateNop (const uint32_t opcode, const ARMEncoding encoding);
+
// A8.6.16 B
bool
EmulateB (const uint32_t opcode, const ARMEncoding encoding);
diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index e8408dcd459..81c64de7c59 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -177,6 +177,8 @@ StopInfoMachException::GetDescription ()
case llvm::Triple::arm:
switch (m_exc_code)
{
+ case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break;
+ case 0x102: code_desc = "EXC_ARM_DA_DEBUG"; break;
case 1: code_desc = "EXC_ARM_BREAKPOINT"; break;
}
break;
@@ -311,7 +313,13 @@ StopInfoMachException::CreateStopReasonWithMachException
break;
case llvm::Triple::arm:
- is_software_breakpoint = exc_code == 1; // EXC_ARM_BREAKPOINT
+ if (exc_code == 0x102)
+ {
+ // EXC_ARM_DA_DEBUG seems to be reused for EXC_BREAKPOINT as well as EXC_BAD_ACCESS
+ return StopInfo::CreateStopReasonToTrace(thread);
+ }
+ else
+ is_software_breakpoint = exc_code == 1; // EXC_ARM_BREAKPOINT
break;
default:
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 62472732d17..ee6bff6a5d2 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -425,14 +425,16 @@ GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data
//ReadRegisterBytes (const RegisterInfo *reg_info, RegisterValue &value, DataExtractor &data)
const RegisterInfo *reg_info;
- for (uint32_t reg_idx=0; (reg_info = GetRegisterInfoAtIndex (reg_idx)) != NULL; ++reg_idx)
+ // We have to march the offset of each register along in the
+ // buffer to make sure we get the right offset.
+ uint32_t reg_byte_offset = 0;
+ for (uint32_t reg_idx=0; (reg_info = GetRegisterInfoAtIndex (reg_idx)) != NULL; ++reg_idx, reg_byte_offset += reg_info->byte_size)
{
const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
// Only write down the registers that need to be written
// if we are going to be doing registers individually.
bool write_reg = true;
- const uint32_t reg_byte_offset = reg_info->byte_offset;
const uint32_t reg_byte_size = reg_info->byte_size;
const char *restore_src = (const char *)restore_data.PeekData(reg_byte_offset, reg_byte_size);
OpenPOWER on IntegriCloud