summaryrefslogtreecommitdiffstats
path: root/libunwind/src/UnwindCursor.hpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix a -Wbitwise-conditional-parentheses warning in _LIBUNWIND_ARM_EHABI ↵Nico Weber2020-02-191-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libunwind builds ``` src/UnwindCursor.hpp:1344:51: error: operator '?:' has lower precedence than '|'; '|' will be evaluated first [-Werror,-Wbitwise-conditional-parentheses] _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0; // Use enum? ~~~~~~~~~~~ ^ src/UnwindCursor.hpp:1344:51: note: place parentheses around the '|' expression to silence this warning _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0; // Use enum? ^ ( ) src/UnwindCursor.hpp:1344:51: note: place parentheses around the '?:' expression to evaluate it first _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0; // Use enum? ^ ( ) ``` But `0 |` is a no-op for either of those two interpretations, so I think what was meant here was ``` _info.flags = (isSingleWordEHT ? 1 : 0) | (scope32 ? 0x2 : 0); // Use enum? ``` Previously, if `isSingleWordEHT` was set, bit 2 would never be set. Now it is. From what I can tell, the only thing that checks these bitmask is ProcessDescriptors in Unwind-EHABI.cpp, and that only cares about bit 1, so in practice this shouldn't have much of an effect. Differential Revision: https://reviews.llvm.org/D73890 (cherry picked from commit 221c5af4e4f4a504a4d1f352dd7b76d305e56a62)
* [libunwind][RISCV] Add 64-bit RISC-V supportSam Elliott2019-12-161-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add unwinding support for 64-bit RISC-V. This is from the FreeBSD implementation with the following minor changes: - Renamed and renumbered DWARF registers to match the RISC-V ABI [1] - Use the ABI mneumonics in getRegisterName() instead of the exact register names - Include checks for __riscv_xlen == 64 to facilitate adding the 32-bit ABI in the future. [1] https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md Patch by Mitchell Horne (mhorne) Reviewers: lenary, luismarques, compnerd, phosek Reviewed By: lenary, luismarques Subscribers: arichardson, sameer.abuasal, abidh, asb, aprantl, krytarowski, simoncook, kito-cheng, christof, shiva0217, rogfer01, rkruppe, PkmX, psnobl, benna, lenary, s.egerton, luismarques, emaste, cfe-commits Differential Revision: https://reviews.llvm.org/D68362
* Correctly update isSignalFrame when unwinding the stack via dwarf.Sterling Augustine2019-11-071-1/+1
| | | | | | | | | | | | | | | | | | A "signal frame" is a function or block of code where execution arrives via a signal or interrupt, rather than via a normal call instruction. In fact, a particular instruction is interrupted by the signal and needs to be restarted. Therefore, when the signal handler is complete, execution needs to return to the interrupted instruction, rather than the instruction immediately following the call instruction, as in a normal call. Stack unwinders need to know this to correctly unwind signal frames. Dwarf handily provides an "S" in the CIE augmentation string to describe this case, and the libunwind API provides various functions to for unwinders to determine it,. The llvm libunwind implementation correctly sets it's internal variable "isSignalFrame" when initializing an unwind context. However, upon stepping up the stack, the current implementation correctly reads the augmentation string and sets it in the CIE info (which it then discards), libunwind doesn't update it's internal unwind context data structure. This change fixes that, and provides compatibility with both the canonical libunwind and the libgcc implementation. Reviewers: jfb Subscribers: christof, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D69677
* [libunwind][Android] Fix findUnwindSections for ARM EHABI BionicRyan Prichard2019-10-181-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fix the arm_section_length count. The meaning of the arm_section_length field changed from num-of-elements to num-of-bytes when the dl_unwind_find_exidx special case was removed (D30306 and D30681). The special case was restored in D39468, but that patch didn't account for the change in arm_section_length's meaning. That patch worked when it was applied to the NDK's fork of libunwind, because it never removed the special case in the first place, and the special case is probably disabled in the Android platform's copy of libunwind, because __ANDROID_API__ is greater than 21. Turn the dl_unwind_find_exidx special case on unconditionally for Bionic. Bionic's dl_unwind_find_exidx is much faster than using dl_iterate_phdr. (e.g. Bionic stores exidx info on an internal soinfo object.) Reviewers: thomasanderson, srhines, danalbert, ed, keith.walker.arm, mclow.lists, compnerd Reviewed By: srhines, danalbert Subscribers: srhines, kristof.beyls, christof, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D68972 llvm-svn: 375275
* Unwind: prevent unw_get_proc_info from returning stale dataSaleem Abdulrasool2019-09-201-1/+4
| | | | | | | | | | | | If unwind info is not available at the current IP, unw_get_proc_info should return a zero-filled structure rather than the info of the previous IP. This change also makes unw_get_proc_info return UNW_ENOINFO instead of UNW_ESUCCESS. Patch by Amanieu d'Antras! llvm-svn: 372407
* [NFC] Fix typo in debug logLouis Dionne2019-04-221-1/+1
| | | | llvm-svn: 358896
* Provide a placement new definition for the SEH version of UnwindCursorMartin Storsjo2019-02-031-0/+4
| | | | | | This fixes compilation after SVN r352966 in SEH mode. llvm-svn: 353010
* [libunwind] Provide placement new definitionPetr Hosek2019-02-021-0/+4
| | | | | | | | | While Clang automatically generates the code for placement new, g++ doesn't do that so we need to provide our own definition. Differential Revision: https://reviews.llvm.org/D57455 llvm-svn: 352966
* Drop the dependency on <algorithm>, add placement new inlinePetr Hosek2019-01-291-6/+25
| | | | | | | | | | | | We haven't eliminated C++ library dependency altogether in D57251, UnwindCursor.hpp had an unused dependency on <algorithm> which was pulling in other C++ headers. Removing that dependency also revealed (correctly) that we need our own global placement new declaration. Now libunwind should be independent of the C++ library. Differential Revision: https://reviews.llvm.org/D57262 llvm-svn: 352553
* Revert "[libunwind] Drop the dependency on <algorithm>, add placement new ↵Petr Hosek2019-01-281-0/+1
| | | | | | | | | inline" This reverts commit r352384: this broke on ARM as UnwindCursor.hpp still has some C++ library dependencies. llvm-svn: 352427
* [libunwind] Drop the dependency on <algorithm>, add placement new inlinePetr Hosek2019-01-281-1/+0
| | | | | | | | | | | | We haven't eliminated C++ library dependency altogether in D57251, UnwindCursor.hpp had an unused dependency on <algorithm> which was pulling in other C++ headers. Removing that dependency also revealed (correctly) that we need our own global placement new declaration. Now libunwind should be independent of the C++ library. Differential Revision: https://reviews.llvm.org/D57262 llvm-svn: 352384
* Silence warnings about unused parametersMartin Storsjo2019-01-221-0/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D56984 llvm-svn: 351888
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. 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: 351648
* [Sparc] Add Sparc V8 supportDaniel Cederman2019-01-141-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Adds the register class implementation for Sparc. Adds support for DW_CFA_GNU_window_save. Adds save and restore context functionality. Adds getArch() function to each Registers_ class to be able to separate between DW_CFA_AARCH64_negate_ra_state and DW_CFA_GNU_window_save which are both represented by the same constant. On Sparc the return address is the address of the call instruction, so an offset needs to be added when returning to skip the call instruction and its delay slot. If the function returns a struct it is also necessary to skip one extra instruction on Sparc V8. Reviewers: jyknight, mclow.lists, mstorsjo, compnerd Reviewed By: jyknight, compnerd Subscribers: jgorbe, mgorny, christof, llvm-commits, fedor.sergeev, JDevlieghere, ldionne, libcxx-commits Differential Revision: https://reviews.llvm.org/D55763 llvm-svn: 351044
* Revert "[Sparc] Add Sparc V8 support"Jorge Gorbe Moya2019-01-101-14/+0
| | | | | | This reverts commit r350705. llvm-svn: 350787
* [Sparc] Add Sparc V8 supportDaniel Cederman2019-01-091-0/+14
| | | | | | | | | | | | | | | | | | | | | | Summary: Adds the register class implementation for Sparc. Adds support for DW_CFA_GNU_window_save. Adds save and restore context functionality. On Sparc the return address is the address of the call instruction, so an offset needs to be added when returning to skip the call instruction and its delay slot. If the function returns a struct it is also necessary to skip one extra instruction. Reviewers: jyknight, mclow.lists, mstorsjo, compnerd Reviewed By: compnerd Subscribers: fedor.sergeev, JDevlieghere, ldionne, libcxx-commits Differential Revision: https://reviews.llvm.org/D55763 llvm-svn: 350705
* [SEH] Add initial support for AArch64Martin Storsjo2018-12-181-0/+53
| | | | | | | | | | | | | This doesn't yet implement inspecting the .pdata/.xdata to find the LSDA pointer (in UnwindCursor::getInfoFromSEH), but normal C++ exception handling seems to run just fine without it. (The only place I can see where it's even referenced is in unwind_phase2_forced, and I can't find a codepath where libcxxabi would end up calling that.) Differential Revision: https://reviews.llvm.org/D55674 llvm-svn: 349532
* Avoid code duplication in the SEH version of UnwindCursor::getRegisterName. NFC.Martin Storsjo2018-12-121-107/+1
| | | | | | | | This requires making Registers_*::getRegisterName static. Differential Revision: https://reviews.llvm.org/D55610 llvm-svn: 348981
* Fix existing code for SEH on ARM to compile correctlyMartin Storsjo2018-08-311-7/+7
| | | | | | | | | | | | | | | | | | | | Even though SEH for ARM is incomplete, make what code already exists at least compile correctly. The _LIBUNWIND_CURSOR_SIZE wasn't correct. ARM (and AArch64) have a DISPATCHER_CONTEXT field named TargetPc instead of TargetIp. For the libunwind.h UNW_* constants, there is no UNW_ARM_PC, only UNW_ARM_IP. Don't use 'r' as loop variable when 'r' already is a Registers_arm member. Differential Revision: https://reviews.llvm.org/D51530 llvm-svn: 341217
* Add support for SEH unwinding on Windows.Charles Davis2018-08-301-0/+581
| | | | | | | | | | | | | | | | | | | | | Summary: I've tested this implementation on x86-64 to ensure that it works. All `libc++abi` tests pass, as do all `libc++` exception-related tests. ARM still remains to be implemented (@compnerd?). Special thanks to KJK::Hyperion for his excellent series of articles on how EH works on x86-64 Windows. (Seriously, check it out. It's awesome.) I'm actually not sure if this should go in as is. I particularly don't like that I duplicated the UnwindCursor class for this special case. Reviewers: mstorsjo, rnk, compnerd, smeenai, javed.absar Subscribers: mgorny, kristof.beyls, christof, chrib, cfe-commits, compnerd, llvm-commits Differential Revision: https://reviews.llvm.org/D50564 llvm-svn: 341125
* The semantics of DW_CFA_GNU_args_size have changed subtile over theJoerg Sonnenberger2018-07-171-2/+0
| | | | | | | | | | years. Adopt the new convention that it is call-site specific and that it should be applied before moving the IP by personality routines, but not during normal unwinding. Differential Revision: https://reviews.llvm.org/D38680 llvm-svn: 337312
* [libunwind][MIPS]: Rename Registers_mips_n64 to Registers_mips_newabi.John Baldwin2018-01-091-6/+6
| | | | | | | | | | | This is in preparation for adding support for N32 unwinding which reuses the newabi register class. Reviewed By: compnerd Differential Revision: https://reviews.llvm.org/D41842 llvm-svn: 322093
* Reland [PPC64] Port to ppc64le - initial versionMartin Storsjo2018-01-021-0/+19
| | | | | | | | | | | | | | | | | | | | | Initial working version of libunwind for PowerPC 64. Tested on little-endian ppc64 host only. Based on the existing PowerPC 32 code. It supports: - context save/restore (unw_getcontext, unw_init_local, unw_resume) - read/write from/to saved registers - backtrace (unw_step) Patch by Leandro Lupori! Differential Revision: https://reviews.llvm.org/D41386 Now builds with LIBUNWIND_ENABLE_CROSS_UNWINDING=ON should work. llvm-svn: 321680
* Revert `rL321667: [PPC64] Port to ppc64le - initial version`Tim Shen2018-01-021-19/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D41386 llvm-svn: 321678
* [PPC64] Port to ppc64le - initial versionMartin Storsjo2018-01-021-0/+19
| | | | | | | | | | | | | | | | | | Initial working version of libunwind for PowerPC 64. Tested on little-endian ppc64 host only. Based on the existing PowerPC 32 code. It supports: - context save/restore (unw_getcontext, unw_init_local, unw_resume) - read/write from/to saved registers - backtrace (unw_step) Patch by Leandro Lupori! Differential Revision: https://reviews.llvm.org/D41386 llvm-svn: 321667
* [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.John Baldwin2017-12-121-0/+36
| | | | | | | | | | | This supports the soft-float ABI only and has been tested with both clang and gcc on FreeBSD. Reviewed By: sdardis, compnerd Differential Revision: https://reviews.llvm.org/D38110 llvm-svn: 320528
* Fix building for ARM with dwarf exception handlingMartin Storsjo2017-11-021-0/+6
| | | | | | | | | | | | | | | | The previous definition of _LIBUNWIND_HIGHEST_DWARF_REGISTER seems to be a copy of the ARM64 value (introduced in SVN r276128); since the code actually hasn't compiled properly for arm in dwarf mode before, this hasn't actually been used. Set it to the correct value based on the UNW_ARM_* enum values. The iwmmx control variables have to be made mutable, since they are touched from within getRegister (which previously wasn't const), and getRegister is used on a const Registers object in DwarfInstructions.hpp. Differential Revision: https://reviews.llvm.org/D39251 llvm-svn: 317192
* Abstract rwlocks into a class, provide a SRW lock implementation for windowsMartin Storsjo2017-10-231-17/+11
| | | | | | | | | | | | | | This requires _WIN32_WINNT >= 0x0600. If someone wants to spend effort on supporting earlier versions, one can easily add another fallback implementation based on critical sections, or try to load SRW lock functions dynamically. This makes sure that the FDE cache is thread safe on windows. Differential Revision: https://reviews.llvm.org/D38704 llvm-svn: 316364
* [libunwind] Handle .ARM.exidx tables without sentinel last entryMomchil Velikov2017-07-241-2/+9
| | | | | | | | | | | | | | | | | | | UnwindCursor<A, R>::getInfoFromEHABISection assumes the last entry in the index table never corresponds to a real function. Indeed, GNU ld always inserts an EXIDX_CANTUNWIND entry, containing the end of the .text section. However, the EHABI specification (http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf) does not seem to contain text that requires the presence of a sentinel entry. In that sense the libunwind implementation isn't compliant with the specification. This patch makes getInfoFromEHABISection examine the last entry in the index table if upper_bound returns the end iterator. Fixes https://bugs.llvm.org/show_bug.cgi?id=31091 Differential revision: https://reviews.llvm.org/D35265 llvm-svn: 308871
* [libunwind] Clean up macro usage.Ranjeet Singh2017-03-311-29/+29
| | | | | | | | Convention in libunwind is to use !defined(FOOT) not !FOO. Differential Revision: https://reviews.llvm.org/D31078 llvm-svn: 299225
* Let arm_section_length store the number of bytes.Ed Schouten2017-03-071-1/+2
| | | | | | | | | | | | | | | | Exception section data that we extract for DWARF gets stored as the offset and the number of bytes. For ARM exception info, we seem to deviate from this by storing the number of entries. Attempt to make this more consistent. By storing the number of bytes, we can get rid of the EHTEntry structure declared in AddressSpace.hpp. In UnwindCursor.hpp we already have another structure declared for the same purpose. Reviewed by: Keith Walker Differential Revision: https://reviews.llvm.org/D30681 llvm-svn: 297149
* [libunwind] Add support for a single-threaded libunwind buildAsiri Rathnayake2016-09-281-1/+7
| | | | | | | | | | | | | | The EHABI unwinder is thread-agnostic, SJLJ unwinder and the DWARF unwinder have a couple of pthread dependencies. This patch makes it possible to build the whole of libunwind for a single-threaded environment. Reviewers: compnerd Differential revision: https://reviews.llvm.org/D24984 llvm-svn: 282575
* consistently add \n to log and trace messagesEd Maste2016-08-301-6/+6
| | | | | | | | | | Previously most messages included a newline in the string, but a few of them were missing. Fix these and simplify by just adding the newline in the _LIBUNWIND_LOG macro itself. Differential Revision: https://reviews.llvm.org/D24026 llvm-svn: 280103
* libunwind: correct 'libuwind' typoEd Maste2016-08-301-1/+1
| | | | | | | There were several instances of libuwind (missing an "n"), dating to the initial import of libunwind. llvm-svn: 280086
* Fix gcc libunwind build.Asiri Rathnayake2016-05-261-1/+1
| | | | | | | | | | | | | | | | | | r270692 seems to have broken gcc builds of libunwind. This is because statements like: static_assert(check_fit<Registers_or1k, unw_context_t>::does_fit, "or1k registers do not fit into unw_context_t"); Do not work when static_assert is a macro taking two parameters, the extra comma separating the template parameters confuses the pre-processor. The fix is to change those statements to: static_assert((check_fit<Registers_or1k, unw_context_t>::does_fit), "or1k registers do not fit into unw_context_t"); Also fixed a gcc warning about a trivial un-intended narrowing. Differential revision: http://reviews.llvm.org/D20119 llvm-svn: 270925
* Introduce a native-only unwinder build.Asiri Rathnayake2016-05-251-1/+27
| | | | | | | | | | | | | | | | Currently libunwind is built to support cross-unwinding [1] by default, which requires the buffers unw_context_t and unw_cursor_t to be large enough to hold the vritual register set (VRS) of any supported architecture. This is not desirable for some platforms where the stack usage of the unwinder needs to be kept to a minimum (e.g. bare-metal targets). The current patch introduces a native-only (-DLIBUNWIND_ENABLE_CROSS_UNWINDING=OFF) unwinder variant that adopts strict sizes for the buffers unw_context_t and unw_cursor_t depending on the target architecture. [1] http://www.nongnu.org/libunwind/man/libunwind(3).html#section_4 Change-Id: I380fff9a56c16a0fc520e3b1d8454a34b4a48373 llvm-svn: 270692
* Make it possible to use libunwind without heap.Peter Zotov2015-11-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch allows to use libunwind on bare-metal systems that do not include malloc/free by conditionally turning off nonessential functionality that requires these functions. The disabled functionality includes: * the .cfi_remember_state and .cfi_restore_state instructions; * the DWARF FDE cache. The .cfi_{remember,restore}_state instructions don't seem to be used by contemporary compilers. None of the LLVM backends emit it. The DWARF FDE cache is bypassed if _LIBUNWIND_NO_HEAP is defined. Specifically, entries are never added to it, so the search begins and ends at the statically allocated, empty initial cache. Such heap-less libunwind on a bare metal system is successfully used in the ARTIQ project[1], and it is my hope that it will be useful elsewhere. [1]: http://m-labs.hk/artiq Differential Revision: http://reviews.llvm.org/D11897 llvm-svn: 252452
* [libunwind] Add support for OpenRISC 1000.Peter Zotov2015-08-311-0/+4
| | | | | | | | | This patch makes no assumptions on ABI past the ABI defined in the OpenRISC 1000 spec except that the DWARF register numbers will be 0-31 for registers r0-r31, which is true for both gcc and clang at the moment. llvm-svn: 246413
* libunwind: Introduce __libunwind_config.h.Logan Chien2015-07-191-6/+6
| | | | | | | Introduce __libunwind_config.h to avoid cross repository circular dependency with libcxxabi. llvm-svn: 242642
* libunwind: Fix unw_step() for ARM EHABI.Logan Chien2015-05-291-2/+19
| | | | | | | | | | | | | | | | | | | This commit fixes the unw_step() for ARM EHABI. However, this commit also changes the implementation details for ARM EHABI. The first change is that the personality function should call __gnu_unwind_frame() for default (or de facto) frame unwinding based on the ARM-defined unwind opcode. The function __gnu_unwind_frame() will in turn calls unw_step() which actually unwinds the frame. The second change is that the implementation _Unwind_Backtrace() should no longer calls unw_step() to unwind the frame; since according to ARM EHABI, the personality function should unwind the frame for us. Special thanks to Anton for helpful suggestion on the initial version of this patch. llvm-svn: 238560
* unwind: move src/Unwind, include/, and test/ unwind contentSaleem Abdulrasool2015-04-241-0/+1317
This moves the majority of the unwind sources into the new project layout for libunwind. This was previously discussed on llvmdev at [1]. This is a purely movement related change, with the build infrastructure currently still residing in the libc++abi repository. [1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-January/081507.html llvm-svn: 235758
OpenPOWER on IntegriCloud