llvm-project/lldb/source/Target
Greg Clayton a97c4d2154 Handle thumb IT instructions correctly all the time.
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
2014-12-09 23:31:02 +00:00
..
ABI.cpp ABI for the Hexagon DSP 2014-07-21 17:21:01 +00:00
CMakeLists.txt LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction 2014-10-10 23:43:03 +00:00
CPPLanguageRuntime.cpp Fixed the C++ method name class to be a bit more picky about what it identifies as a C++ method. 2014-11-05 23:56:37 +00:00
ExecutionContext.cpp Merging the iohandler branch back into main. 2014-01-27 23:43:24 +00:00
FileAction.cpp Enable local llgs debugging on Linux when the use-llgs-for-local setting is enabled. 2014-10-10 00:09:16 +00:00
InstrumentationRuntime.cpp LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction 2014-10-10 23:43:03 +00:00
InstrumentationRuntimeStopInfo.cpp LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction 2014-10-10 23:43:03 +00:00
JITLoader.cpp Moved JITLoader.cpp and JITLoaderList.cpp over into "source/Target" since the header files were in "include/lldb/Target". 2014-03-06 00:14:12 +00:00
JITLoaderList.cpp Create a Process::ModulesDidLoad() method to handle process-related tasks, as suggested by Jim Ingham. Make JITLoader instances use this to probe only new modules for relevant JIT symbols. Also re-enable the JITLoader hooks in Process. 2014-03-13 09:37:02 +00:00
LanguageRuntime.cpp Add the ability to set breakpoints with conditions, commands, etc, 2014-12-06 01:28:03 +00:00
Makefile
Memory.cpp Clean-up warnings on Linux/GCC 2014-09-16 06:34:29 +00:00
MemoryHistory.cpp Fix MemoryHistory plugin to check whether the plugin 2014-10-16 16:59:23 +00:00
NativeRegisterContext.cpp Add lldb-gdbserver support for Linux x86_64. 2014-06-30 21:05:18 +00:00
NativeRegisterContextRegisterInfo.cpp Add lldb-gdbserver support for Linux x86_64. 2014-06-30 21:05:18 +00:00
ObjCLanguageRuntime.cpp - Use "for_expression" rather than "allow_unknownanytype" 2014-10-31 18:02:30 +00:00
OperatingSystem.cpp <rdar://problem/13854277> 2013-05-10 21:47:16 +00:00
PathMappingList.cpp Start converting usages of off_t to other types. 2014-07-02 17:24:07 +00:00
Platform.cpp Added support to Platform to indicate (1) whether the 2014-12-05 01:16:31 +00:00
Process.cpp Handle thumb IT instructions correctly all the time. 2014-12-09 23:31:02 +00:00
ProcessInfo.cpp Pull ProcessInfo and ProcessLaunchInfo out of Target/Process. 2014-06-30 00:30:53 +00:00
ProcessLaunchInfo.cpp Fix some posix assumptions related to running shell commands. 2014-12-08 21:36:42 +00:00
Queue.cpp Add a SBQueue::GetKind() method to retrieve the type of libdispatch queue (serial or concurrent). 2014-03-13 02:54:54 +00:00
QueueItem.cpp Correctly add the QueueID to a pending block's extended thread backtrace thread. 2014-03-10 08:42:03 +00:00
QueueList.cpp Add new Queue, QueueItem, Queuelist, SBQueue, SBQueueItem classes to represent 2013-12-13 00:29:16 +00:00
RegisterContext.cpp Replace uint32_t by lldb::RegisterKing in register context API. 2014-07-02 09:51:28 +00:00
SectionLoadHistory.cpp Fix typos. 2014-07-01 21:22:11 +00:00
SectionLoadList.cpp Fix typos. 2014-07-08 18:05:41 +00:00
StackFrame.cpp Fix a corner case with the handling of noreturn functions. 2014-11-08 05:38:17 +00:00
StackFrameList.cpp Fixed more fallout from running the test suite remotely on iOS devices. 2014-11-17 19:39:20 +00:00
StackID.cpp sweep up -Wformat warnings from gcc 2014-04-04 04:06:10 +00:00
StopInfo.cpp The breakpoint location hit counts were getting incremented in 2014-10-22 01:54:17 +00:00
SystemRuntime.cpp Change the Mac OS X SystemRuntime plugin from using the placeholder 2014-02-05 05:44:54 +00:00
Target.cpp Add the ability to set breakpoints with conditions, commands, etc, 2014-12-06 01:28:03 +00:00
TargetList.cpp Add the ability to set breakpoints with conditions, commands, etc, 2014-12-06 01:28:03 +00:00
Thread.cpp Handle thumb IT instructions correctly all the time. 2014-12-09 23:31:02 +00:00
ThreadCollection.cpp [lldb] Abstract a superclass for a generic thread container. 2014-09-05 19:13:15 +00:00
ThreadList.cpp [lldb] Abstract a superclass for a generic thread container. 2014-09-05 19:13:15 +00:00
ThreadPlan.cpp sweep up -Wformat warnings from gcc 2014-04-04 04:06:10 +00:00
ThreadPlanBase.cpp Improve logging a bit by printing the exception or signal type description. 2014-02-27 19:35:12 +00:00
ThreadPlanCallFunction.cpp Fix the behavior when hand-calling a function times out on one thread, 2014-04-08 21:33:21 +00:00
ThreadPlanCallUserExpression.cpp Move some Host logic into HostInfo class. 2014-08-19 17:18:29 +00:00
ThreadPlanPython.cpp This checkin is the first step in making the lldb thread stepping mechanism more accessible from 2014-09-29 23:17:18 +00:00
ThreadPlanRunToAddress.cpp Fix typos. 2014-07-01 21:22:11 +00:00
ThreadPlanShouldStopHere.cpp When stepping, handle the case where the step leaves us with 2014-08-06 01:49:59 +00:00
ThreadPlanStepInRange.cpp Remove unneeded local var initialization. 2014-10-15 03:06:23 +00:00
ThreadPlanStepInstruction.cpp "nexti" should not step over inlined functions. 2014-11-20 22:04:45 +00:00
ThreadPlanStepOut.cpp This checkin is the first step in making the lldb thread stepping mechanism more accessible from 2014-09-29 23:17:18 +00:00
ThreadPlanStepOverBreakpoint.cpp Fix stepping over the inserted breakpoint trap when the NEXT instruction 2014-10-08 01:03:54 +00:00
ThreadPlanStepOverRange.cpp This checkin is the first step in making the lldb thread stepping mechanism more accessible from 2014-09-29 23:17:18 +00:00
ThreadPlanStepRange.cpp This checkin is the first step in making the lldb thread stepping mechanism more accessible from 2014-09-29 23:17:18 +00:00
ThreadPlanStepThrough.cpp Not all processes have a Dynamic Loader. Be sure to check that it exists before using it. 2014-09-30 20:33:25 +00:00
ThreadPlanStepUntil.cpp Fetching the parent frame may fail, handle that case. Patch from Tong Shen. 2014-08-11 23:57:43 +00:00
ThreadPlanTracer.cpp Add a new disassembly-format specification so that the disassembler 2014-10-10 23:07:36 +00:00
ThreadSpec.cpp Resolve printf formatting warnings on Linux: 2012-11-29 21:49:15 +00:00
UnixSignals.cpp Change the default handling for SIGALRM and SIGCHLD to not notify. 2013-10-28 19:00:42 +00:00
UnwindAssembly.cpp Fix UnwindAssembly memory leak by defining and using a shared UnwindAssemblySP type. 2014-02-03 23:49:47 +00:00