summaryrefslogtreecommitdiffstats
path: root/lldb/source/Symbol/FuncUnwinders.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [lldb] Initialize some bitfields in FuncUnwinders.cppPavel Labath2020-01-071-0/+2
| | | | This got flagged by msan.
* [Windows] Use information from the PE32 exceptions directory to construct ↵Aleksandr Urakov2019-10-111-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unwind plans This patch adds an implementation of unwinding using PE EH info. It allows to get almost ideal call stacks on 64-bit Windows systems (except some epilogue cases, but I believe that they can be fixed with unwind plan disassembly augmentation in the future). To achieve the goal the CallFrameInfo abstraction was made. It is based on the DWARFCallFrameInfo class interface with a few changes to make it less DWARF-specific. To implement the new interface for PECOFF object files the class PECallFrameInfo was written. It uses the next helper classes: - UnwindCodesIterator helps to iterate through UnwindCode structures (and processes chained infos transparently); - EHProgramBuilder with the use of UnwindCodesIterator constructs EHProgram; - EHProgram is, by fact, a vector of EHInstructions. It creates an abstraction over the low-level unwind codes and simplifies work with them. It contains only the information that is relevant to unwinding in the unified form. Also the required unwind codes are read from the object file only once with it; - EHProgramRange allows to take a range of EHProgram and to build an unwind row for it. So, PECallFrameInfo builds the EHProgram with EHProgramBuilder, takes the ranges corresponding to every offset in prologue and builds the rows of the resulted unwind plan. The resulted plan covers the whole range of the function except the epilogue. Reviewers: jasonmolenda, asmith, amccarth, clayborg, JDevlieghere, stella.stamenova, labath, espindola Reviewed By: jasonmolenda Subscribers: leonid.mashinskiy, emaste, mgorny, aprantl, arichardson, MaskRay, lldb-commits, llvm-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67347 llvm-svn: 374528
* FuncUnwinders: prefer debug_frame over eh_framePavel Labath2019-05-271-4/+4
| | | | | | | | | | | | | | | The two sections usually contain the same information, and we rarely have both kinds of entries for a single function. However, in theory the debug_frame plan can be more complete, whereas eh_frame is only required to be correct at places where exceptions can be thrown. Reviewers: jasonmolenda, clayborg Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D62374 llvm-svn: 361758
* [FuncUnwinders] Use "symbol file" unwind plans for unwindingPavel Labath2019-05-241-1/+6
| | | | | | | | | | | | | | | | | Summary: Previous patch (r360409) introduced the "symbol file unwind plan" concept, but that plan wasn't used for unwinding yet. With this patch, we start to consider the new plan as a possible strategy for both synchronous and asynchronous unwinding. I also add a test that asserts that unwinding via breakpad STACK CFI info works end-to-end. Reviewers: jasonmolenda, clayborg Subscribers: lldb-commits, amccarth, markmentovai Differential Revision: https://reviews.llvm.org/D61853 llvm-svn: 361618
* FuncUnwinders: Add a new "SymbolFile" unwind planPavel Labath2019-05-101-1/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: some unwind formats are specific to a single symbol file and so it does not make sense for their parsing code live in the general Symbol library (as is the case with eh_frame for instance). This is the case for the unwind information in breakpad files, but the same will probably be true for PDB unwind info (once we are able to parse that). This patch adds the ability to fetch an unwind plan provided by a symbol file plugin, as discussed in the RFC at <http://lists.llvm.org/pipermail/lldb-dev/2019-February/014703.html>. I've kept the set of changes to a minimum, as there is no way to test them until we have a symbol file which implements this API -- that is comming in a follow-up patch, which will also implicitly test this change. The interesting part here is the introduction of the "RegisterInfoResolver" interface. The reason for this is that breakpad needs to be able to resolve register names (which are present as strings in the file) into register enums so that it can construct the unwind plan. This is normally done via the RegisterContext class, handing this over to the SymbolFile plugin would mean that it has full access to the debugged process, which is not something we want it to have. So instead, I create a facade, which only provides the ability to query register names, and hide the RegisterContext behind the facade. Also note that this only adds the ability to dump the unwind plan created by the symbol file plugin -- the plan is not used for unwinding yet -- this will be added in a third patch, which will add additional tests which makes sure the unwinding works as a whole. Reviewers: jasonmolenda, clayborg Subscribers: markmentovai, amccarth, lldb-commits Differential Revision: https://reviews.llvm.org/D61732 llvm-svn: 360409
* FuncUnwinders: remove "current_offset" from function argumentsPavel Labath2019-04-231-51/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This argument was added back in 2010 (r118882) to support the ability to unwind from functions whose eh_frame entry does not cover the entire range of the function. However, due to the caching happening in FuncUnwinders, this solution is very fragile. FuncUnwinders will cache the plan it got from eh_frame regardless of the value of the current_offset, so our ability to unwind from a given function depended what was the value of "current_offset" the first time that this function was called. Furthermore, since the "image show-unwind" command did not know what's the right offset to pass, this created an unfortunate situation where "image show-unwind" would show no valid plans for a function, even though they were available and being used. In this patch I implement the feature slightly differently. Instead of giving just a base address to the eh_frame unwinder, I give it the entire range we are interested in. Then, I change the unwinder to return the first plan that covers (even partially) that range. This way even a partial plan will be returned, regardless of the address in the function where we are stopped at. This solution is still not 100% correct, as it will not handle a function which is covered by two independent fde entries. However, I don't expect anybody will write this kind of functions, and this wasn't handled by the previous implementation either. If this is ever needed in the future. The eh_frame unwinder can be extended to return "composite" unwind plans created by merging sevelar fde entries. I also create a test which triggers this scenario. As doing this is virtually impossible without hand-written assembly, the test only works on x86 linux. Reviewers: jasonmolenda, clayborg Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D60829 llvm-svn: 358964
* [NFC] Remove ASCII lines from commentsJonas Devlieghere2019-04-101-4/+0
| | | | | | | | | | | | | | | | | | | | | | | A lot of comments in LLDB are surrounded by an ASCII line to delimit the begging and end of the comment. Its use is not really consistent across the code base, sometimes the lines are longer, sometimes they are shorter and sometimes they are omitted. Furthermore, it looks kind of weird with the 80 column limit, where the comment actually extends past the line, but not by much. Furthermore, when /// is used for Doxygen comments, it looks particularly odd. And when // is used, it incorrectly gives the impression that it's actually a Doxygen comment. I assume these lines were added to improve distinguishing between comments and code. However, given that todays editors and IDEs do a great job at highlighting comments, I think it's worth to drop this for the sake of consistency. The alternative is fixing all the inconsistencies, which would create a lot more churn. Differential revision: https://reviews.llvm.org/D60508 llvm-svn: 358135
* Use std::make_shared in LLDB (NFC)Jonas Devlieghere2019-02-111-15/+20
| | | | | | | | | | | Unlike std::make_unique, which is only available since C++14, std::make_shared is available since C++11. Not only is std::make_shared a lot more readable compared to ::reset(new), it also performs a single heap allocation for the object and control block. Differential revision: https://reviews.llvm.org/D57990 llvm-svn: 353764
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Simplify ObjectFile::GetArchitecturePavel Labath2019-01-031-2/+1
| | | | | | | | | | | | | | | | Summary: instead of returning the architecture through by-ref argument and a boolean value indicating success, we can just return the ArchSpec directly. Since the ArchSpec already has an invalid state, it can be used to denote the failure without the additional bool. Reviewers: clayborg, zturner, espindola Subscribers: emaste, arichardson, JDevlieghere, lldb-commits Differential Revision: https://reviews.llvm.org/D56129 llvm-svn: 350291
* Simplify Boolean expressionsJonas Devlieghere2018-12-151-1/+1
| | | | | | | | | | | This patch simplifies boolean expressions acorss LLDB. It was generated using clang-tidy with the following command: run-clang-tidy.py -checks='-*,readability-simplify-boolean-expr' -format -fix $PWD Differential revision: https://reviews.llvm.org/D55584 llvm-svn: 349215
* Reflow paragraphs in comments.Adrian Prantl2018-04-301-19/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is intended as a clean up after the big clang-format commit (r280751), which unfortunately resulted in many of the comment paragraphs in LLDB being very hard to read. FYI, the script I used was: import textwrap import commands import os import sys import re tmp = "%s.tmp"%sys.argv[1] out = open(tmp, "w+") with open(sys.argv[1], "r") as f: header = "" text = "" comment = re.compile(r'^( *//) ([^ ].*)$') special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$') for line in f: match = comment.match(line) if match and not special.match(match.group(2)): # skip intentionally short comments. if not text and len(match.group(2)) < 40: out.write(line) continue if text: text += " " + match.group(2) else: header = match.group(1) text = match.group(2) continue if text: filled = textwrap.wrap(text, width=(78-len(header)), break_long_words=False) for l in filled: out.write(header+" "+l+'\n') text = "" out.write(line) os.rename(tmp, sys.argv[1]) Differential Revision: https://reviews.llvm.org/D46144 llvm-svn: 331197
* Add debug_frame section supportPavel Labath2017-06-271-36/+97
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This is a beefed-up version of D33504, which adds support for dwarf 4 debug_frame section format. The main difference here is that the decision whether to use eh_frame or debug_frame is done on a per-function basis instead of per-object file. This is necessary because one module can contain both sections (for example, the start files added by the linker will typically pull in eh_frame), but we want to be able to access both, for maximum information. I also add unit test for parsing various CFI formats (eh_frame, debug_frame v3 and debug_frame v4). Reviewers: jasonmolenda, clayborg Subscribers: mgorny, aprantl, abidh, lldb-commits, tatyana-krasnukha Differential Revision: https://reviews.llvm.org/D34613 llvm-svn: 306397
* Fix a race condition in FuncUnwinders where the mutex was beingJason Molenda2017-02-241-9/+9
| | | | | | | | | | | | | | | acquired only after checking if the ivar shared pointer was already filled in. But when I assign an UnwindPlan object to the shared pointer, I assign an empty object and then fill it in. That leaves a window where another thread could get the shared pointer to the empty (but quickly being-filled-in) object and lead to a crash. Also two changes from Greg for correctness on the TestMultipleDebuggers test case. <rdar://problem/30564102> llvm-svn: 296084
* Remove dependencies from Utility to Core and Target.Zachary Turner2017-02-141-1/+1
| | | | | | | | | | With this patch, the only dependency left is from Utility to Host. After this is broken, Utility will finally be standalone. Differential Revision: https://reviews.llvm.org/D29909 llvm-svn: 295088
* *** This commit represents a complete reformatting of the LLDB source codeKate Stone2016-09-061-348/+317
| | | | | | | | | | | | | | | | | | | | | | | *** 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
* Enhance FuncUnwinders::GetUnwindPlanAtNonCallSite to detect when weJason Molenda2016-07-061-4/+70
| | | | | | | | | | | | | | | | | | may be in a function that is non-ABI conformant, and the eh_frame instructions correctly describe how to unwind out of this function, but the assembly parsing / arch default unwind plans would be incorrect. This is to address a problem that Ravitheja Addepally reported in http://reviews.llvm.org/D21221 - I wanted to try handling the problem with this approach which I think may be more generally helpful, Ravitheja tested it and said it solves the problem on Linux/FreeBSD. Ravi has a test case in http://reviews.llvm.org/D21221 that will be committed separately. Thanks for all the help on this one, Ravi. llvm-svn: 274700
* remove use of Mutex in favour of std::{,recursive_}mutexSaleem Abdulrasool2016-05-181-31/+31
| | | | | | | | | | This is a pretty straightforward first pass over removing a number of uses of Mutex in favor of std::mutex or std::recursive_mutex. The problem is that there are interfaces which take Mutex::Locker & to lock internal locks. This patch cleans up most of the easy cases. The only non-trivial change is in CommandObjectTarget.cpp where a Mutex::Locker was split into two. llvm-svn: 269877
* Add a way for an ObjectFile to indicate that assembly emulationJason Molenda2016-05-041-1/+5
| | | | | | | | | | | | | | | | | | | | | should not be used for this module -- for use when an ObjectFile knows that it does not have meaningful or accurate function start addresses. More commonly, it is not clear that function start addresses are missing in a module. There are certain cases on Mac OS X where we can tell that a Mach-O binary has been stripped of this essential information, and the unwinder can end up emulating many megabytes of instructions for a single "function" in the binary. When a Mach-O binary is missing both an LC_FUNCTION_STARTS load command (very unusual) and an eh_frame section, then we will assume it has also been stripped of symbols and that instruction emulation will not be useful on this module. <rdar://problem/25988067> llvm-svn: 268475
* Add support for .ARM.exidx unwind informationTamas Berghammer2015-09-301-5/+38
| | | | | | | | | .ARM.exidx/.ARM.extab sections contain unwind information used on ARM architecture from unwinding from an exception. Differential revision: http://reviews.llvm.org/D13245 llvm-svn: 248903
* Improve instruction emulation based stack unwinding on ARMTamas Berghammer2015-06-241-6/+7
| | | | | | | | | | | | | | | | | | | | | | | * Add and fix the emulation of several instruction. * Disable frame pointer usage on Android. * Specify return address register for the unwind plan instead of explict tracking the value of RA. * Replace prologue detection heuristics (unreliable in several cases) with a logic to follow the branch instructions and restore the CFI value based on them. The target address for a branch should have the same CFI as the source address (if they are in the same function). * Handle symbols in ELF files where the symbol size is not specified with calcualting their size based on the next symbol (already done in MachO files). * Fix architecture in FuncUnwinders with filling up the inforamtion missing from the object file with the architecture of the target. * Add code to read register wehn the value is set to "IsSame" as it meanse the value of a register in the parent frame is the same as the value in the current frame. Differential revision: http://reviews.llvm.org/D10447 llvm-svn: 240533
* Simplify FuncUnwinders::GetEHFrameAugmentedUnwindPlanPavel Labath2015-05-061-29/+17
| | | | | | | | | | | | | | | | | Summary: GetEHFrameAugmentedUnwindPlan duplicated the work of GetEHFrameUnwindPlan in getting the original plan from DWARF CFI. This changes the function to call GetEHFrameUnwindPlan instead of doing all the work itself. A copy constructor is added to UnwindPlan to enable plan copying. Test Plan: No regressions on linux test suite. Reviewers: jasonmolenda, clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D9369 llvm-svn: 236607
* Various unwinder work. Jason Molenda2014-12-211-100/+195
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-14/+35
| | | | | | | | | | | | | | | | | | 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 up the code in the FuncUnwinders class thatJason Molenda2014-11-181-14/+14
| | | | | | | | | | retrieves the personality routine addr and the LSDA addr. Don't bother checking with the "non-call site" unwind plan - this kind of information is only going to come from the call site unwind plan. llvm-svn: 222226
* Read the LSDA and Personality Routine function address out of theJason Molenda2014-11-181-0/+33
| | | | | | | | | | | | | | | | | | | | | eh_frame data. These two pieces of information are used in the process of exception handler unwinding on SysV ABI systems. This patch reads the data from the eh_frame section (DWARFCallFrameInfo.cpp), allows for it to be saved & read out of a given UnwindPlan (UnwindPlan.h, UnwindPlan.cpp) - as well as printing the information in the UnwindPlan::Dump method - and adds methods to the FuncUnwinders object so that higher levels can query if a given function has an LSDA / personality routine defined. It's only lightly tested, but seems to be working correctly as long as your have this information in eh_frame. Does not address getting this information from compact unwind yet on Darwin systems. <rdar://problem/18742797> llvm-svn: 222214
* Back out r221229 -- instead of trying to identify the end of the unwind,Jason Molenda2014-11-041-83/+11
| | | | | | | | | | | | | | | | | let's let lldb try the arch default unwind every time but not destructively -- it doesn't permanently replace the main unwind method for that function from now on. This fix is for <rdar://problem/18683658>. I tested it against Ryan Brown's go program test case and also a collection of core files of tricky unwind scenarios <rdar://problem/15664282> <rdar://problem/15835846> <rdar://problem/15982682> <rdar://problem/16099440> <rdar://problem/17364005> <rdar://problem/18556719> that I've fixed over the last 6-9 months. llvm-svn: 221238
* Copy unwind plan instead of modifying it directly, so "image show-unwind" ↵Todd Fiala2014-08-251-3/+7
| | | | | | | | prints different plans for asynchronous and synchronous. Change by Tong Shen. llvm-svn: 216416
* Have augment_unwind_plan_from_call_site update the UnwindPlan Jason Molenda2014-08-251-1/+2
| | | | | | | 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-2/+13
| | | | | | | | | | | | | 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
* Instead of having an UnwindTable own a single assembly profiler, Jason Molenda2014-05-231-9/+22
| | | | | | | | | | | and sharing it with all of its FuncUnwinders, have each FuncUnwinder create an AssemblyProfiler on demand as needed. I was worried that the cost of creating the llvm disassemblers would be high for this approach but it's not supposed to be an expensive operation, and it means we don't need to add locks around this section of code. <rdar://problem/16992332> llvm-svn: 209493
* Revert r209488; Greg suggests a different approach.Jason Molenda2014-05-231-12/+8
| | | | llvm-svn: 209492
* The UnwindTable (one per module) used to hand out shared pointersJason Molenda2014-05-231-8/+12
| | | | | | | | | | | | | | | to its unwind assembly profiler to all of the FuncUnwinders (one per symbol) under it. If lldb is running multiple targets, you could get two different FuncUnwinders in the same Module trying to use the same llvm disassembler simultaneously and that may be a re-entrancy problem. Instead, the UnwindTable has the unwind assembly profiler and when the FuncUnwinders want to use it, they get exclusive access to the assembly profiler until they're done using it. <rdar://problem/16992332> llvm-svn: 209488
* Switch NULL to C++11 nullptr in source/Symbol and source/UtilityEd Maste2014-04-201-5/+5
| | | | | | Patch by Robert Matusewicz llvm-svn: 206713
* Fix UnwindAssembly memory leak by defining and using a shared ↵Jean-Daniel Dupas2014-02-031-1/+1
| | | | | | UnwindAssemblySP type. llvm-svn: 200725
* Update RegisterContextLLDB::GetFullUnwindPlanForFrame() to use the ↵Jason Molenda2013-09-241-8/+15
| | | | | | | | | | | | | | | | | architectural- default-at-first-instruction UnwindPlan if we're at the beginning of a function and the ABI can provide us with an UnwindPlan to get out of there before falling back to the generic architectural default UnwindPlan (which usually assumes that the stack has already been set up.) Update the FuncUnwinders methods to gracefully handle the case where an assembly profiler may not be available. Fix a bug where FuncUnwinders::GetUnwindPlanArchitectureDefaultAtFunctionEntry was returning the wrong UnwindPlan to its caller. llvm-svn: 191262
* Since we use C++11, we should switch over to using std::unique_ptr when ↵Greg Clayton2013-04-181-8/+8
| | | | | | | | C++11 is being used. To do this, we follow what we have done for shared pointers and we define a STD_UNIQUE_PTR macro that can be used and it will "do the right thing". Due to some API differences in std::unique_ptr and due to the fact that we need to be able to compile without C++11, we can't use move semantics so some code needed to change so that it can compile with either C++. Anyone wanting to use a unique_ptr or auto_ptr should now use the "STD_UNIQUE_PTR(TYPE)" macro. llvm-svn: 179779
* Add a new capability to RegisterContextLLDB: To recognize when theJason Molenda2012-10-261-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Thread hardening part 3. Now lldb_private::Thread objects have std::weak_ptrGreg Clayton2012-02-211-1/+3
| | | | | | | | | | | | | | | | | 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
* The second part in thread hardening the internals of LLDB where we makeGreg Clayton2012-02-181-6/+6
| | | | | | | | | | | | | | | | the lldb_private::StackFrame objects hold onto a weak pointer to the thread object. The lldb_private::StackFrame objects the the most volatile objects we have as when we are doing single stepping, frames can often get lost or thrown away, only to be re-created as another object that still refers to the same frame. We have another bug tracking that. But we need to be able to have frames no longer be able to get the thread when they are not part of a thread anymore, and this is the first step (this fix makes that possible but doesn't implement it yet). Also changed lldb_private::ExecutionContextScope to return shared pointers to all objects in the execution context to further thread harden the internals. llvm-svn: 150871
* Have the FuncUnwinder object request & provide an architecture-definedJason Molenda2011-09-151-0/+38
| | | | | | | | | | | | | | | | | | | | | UnwindPlan for unwinding from the first instruction of an otherwise unknown function call (GetUnwindPlanArchitectureDefaultAtFunctionEntry()). Update RegisterContextLLDB::GetFullUnwindPlanForFrame() to detect the case of a frame 0 at address 0x0 which indicates that we jumped through a NULL function pointer. Use the ABI's FunctionEntryUnwindPlan to find the caller frame. These changes make it so lldb can identify the calling frame correctly in code like int main () { void (*f)(void) = 0; f(); } llvm-svn: 139760
* Moved all code from ArchDefaultUnwindPlan and ArchVolatileRegs into theirGreg Clayton2011-05-111-7/+12
| | | | | | | | | | | | | | | respective ABI plugins as they were plug-ins that supplied ABI specfic info. Also hookep up the UnwindAssemblyInstEmulation so that it can generate the unwind plans for ARM. Changed the way ABI plug-ins are handed out when you get an instance from the plug-in manager. They used to return pointers that would be mananged individually by each client that requested them, but now they are handed out as shared pointers since there is no state in the ABI objects, they can be shared. llvm-svn: 131193
* Renamed UnwindAssemblyProfiler to UnwindAssembly along with its source files.Greg Clayton2011-04-251-2/+2
| | | | llvm-svn: 130156
* Put plug-ins into the correct directories as they were incorrectly locatedGreg Clayton2011-04-251-6/+5
| | | | | | in a Utility directory. llvm-svn: 130135
* All UnwindPlan objects are now passed around as shared pointers.Greg Clayton2011-02-151-31/+30
| | | | | | | | | | | | | ArchDefaultUnwindPlan plug-in interfaces are now cached per architecture instead of being leaked for every frame. Split the ArchDefaultUnwindPlan_x86 into ArchDefaultUnwindPlan_x86_64 and ArchDefaultUnwindPlan_i386 interfaces. There were sporadic crashes that were due to something leaking or being destroyed when doing stack crawls. This patch should clear up these issues. llvm-svn: 125541
* Made FuncUnwinders threadsafe.Greg Clayton2011-01-081-14/+67
| | | | | | Other small cleanups as well. llvm-svn: 123088
* Fixed issues with the unwinding code where the collection of FuncUnwindersGreg Clayton2011-01-081-70/+62
| | | | | | | | | | | | was being searched and sorted using a shared pointer as the value which means the pointer value was what was being searched for. This means that anytime you did a stack backtrace, the collection of FuncUnwinders doubled and then the array or shared pointer got sorted (by pointer value), so you had an ever increasing collection of shared pointer where a match was never found. This means we had a ton of duplicates in this table and would cause issues after one had been debugging for a long time. llvm-svn: 123045
* I'm not thrilled with how I structured this but RegisterContextLLDBJason Molenda2010-11-121-6/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | needs to use the current pc and current offset in two ways: To determine which function we are currently executing, and the decide how much of that function has executed so far. For the former use, we need to back up the saved pc value by one byte if we're going to use the correct function's unwind information -- we may be executing a CALL instruction at the end of a function and the following instruction belongs to a new function, or we may be looking at unwind information which only covers the call instruction and not the subsequent instruction. But when we're talking about deciding which row of an UnwindPlan to execute, we want to use the actual byte offset in the function, not the byte offset - 1. Right now RegisterContextLLDB is tracking both the "real" offset and an "offset minus one" and different parts of the class have to know which one to use and they need to be updated/set in tandem. I want to revisit this at some point. The second change made in looking up eh_frame information; it was formerly done by looking for the start address of the function we are currently executing. But it is possible to have unwind information for a function which only covers a small section of the function's address range. In which case looking up by the start pc value may not find the eh_frame FDE. The hand-written _sigtramp() unwind info on Mac OS X, which covers exactly one instruction in the middle of the function, happens to trigger both of these issues. I still need to get the UnwindPlan runner to handle arbitrary dwarf expressions in the FDE but there's a good chance it will be easy to reuse the DWARFExpression class to do this. llvm-svn: 118882
* Built the native unwinder with all the warnings c++-4.2 could muster;Jason Molenda2010-11-041-1/+0
| | | | | | | | | fixed them. Added DISALLOW_COPY_AND_ASSIGN to classes that should not be bitwise copied. Added default initializers for member variables that weren't being initialized in the ctor. Fixed a few shadowed local variable mistakes. llvm-svn: 118240
* Check in the native lldb unwinder. Jason Molenda2010-10-251-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | Not yet enabled as the default unwinder but there are no known backtrace problems with the code at this point. Added 'log enable lldb unwind' to help diagnose backtrace problems; this output needs a little refining but it's a good first step. eh_frame information is currently read unconditionally - the code is structured to allow this to be delayed until it's actually needed. There is a performance hit when you have to parse the eh_frame information for any largeish executable/library so it's necessary to avoid if possible. It's confusing having both the UnwindPlan::RegisterLocation struct and the RegisterConextLLDB::RegisterLocation struct, I need to rename one of them. The writing of registers isn't done in the RegisterConextLLDB subclass yet; neither is the running of complex DWARF expressions from eh_frame (e.g. used for _sigtramp on Mac OS X). llvm-svn: 117256
OpenPOWER on IntegriCloud