forked from OSchip/llvm-project
a97c4d2154
The issue with Thumb IT (if/then) instructions is the IT instruction preceeds up to four instructions that are made conditional. If a breakpoint is placed on one of the conditional instructions, the instruction either needs to match the thumb opcode size (2 or 4 bytes) or a BKPT instruction needs to be used as these are always unconditional (even in a IT instruction). If BKPT instructions are used, then we might end up stopping on an instruction that won't get executed. So if we do stop at a BKPT instruction, we need to continue if the condition is not true. When using the BKPT isntructions are easy in that you don't need to detect the size of the breakpoint that needs to be used when setting a breakpoint even in a thumb IT instruction. The bad part is you will now always stop at the opcode location and let LLDB determine if it should auto-continue. If the BKPT instruction is used, the BKPT that is used for ARM code should be something that also triggers the BKPT instruction in Thumb in case you set a breakpoint in the middle of code and the code is actually Thumb code. A value of 0xE120BE70 will work since the lower 16 bits being 0xBE70 happens to be a Thumb BKPT instruction. The alternative is to use trap or illegal instructions that the kernel will translate into breakpoint hits. On Mac this was 0xE7FFDEFE for ARM and 0xDEFE for Thumb. The darwin kernel currently doesn't recognize any 32 bit Thumb instruction as a instruction that will get turned into a breakpoint exception (EXC_BREAKPOINT), so we had to use the BKPT instruction on Mac. The linux kernel recognizes a 16 and a 32 bit instruction as valid thumb breakpoint opcodes. The benefit of using 16 or 32 bit instructions is you don't stop on opcodes in a IT block when the condition doesn't match. To further complicate things, single stepping on ARM is often implemented by modifying the BCR/BVR registers and setting the processor to stop when the PC is not equal to the current value. This means single stepping is another way the ARM target can stop on instructions that won't get executed. This patch does the following: 1 - Fix the internal debugserver for Apple to use the BKPT instruction for ARM and Thumb 2 - Fix LLDB to catch when we stop in the middle of a Thumb IT instruction and continue if we stop at an instruction that won't execute 3 - Fixes this in a way that will work for any target on any platform as long as it is ARM/Thumb 4 - Adds a patch for ignoring conditions that don't match when in ARM mode (see below) This patch also provides the code that implements the same thing for ARM instructions, though it is disabled for now. The ARM patch will check the condition of the instruction in ARM mode and continue if the condition isn't true (and therefore the instruction would not be executed). Again, this is not enable, but the code for it has been added. <rdar://problem/19145455> llvm-svn: 223851 |
||
---|---|---|
.. | ||
ABI.cpp | ||
CMakeLists.txt | ||
CPPLanguageRuntime.cpp | ||
ExecutionContext.cpp | ||
FileAction.cpp | ||
InstrumentationRuntime.cpp | ||
InstrumentationRuntimeStopInfo.cpp | ||
JITLoader.cpp | ||
JITLoaderList.cpp | ||
LanguageRuntime.cpp | ||
Makefile | ||
Memory.cpp | ||
MemoryHistory.cpp | ||
NativeRegisterContext.cpp | ||
NativeRegisterContextRegisterInfo.cpp | ||
ObjCLanguageRuntime.cpp | ||
OperatingSystem.cpp | ||
PathMappingList.cpp | ||
Platform.cpp | ||
Process.cpp | ||
ProcessInfo.cpp | ||
ProcessLaunchInfo.cpp | ||
Queue.cpp | ||
QueueItem.cpp | ||
QueueList.cpp | ||
RegisterContext.cpp | ||
SectionLoadHistory.cpp | ||
SectionLoadList.cpp | ||
StackFrame.cpp | ||
StackFrameList.cpp | ||
StackID.cpp | ||
StopInfo.cpp | ||
SystemRuntime.cpp | ||
Target.cpp | ||
TargetList.cpp | ||
Thread.cpp | ||
ThreadCollection.cpp | ||
ThreadList.cpp | ||
ThreadPlan.cpp | ||
ThreadPlanBase.cpp | ||
ThreadPlanCallFunction.cpp | ||
ThreadPlanCallUserExpression.cpp | ||
ThreadPlanPython.cpp | ||
ThreadPlanRunToAddress.cpp | ||
ThreadPlanShouldStopHere.cpp | ||
ThreadPlanStepInRange.cpp | ||
ThreadPlanStepInstruction.cpp | ||
ThreadPlanStepOut.cpp | ||
ThreadPlanStepOverBreakpoint.cpp | ||
ThreadPlanStepOverRange.cpp | ||
ThreadPlanStepRange.cpp | ||
ThreadPlanStepThrough.cpp | ||
ThreadPlanStepUntil.cpp | ||
ThreadPlanTracer.cpp | ||
ThreadSpec.cpp | ||
UnixSignals.cpp | ||
UnwindAssembly.cpp |