summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
Commit message (Collapse)AuthorAgeFilesLines
* *** This commit represents a complete reformatting of the LLDB source codeKate Stone2016-09-061-1318/+1162
| | | | | | | | | | | | | | | | | | | | | | | *** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
* Add support for the LEAVE x86 instruction to AssemblyParse_x86.Jason Molenda2016-01-081-7/+38
| | | | llvm-svn: 257209
* Add support for 'leal' instruction to UnwindAssembly-x86Tamas Berghammer2015-03-251-1/+58
| | | | | | | | | | | Gcc for android use the leal instruction to substract from the stack pointer in the prologue of a function call. This patch add basic support for evaluating this instruction to support stack unwinding on android-x86. Differential revision: http://reviews.llvm.org/D8583 llvm-svn: 233178
* Don't #include ClangPersistentVariables.h from Process.hZachary Turner2015-03-031-0/+1
| | | | | | | Nothing from this header file was even being referenced in Process.h anyway, so it was a completely unnecessary include. llvm-svn: 231131
* Reduce header footprint of Target.hZachary Turner2015-03-031-0/+1
| | | | | | | | | | | | This continues the effort to reduce header footprint and improve build speed by removing clang and other unnecessary headers from Target.h. In one case, some headers were included solely for the purpose of declaring a nested class in Target, which was not needed by anybody outside the class. In this case the definition and implementation of the nested class were isolated in the .cpp file so the header could be removed. llvm-svn: 231107
* UnwindPlan::Row refactor -- add support for CFA set by a DWARF expressionPavel Labath2015-02-231-39/+39
| | | | | | | | | | | | | | | | | | | Summary: This change refactors UnwindPlan::Row to be able to store the fact that the CFA is value is set by evaluating a dwarf expression (DW_CFA_def_cfa_expression). This is achieved by creating a new class CFAValue and moving all CFA setting/getting code there. Note that code using the new CFAValue::isDWARFExpression is not yet present and will be added in a follow-up patch. Therefore, this patch should not change the functionality in any way. Test Plan: Ran tests on Mac and Linux. No regressions detected. Reviewers: jasonmolenda, clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7755 llvm-svn: 230210
* Fix the last two warnings I see on Linx building 'lldb': mismatchedChandler Carruth2015-02-131-2/+2
| | | | | | | | | | | | | signed and unsigned types in comparisons. For the text offset, use the addr_t type that is used elsewhere to get these kinds of offsets, and which it is being compared against. This seems to make things more consistent. For the other, the numbers are clearly small and uninteresting, so just cast them to the most boring 'int' type. llvm-svn: 229085
* Save & restore the array of which registers have already beenJason Molenda2015-01-131-2/+17
| | | | | | | | | saved/restored across a mid-function epilogue. We ignore repeated push/pops of a register so once we saw one 'pop %rbp', we'd ignore it the second time we saw it. <rdar://problem/19417410> llvm-svn: 225853
* Enhance the eh_frame unwind instruction augmenter so thatJason Molenda2015-01-131-6/+46
| | | | | | | | | it will do the right thing on x86 routines with a mid-function epilogue sequence (where the unwind rules need to be reinstalled after the epilogue has completed). <rdar://problem/19417410> llvm-svn: 225773
* Add an additional check to UnwindAssembly_x86::AugmentUnwindPlanFromCallSite Jason Molenda2015-01-131-17/+36
| | | | | | | | | | | | | | | | which will verify if the eh_frame instructions include details about the prologue or not. Both clang and gcc include prologue instructions but there's no requirement for them to do so -- and I'm sure we'll have to interoperate with a compiler that doesn't generate prologue info at some point. I don't have any compilers that omit the prologue instructions so the testing was of the "makre sure augmented unwind info is still created". With an eh_frame without prologue, this code should reject the augmentation scheme altogether and we should fall back to using assembly instruction profiling. llvm-svn: 225771
* Change the x86 assembly instruction unwind parser toJason Molenda2015-01-131-170/+129
| | | | | | | | | | | | | | | step through the complete function looking for any epilogue instructions. If we find an epilogue sequence, re-instate the correct unwind instructions if there is more code past that epilogue -- this will correctly handle an x86 function with multiple epilogues in it. NB there is still a bug with the "eh_frame augmented" UnwindPlans and mid-function epilogues. Looking at that next. <rdar://problem/18863406> llvm-svn: 225770
* Hoist the RegisterNumber class out of RegisterContextLLDB and makeJason Molenda2015-01-101-3/+68
| | | | | | | | | | | | | | | it more generally available. Add checks to UnwindAssembly_x86::AugmentUnwindPlanFromCallSite() so that it won't try to augment an UnwindPlan that already describes the function epilogue. Add a test case for backtracing out of _sigtramp on Darwin systems. This could probably be adapted to test the same thing on linux/bsd but the function names of sigtramp and kill are probably platform specific and I'm not sure what they should be. llvm-svn: 225578
* Have AssemblyParse_x86::get_non_call_site_unwind_plan trackJason Molenda2015-01-081-2/+13
| | | | | | | | | | | | | | | which registers have been spilled (saved to the stack) - and if we see that same register being saved to the stack again, don't record that, it's something specific to this stack frame. I found a code sequence for i386 where clang did a push %esi and then later in the function it did movl %esi, -0x7c(%ebp) and that second save of a scratch value overrode the original push location. <rdar://problem/19171178> llvm-svn: 225431
* Various unwinder work. Jason Molenda2014-12-211-3/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most of the changes are to the FuncUnwinders class -- as we've added more types of unwind information, the way this class was written was making it a mess to maintain. Instead of trying to keep one "non-call site" unwind plan and one "call site" unwind plan, track all the different types of unwind plans we can possibly retrieve for each function and have the call-site/non-call-site accessor methods retrieve those. Add a real "fast unwind plan" for x86_64 / i386 -- when doing an unwind through a function, this only has to read the first 4 bytes to tell if the function has a standard prologue sequence. If so, we can use the architecture default unwind plan to backtrace through this function. If we try to retrieve the save location for other registers later on, a real unwind plan will be used. This one is just for doing fast backtraces. Change the compact unwind plan importer to fill in the valid address range it is valid for. Compact unwind, in theory, may have multiple entries for a single function. The FuncUnwinders rewrite includes the start of supporting this correctly. In practice compact unwind encodings are used for the entire range of the function today -- in fact, sometimes the same encoding is used for multiple functions that have the same unwind rules. But I want to handle a single function that has multiple different compact unwind UnwindPlans eventually. llvm-svn: 224689
* The lldb unwinder can now use the unwind information from the compact-unwind Jason Molenda2014-12-081-0/+1
| | | | | | | | | | | | | | | | | | section for x86_64 and i386 targets on Darwin systems. Currently only the compact unwind encoding for normal frame-using functions is supported but it will be easy handle frameless functions when I have a bit more free time to test it. The LSDA and personality routines for functions are also retrieved correctly for functions from the compact unwind section. This new code is very fresh -- it passes the lldb testsuite and I've done by-hand inspection of many functions and am getting correct behavior for all of them. There may need to be some bug fixing over the next couple weeks as I exercise and test it further. But I think it's fine right now so I'm committing it. <rdar://problem/13220837> llvm-svn: 223625
* Fix some compiler warnings, one of which was a legit bug.Zachary Turner2014-11-101-2/+2
| | | | | | | | | | | | MSVC warns that not all control paths return a value when a switch doesn't have a default case handler. Changed explicit value checks to a default check. Also, it caught a case where bitwise AND was being used instead of logical AND. I'm not sure what this fixes, but presumably it is not covered by any kind of test case. llvm-svn: 221636
* Add recognition for another x86 epilogue sequence (ret followed byJason Molenda2014-11-041-0/+11
| | | | | | | | a nop). Fixes an instruction stepping problem when trying to step over the final instructions of an epilogue. <rdar://problem/18068877> llvm-svn: 221241
* Remove trailing whitespace from lines in UnwindAssembly-x86.cpp. No other ↵Jason Molenda2014-08-251-63/+63
| | | | | | changes. llvm-svn: 216420
* Clean up the coding conventions in UnwindAssembly-x86.cpp a little bit.Jason Molenda2014-08-251-38/+74
| | | | | | | | I wrote this originally as a part of an unwind library that was using a different coding convention and some of that old style remained after its integration into lldb. llvm-svn: 216419
* Have augment_unwind_plan_from_call_site update the UnwindPlan Jason Molenda2014-08-251-0/+15
| | | | | | | name/from-compiler settings to indicate that it was augmented by assembly profiling. llvm-svn: 216412
* On x86 & x86_64, try to use eh_frame for frame 0.Todd Fiala2014-08-251-11/+259
| | | | | | | | | | | | | We decided to use assmbly profiler instead of eh_frame for frame 0 because for compiler generated code, eh_frame is usually synchronous(a.k.a. only valid at call site); and we have no way to tell if it's asynchronous or not. But for x86 & x86_64 compiler generated code: 1. clang & GCC describes all prologue instructions in eh_frame; 2. mid-function stack pointer altering instructions can be easily detected. So we can grab eh_frame, and use assembly profiler to augment it into asynchronous unwind table. This change also benefits hand-written assembly; eh_frame for hand-written assembly is often asynchronous,so we have a much better chance to successfully unwind through them. Change by Tong Shen. llvm-svn: 216406
* Add code to AssemblyParse_x86::get_non_call_site_unwind_planJason Molenda2014-08-041-6/+24
| | | | | | | | to recognize an epilogue that ends with a jmp to objc_retainAutoreleaseReturnValue instead of a ret instruction. <rdar://problem/17889928> llvm-svn: 214783
* Fix an x86 assembler stack unwind calculation for non-volatile registers.Todd Fiala2014-07-251-1/+13
| | | | | | | | | | | | | | | | | | This change has the practical effect of fixing some backtrace scenarios that would fail with inferiors running on the Android Art host-side JVM under Linux x86_64 on Ubuntu 14.04. See this lldb-commits thread for more details: http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140721/011988.html Change by Tong Shen. Reviewed by Jason Molenda. Tested: Ubuntu 14.04 x86_64, clang-3.5-built lldb. MacOSX 10.10 Preview 4, Xcode 6 Beta 4-built lldb. llvm-svn: 213914
* sanitise sign comparisonsSaleem Abdulrasool2014-04-021-8/+14
| | | | | | | | This is a mechanical change addressing the various sign comparison warnings that are identified by both clang and gcc. This helps cleanup some of the warning spew that occurs during builds. llvm-svn: 205390
* Fix a bug where the x86 assembly instruction profiler would not correctly adjustJason Molenda2013-09-241-5/+14
| | | | | | | | the CFA instructions when it was profiling an -fomit-frame-pointer function and a "volatile" register was saved on the stack (e.g. an argument register). <rdar://problem/15036546> llvm-svn: 191267
* <rdar://problem/13854277>Greg Clayton2013-05-101-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <rdar://problem/13594769> Main changes in this patch include: - cleanup plug-in interface and use ConstStrings for plug-in names - Modfiied the BSD Archive plug-in to be able to pick out the correct .o file when .a files contain multiple .o files with the same name by using the timestamp - Modified SymbolFileDWARFDebugMap to properly verify the timestamp on .o files it loads to ensure we don't load updated .o files and cause problems when debugging The plug-in interface changes: Modified the lldb_private::PluginInterface class that all plug-ins inherit from: Changed: virtual const char * GetPluginName() = 0; To: virtual ConstString GetPluginName() = 0; Removed: virtual const char * GetShortPluginName() = 0; - Fixed up all plug-in to adhere to the new interface and to return lldb_private::ConstString values for the plug-in names. - Fixed all plug-ins to return simple names with no prefixes. Some plug-ins had prefixes and most ones didn't, so now they all don't have prefixed names, just simple names like "linux", "gdb-remote", etc. llvm-svn: 181631
* Add a new capability to RegisterContextLLDB: To recognize when theJason Molenda2012-10-261-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Full UnwindPlan is trying to do an impossible unwind; in that case invalidate the Full UnwindPlan and replace it with the architecture default unwind plan. This is a scenario that happens occasionally with arm unwinds in particular; the instruction analysis based full unwindplan can mis-parse the functions and the stack walk stops prematurely. Now we can do a simpleminded frame-chain walk to find the caller frame and continue the unwind. It's not ideal but given the complicated nature of analyzing the arm functions, and the lack of eh_frame information on iOS, it is a distinct improvement and fixes some long-standing problems with the unwinder on that platform. This is fixing <rdar://problem/12091421>. I may re-use this invalidate feature in the future if I can identify other cases where the full unwindplan's unwind information is clearly incorrect. This checkin also includes some cleanup for the volatile register definition in the arm ABI plugin for <rdar://problem/10652166> although work remains to be done for that bug. llvm-svn: 166757
* Change the scratch buffer for x86 assembly instructions in AssemblyParse_x86 ↵Jason Molenda2012-10-111-13/+5
| | | | | | | | from malloc'ed heap to an llvm SmallVector. llvm-svn: 165703
* Move the scratch buffer allocation for x86 instructions from being allocated ↵Jason Molenda2012-10-101-7/+9
| | | | | | | | | each instruction, to once in the AssemblyParse_x86 ctor. an instruction llvm-svn: 165662
* Free the opcode_data malloc'ed memory instead of leaking it - thanks for ↵Jason Molenda2012-10-101-1/+2
| | | | | | catching that, Chris. llvm-svn: 165597
* Change the x86 unwinder from using edis as its disassemblerJason Molenda2012-10-101-67/+43
| | | | | | | | API (to get the length of x86 instructions) to using the LLVM-MC disassembler. <rdar://problem/12411000> llvm-svn: 165587
* Switch nearly all of the use of the UnwindPlan::Row's to go throughJason Molenda2012-07-141-40/+77
| | | | | | | | | | | | | | a shared pointer to ease some memory management issues with a patch I'm working on. The main complication with using SPs for these objects is that most methods that build up an UnwindPlan will construct a Row to a given instruction point in a function, then add additional regsaves in the next instruction point to that row and push it again. A little care is needed to not mutate the previous instruction point's Row once these are switched to being held behing shared pointers. llvm-svn: 160214
* Add support for function with stack frame checks added by the compiler;Jason Molenda2012-05-251-28/+57
| | | | | | | | | | | | | | | | | | | | these functions will end in the sequence mov %rbp, %rsp ret call __stack_chk_fail instead of the usual mov, ret. The x86 assembly profiler only looked for functions ending in 'ret' and added the Unwind row describing how to set the CFA based on that -- the addition of the call insn (which is jumped to earlier in the function body) threw off that inspection. Resolves the need to "step" twice to get out of these functions when doing source-level stepping. <rdar://problem/11469705> llvm-svn: 157454
* Thread hardening part 3. Now lldb_private::Thread objects have std::weak_ptrGreg Clayton2012-02-211-21/+33
| | | | | | | | | | | | | | | | | objects for the backlink to the lldb_private::Process. The issues we were running into before was someone was holding onto a shared pointer to a lldb_private::Thread for too long, and the lldb_private::Process parent object would get destroyed and the lldb_private::Thread had a "Process &m_process" member which would just treat whatever memory that used to be a Process as a valid Process. This was mostly happening for lldb_private::StackFrame objects that had a member like "Thread &m_thread". So this completes the internal strong/weak changes. Documented the ExecutionContext and ExecutionContextRef classes so that our LLDB developers can understand when and where to use ExecutionContext and ExecutionContextRef objects. llvm-svn: 151009
* Patch from Daniel Dunbar for future-proof against ↵Johnny Chen2011-11-291-0/+11
| | | | | | http://llvm.org/viewvc/llvm-project?view=rev&revision=145331. llvm-svn: 145345
* Changed the emulate instruction function to take emulate options whichGreg Clayton2011-04-261-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | are defined as enumerations. Current bits include: eEmulateInstructionOptionAutoAdvancePC eEmulateInstructionOptionIgnoreConditions Modified the EmulateInstruction class to have a few more pure virtuals that can help clients understand how many instructions the emulator can handle: virtual bool SupportsEmulatingIntructionsOfType (InstructionType inst_type) = 0; Where instruction types are defined as: //------------------------------------------------------------------ /// Instruction types //------------------------------------------------------------------ typedef enum InstructionType { eInstructionTypeAny, // Support for any instructions at all (at least one) eInstructionTypePrologueEpilogue, // All prologue and epilogue instructons that push and pop register values and modify sp/fp eInstructionTypePCModifying, // Any instruction that modifies the program counter/instruction pointer eInstructionTypeAll // All instructions of any kind } InstructionType; This allows use to tell what an emulator can do and also allows us to request these abilities when we are finding the plug-in interface. Added the ability for an EmulateInstruction class to get the register names for any registers that are part of the emulation. This helps with being able to dump and log effectively. The UnwindAssembly class now stores the architecture it was created with in case it is needed later in the unwinding process. Added a function that can tell us DWARF register names for ARM that goes along with the source/Utility/ARM_DWARF_Registers.h file: source/Utility/ARM_DWARF_Registers.c Took some of plug-ins out of the lldb_private namespace. llvm-svn: 130189
* Renamed UnwindAssemblyProfiler to UnwindAssembly along with its source files.Greg Clayton2011-04-251-2/+2
| | | | llvm-svn: 130156
* Even more renaming.Greg Clayton2011-04-251-0/+902
llvm-svn: 130155
OpenPOWER on IntegriCloud