aboutsummaryrefslogtreecommitdiff
path: root/libunwind/src/libunwind.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-05-21[WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (#92840)Heejin Ahn1-2/+1
We've decided to change `__USING_WASM_EXCEPTIONS__` preprocessor to `__WASM_EXCEPTIONS__` given that it's more concise.
2024-05-21[libunwind][WebAssembly] Make libunwind compilable (#92192)Heejin Ahn1-2/+2
This tries to make Wasm compilable in LLVM tree with CMake for non-Emscripten platform. This - Adds `-D__USING_WASM_EXCEPTIONS__` when you compile with `-fwasm-exceptions` (like other EH options) in Clang - Exclude `UnwindLevel1.c`, `UnwindRegistersSave.S`, and `UnwindRegistersRestore.S` when compiling with Wasm - Changed some `__USING_WASM_EXCEPTIONS__` to `__wasm__`; they should be applied when compiling with Wasm w/o exceptions. - Define some unused macros to make it compile Fixes #72771.
2024-01-16[libunwind][WebAssembly] Fix libunwind.cpp guard (#78230)Heejin Ahn1-2/+2
This should have been `&&`, meaning neither SjLj nor Wasm uses this file.
2024-01-16[libunwind] fix dynamic .eh_frame registration (#77185)SihangZhu1-1/+1
Fix this issue [#76957](https://github.com/llvm/llvm-project/issues/76957) Libgcc provides __register_frame to register a dynamic .eh_frame section, while __unw_add_dynamic_eh_frame_section can be used to do the same in libunwind. However, the address after dynamic .eh_frame are padding with 0 value, it will be identified as legal CIE. And __unw_add_dynamic_eh_frame_section will continue to parse subsequent addresses until illegal memory or other sections are accessed. This patch adds length formal parameter for dynamic registration.
2023-11-29[libunwind][WebAssembly] Omit unused parts of libunwind.cpp for Wasm (#73196)Heejin Ahn1-2/+3
Wasm doesn't use most of that file; Wasm does not allow access of system registers and those functionalities are provided from the VM.
2023-02-10[libunwind] On Darwin, add a callback-based lookup scheme for JIT'd unwind info.Lang Hames1-0/+80
This commit adds support for a new callback-based lookup scheme for unwind info that was inspired by the `_dyld_find_unwind_info_sections` SPI that libunwind uses to find unwind-info in non-JIT'd frames. From llvm-project/libunwind/src/AddressSpace.hpp: ``` struct dyld_unwind_sections { const struct mach_header* mh; const void* dwarf_section; uintptr_t dwarf_section_length; const void* compact_unwind_section; uintptr_t compact_unwind_section_length; }; extern bool _dyld_find_unwind_sections(void *, dyld_unwind_sections *); ``` During unwinding libunwind calls `_dyld_find_unwind_sections` to both find unwind section addresses and identify the subarchitecture for frames (via the MachO-header pointed to by the mh field). This commit introduces two new libunwind SPI functions: ``` struct unw_dynamic_unwind_sections { unw_word_t dso_base; unw_word_t dwarf_section; size_t dwarf_section_length; unw_word_t compact_unwind_section; size_t compact_unwind_section_length; }; typedef int (*unw_find_dynamic_unwind_sections)( unw_word_t addr, struct unw_dynamic_unwind_sections *info); // Returns UNW_ESUCCESS if successfully registered, UNW_EINVAL for duplicate // registrations, and UNW_ENOMEM to indicate too many registrations. extern int __unw_add_find_dynamic_unwind_sections( unw_find_dynamic_unwind_sections find_dynamic_unwind_sections); // Returns UNW_ESUCCESS if successfully deregistered, UNW_EINVAL to indicate // no such registration. extern int __unw_remove_find_dynamic_unwind_sections( unw_find_dynamic_unwind_sections find_dynamic_unwind_sections); ``` These can be used to register and deregister callbacks that have a similar signature to `_dyld_find_unwind_sections`. During unwinding if `_dyld_find_unwind_sections` returns false (indicating that no frame info was found by dyld) then registered callbacks are run in registration order until either the unwind info is found or the end of the list is reached. With this commit, and by implementing the find-unwind-info callback in the ORC runtime in LLVM, we (1) enable support for registering JIT'd compact-unwind info with libunwind*, (2) provide a way to identify the subarchitecture for each frame (by returning a pointer to a JIT'd MachO header), and (3) delegate tracking of unwind info to the callback, which may be able to implement more efficient address-based lookup than libunwind. * JITLink does not process or register compact unwind info yet, so this patch does not fully enable compact unwind info in ORC, it simply provides some necessary plumbing. JITLink support for compact unwind should land some time in the LLVM 17 development cycle. Reviewed By: pete Differential Revision: https://reviews.llvm.org/D142176
2022-11-15[libunwind][LoongArch] Add 64-bit LoongArch supportzhanglimin1-0/+2
Defines enums for the LoongArch registers. Adds the register class implementation for LoongArch. Adds save and restore context functionality. This only supports 64 bits integer and float-point register implementation. Fix https://github.com/llvm/llvm-project/issues/55398 Reviewed By: SixWeining Differential Revision: https://reviews.llvm.org/D137010
2022-09-21[libunwind] Handle G in personality stringFlorian Mayer1-0/+9
Tested with the following program: ``` static volatile int* x = nullptr; void throws() __attribute__((noinline)) { if (getpid() == 0) return; throw "error"; } void maybe_throws() __attribute__((noinline)) { volatile int y = 1; x = &y; throws(); y = 2; } int main(int argc, char** argv) { int y; try { maybe_throws(); } catch (const char* e) { //printf("Caught\n"); } y = *x; printf("%d\n", y); // should be MTE failure. return 0; } ``` Built using `clang++ -c -O2 -target aarch64-linux -fexceptions -march=armv8-a+memtag -fsanitize=memtag-heap,memtag-stack` Currently only Android implements runtime support for MTE stack tagging. Without this change, we crash on `__cxa_get_globals` when trying to catch the exception (because the stack frame __cxa_get_globals frame will fail due to tags left behind on the stack). With this change, we crash on the `y = *x;` as expected, because the stack frame has been untagged, but the pointer hasn't. Reviewed By: #libunwind, compnerd, MaskRay Differential Revision: https://reviews.llvm.org/D128998
2022-08-20[libunwind] Fixed a number of typosGabriel Ravier1-1/+1
I went over the output of the following mess of a command: `(ulimit -m 2000000; ulimit -v 2000000; git ls-files -z | parallel --xargs -0 cat | aspell list --mode=none --ignore-case | grep -E '^[A-Za-z][a-z]*$' | sort | uniq -c | sort -n | grep -vE '.{25}' | aspell pipe -W3 | grep : | cut -d' ' -f2 | less)` and proceeded to spend a few days looking at it to find probable typos and fixed a few hundred of them in all of the llvm project (note, the ones I found are not anywhere near all of them, but it seems like a good start). Reviewed By: #libunwind, MaskRay Differential Revision: https://reviews.llvm.org/D130948
2022-05-02[libunwind] Add SystemZ supportUlrich Weigand1-0/+2
Add support for the SystemZ (s390x) architecture to libunwind. Support should be feature-complete with the exception of unwinding from signal handlers (to be added later). Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D124248
2022-04-13[libunwind][AIX] implementation of the unwinder for AIXXing Xue1-0/+10
Summary: This patch contains the implementation of the unwinder for IBM AIX. AIX does not support the eh_frame section. Instead, the traceback table located at the end of each function provides the information for stack unwinding and EH. In this patch macro _LIBUNWIND_SUPPORT_TBTAB_UNWIND is used to guard code for AIX traceback table based unwinding. Function getInfoFromTBTable() and stepWithTBTable() are added to get the EH information from the traceback table and to step up the stack respectively. There are two kinds of LSDA information for EH on AIX, the state table and the range table. The state table is used by the previous version of the IBM XL compiler, i.e., xlC and xlclang++. The DWARF based range table is used by AIX clang++. The traceback table has flags to differentiate these cases. For the range table, relative addresses are calculated using a base of DW_EH_PE_datarel, which is the TOC base of the module where the function of the current frame belongs. Two personality routines are employed to handle these two different LSDAs, __xlcxx_personality_v0() for the state table and __xlcxx_personality_v1() for the range table. Since the traceback table does not have the information of the personality for the state table approach, its personality __xlcxx_personality_v0() is dynamically resolved as the handler for the state table. For the range table, the locations of the LSDA and its associated personality routine are found in the traceback table. Assembly code for 32- and 64-bit PowerPC in UnwindRegistersRestore.S and UnwindRegistersSave.S are modified so that it can be consumed by the GNU flavor assembler and the AIX assembler. The restoration of vector registers does not check VRSAVE on AIX because VRSAVE is not used in the AIX ABI. Reviewed by: MaskRay, compnerd, cebowleratibm, sfertile, libunwind Differential Revision: https://reviews.llvm.org/D100132
2022-02-05[libunwind] [sparc] Add SPARCv9 supportKoakuma1-0/+2
Adds libunwind support for SPARCv9 (aka sparc64). This is a rebase of @kettenis' patch D32450, which I created (with his permission) because the original review has become inactive. The changes are of a cosmetic nature to make it fit better with the new code style, and to reuse the existing SPARCv8 code, whenever possible. Please let me know if I posted this on the wrong place. Also, the summary of the original review is reproduced below: > This adds unwinder support for 64-bit SPARC (aka SPARCv9). The implementation was done on OpenBSD/sparc64, so it takes StackGhost into account: > > https://www.usenix.org/legacy/publications/library/proceedings/sec01/full_papers/frantzen/frantzen_html/index.html > > Since StackGhost xor's return addresses with a random cookie before storing them on the stack, the unwinder has to do some extra work to recover those. This is done by introducing a new kRegisterInCFADecrypt "location" type that is used to implement the DW_CFA_GNU_window_save opcode. That implementation is SPARC-specific, but should work for 32-bit SPARC as well. DW_CFA_GNU_window_save is only ever generated on SPARC as far as I know. Co-authored-by: Mark Kettenis Reviewed By: #libunwind, thesamesam, MaskRay, Arfrever Differential Revision: https://reviews.llvm.org/D116857
2022-01-27[unwind] fix build with GCC on PPC32Sam James1-1/+1
Originally reported downstream in Gentoo: https://bugs.gentoo.org/832140 ``` /var/tmp/portage/sys-libs/llvm-libunwind-13.0.0/work/libunwind/src/libunwind.cpp:77:3: error: #error Architecture not supported 77 | # error Architecture not supported | ^~~~~ [...] /var/tmp/portage/sys-libs/llvm-libunwind-13.0.0/work/libunwind/src/libunwind.cpp: In function ‘int __unw_init_local(unw_cursor_t*, unw_context_t*)’: /var/tmp/portage/sys-libs/llvm-libunwind-13.0.0/work/libunwind/src/libunwind.cpp:80:57: error: ‘REGISTER_KIND’ was not declared in this scope 80 | new (reinterpret_cast<UnwindCursor<LocalAddressSpace, REGISTER_KIND> *>(cursor)) | ^~~~~~~~~~~~~ [...] ``` PPC is actually a supported architecture, but GCC (tested with 11.2.0) on powerpc32 seems to only define: `__PPC__, _ARCH_PPC, __PPC, __powerpc` and //not// `__ppc__`. This instead uses `__powerpc__` which should be around on PPC32 and PPC64 (but we check it after PPC64, so it's fine). Signed-off-by: Sam James <sam@gentoo.org> Differential Revision: https://reviews.llvm.org/D118320
2021-11-18[libunwind] Add an interface for dynamic .eh_frame registrationPeter S. Housel1-0/+29
The libgcc runtime library provides __register_frame and __deregister_frame functions, which can be used by dynamic code generators to register an .eh_frame section, which contains one or more Call Frame Information records, each consisting of a Common Information Entry record followed by one or more Frame Description Entry records. This libunwind library also provides __register_frame and __deregister_frame functions, but they are aliases for __unw_add_dynamic_fde and __unw_remove_dynamic_fde and thus can only take a single FDE. This patch adds __unw_add_dynamic_eh_frame_section and __unw_remove_dynamic_eh_frame_section functions which explicitly use the .eh_frame format. Clients such as the ORCv2 platform and runtime can check for these functions and use them if unwinding is being provided by libunwind, or fall back to __register_frame and __deregister_frame if unwinding is provided by libgcc. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D111863
2021-11-17[runtimes][NFC] Remove filenames at the top of the license noticeLouis Dionne1-1/+1
We've stopped doing it in libc++ for a while now because these names would end up rotting as we move things around and copy/paste stuff. This cleans up all the existing files so as to stop the spreading as people copy-paste headers around.
2021-08-26[libunwind] Support stack unwind in CET environmentgejin1-1/+1
Control-flow Enforcement Technology (CET), published by Intel, introduces shadow stack feature aiming to ensure a return from a function is directed to where the function was called. In a CET enabled system, each function call will push return address into normal stack and shadow stack, when the function returns, the address stored in shadow stack will be popped and compared with the return address, program will fail if the 2 addresses don't match. In exception handling, the control flow may skip some stack frames and we must adjust shadow stack to avoid violating CET restriction. In order to achieve this, we count the number of stack frames skipped and adjust shadow stack by this number before jumping to landing pad. Reviewed By: hjl.tools, compnerd, MaskRay Differential Revision: https://reviews.llvm.org/D105968 Signed-off-by: gejin <ge.jin@intel.com>
2021-06-13unwind: allow building with GCCSaleem Abdulrasool1-2/+8
This was regressed in adf1561d6ce8. Since gcc does not support `__has_feature`, this adjusts the build to use the `__SANITIZE_ADDRESS__` macro which GCC defines to identify if ASAN is enabled (similar to `__has_feature`). This allows building libunwind with gcc again. Patch by Daniel Levin! Reviewed By: compnerd Differential Revision: https://reviews.llvm.org/D104176
2021-05-26[libunwind] Inform ASan that resumption is noreturnShoaib Meenai1-0/+7
If you're building libunwind instrumented with ASan, `_Unwind_RaiseException` will poison the stack and then transfer control in a manner which isn't understood by ASan, so the stack will remain poisoned. This can cause false positives, e.g. if you call an uninstrumented function (so it doesn't re-poison the stack) after catching an exception. Add a call to `__asan_handle_no_return` inside `__unw_resume` to get ASan to unpoison the stack and avoid this. `__unw_resume` seems like the appropriate place to make this call, since it's used for resumption by all unwind implementations except SJLJ. SJLJ uses `__builtin_longjmp` to handle resumption, which is already recognized as noreturn (and therefore ASan adds the `__asan_handle_no_return` call itself), so it doesn't need any special handling. PR32434 is somewhat similar (in particular needing a component built without ASan to trigger the bug), and rG781ef03e1012, the fix for that bug, adds an interceptor for `_Unwind_RaiseException`. This interceptor won't always be triggered though, e.g. if you statically link the unwinder into libc++abi in a way that prevents interposing the unwinder functions (e.g. marking the symbols as hidden, using `--exclude-libs`, or using `-Bsymbolic`). rG53335d6d86d5 makes `__cxa_throw` call `__asan_handle_no_return` explicitly, to similarly avoid relying on interception. Reviewed By: #libunwind, compnerd Differential Revision: https://reviews.llvm.org/D103002
2021-03-02[libunwind] This adds support in libunwind for rv32 hard floatKamlesh Kumar1-1/+1
and soft-float for both rv32 and rv64. Differential Revision: https://reviews.llvm.org/D80690
2021-01-17[VE] Support VE in libunwindKazushi (Jam) Marukawa1-0/+2
Modify libunwind to support SjLj exception handling routines for VE. In order to do that, we need to implement not only SjLj exception handling routines but also a Registers_ve class. This implementation of Registers_ve is incomplete. We will work on it later when we need backtrace in libunwind. Reviewed By: #libunwind, compnerd Differential Revision: https://reviews.llvm.org/D94591
2020-04-10[libunwind] add hexagon supportBrian Cain1-0/+2
2019-12-16[libunwind][RISCV] Add 64-bit RISC-V supportSam Elliott1-0/+2
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
2019-09-18unwind: remove a could of extraneous `else` (NFC)Saleem Abdulrasool1-4/+2
Simplify `if return else return` by removing the unnecessary `else`. llvm-svn: 372233
2019-04-11[libunwind] Fix the typo in unw_save_vfp_as_X aliasPetr Hosek1-1/+1
This was accidentaly introduced in r357640. llvm-svn: 358164
2019-04-03[libunwind] Export the unw_* symbols as weak symbolsPetr Hosek1-56/+58
libunwind defines the _Unwind_* ABI used by libc++abi. This ABI is a stable quasi-standard common between multiple implementations such as LLVM and GNU. The _U* symbol name space is also safely within the symbol name space that standard C & C++ reserve for the implementation. Futhermore, libunwind also defines several unw_* symbols, and references these from the _Unwind_* entry points so the standard/reserved part of the ABI is dependent on the unw_* part of the ABI. This is not OK for a C or C++ implementation. The unw_* symbols are reserved for C and extern "C" used by application code. This change renames each unw_* function to __unw* and adds a weak alias unw_* to keep the public <libunwind.h> ABI unchanged for backwards compatibility. Every reference to unw_* in the implementation has been changed to use __unw* so that if other unw_* definitions are in force because nothing uses <libunwind.h> in a particular program, no _Unwind* code path depends on any unw_* symbol. Furthemore, __unw_* symbols are hidden, which saves PLT overhead in the shared library case. In the future, we should cconsider untangling the unw_* API/ABI from the _Unwind_* API/ABI. The internal API backing the _Unwind_* ABI implementation should not rely on any nonstandard symbols not in the implementation-reserved name space. This would then allow separating the _Unwind_* API/ABI from unw_* entirely, but that's a more substantial change that's going to require more significant refactoring. Differential Revision: https://reviews.llvm.org/D59921 llvm-svn: 357640
2019-02-02[libunwind] Provide placement new definitionPetr Hosek1-6/+3
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
2019-02-02[libunwind] Remove the remote unwinding supportPetr Hosek1-87/+0
This is unfinished, unused and incomplete. This could be brought back in the future if there's a desire to build a more complete implementation, but at the moment it's just bitrotting. Differential Revision: https://reviews.llvm.org/D57252 llvm-svn: 352965
2019-01-29Drop the dependency on <algorithm>, add placement new inlinePetr Hosek1-4/+4
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
2019-01-28Revert "[libunwind] Drop the dependency on <algorithm>, add placement new ↵Petr Hosek1-4/+4
inline" This reverts commit r352384: this broke on ARM as UnwindCursor.hpp still has some C++ library dependencies. llvm-svn: 352427
2019-01-28[libunwind] Drop the dependency on <algorithm>, add placement new inlinePetr Hosek1-4/+4
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
2019-01-25[libunwind] Use placement new to avoid dependency C++ libraryPetr Hosek1-7/+10
The rest of libunwind already uses placement new, these are the only places where non-placement new is being used introducing undesirable C++ library dependency. Differential Revision: https://reviews.llvm.org/D57251 llvm-svn: 352245
2019-01-19Update more file headers across all of the LLVM projects in the monorepoChandler Carruth1-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
2019-01-14[Sparc] Add Sparc V8 supportDaniel Cederman1-0/+2
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
2019-01-10Revert "[Sparc] Add Sparc V8 support"Jorge Gorbe Moya1-2/+0
This reverts commit r350705. llvm-svn: 350787
2019-01-09[Sparc] Add Sparc V8 supportDaniel Cederman1-0/+2
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
2018-07-17The semantics of DW_CFA_GNU_args_size have changed subtile over theJoerg Sonnenberger1-1/+13
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
2018-05-15[libunwind][MIPS] Support MIPS floating-point registers for hard-float ABIs.John Baldwin1-3/+2
Summary: For MIPS ABIs with 64-bit floating point registers including newabi and O32 with 64-bit floating point registers, just save and restore the 32 floating-point registers as doubles. For O32 MIPS with 32-bit floating-point registers, save and restore the individual floating-point registers as "plain" registers. These registers are encoded as floats rather than doubles, but the DWARF unwinder assumes that floating-point registers are stored as doubles when reading them from memory (via AddressSpace::getDouble()). Treating the registers as "normal" registers instead causes the DWARF unwinder to fetch them from memory as a 32-bit register. This does mean that for O32 with 32-bit floating-point registers unw_get_fpreg() and unw_set_fpreg() do not work. One would have to use unw_get_reg() and unw_set_reg() instead. However, DWARF unwinding works correctly as the DWARF CFI emits records for individual 32-bit floating-point registers even when they are treated as doubles stored in paired registers. If the lack of unw_get/set_fpreg() becomes a pressing need in the future for O32 MIPS we could add in special handling to make it work. Reviewers: sdardis, compnerd Reviewed By: sdardis Differential Revision: https://reviews.llvm.org/D41968 llvm-svn: 332414
2018-02-27[libunwind][MIPS]: Add support for unwinding in N32 processes.John Baldwin1-2/+3
Summary: N32 uses the same register context as N64. However, N32 requires one change to properly fetch addresses from registers stored in memory. Since N32 is an ILP32 platform, getP() only fetches the first 32-bits of a stored register. For a big-endian platform this fetches the upper 32-bits which will be zero. To fix this, add a new getRegister() method to AddressSpace which is responsible for extracting the address stored in a register in memory. This matches getP() for all current ABIs except for N32 where it reads the 64-bit register and returns the low 32-bits as an address. The DwarfInstructions::getSavedRegister() method uses AddressSpace::getRegister() instead of AddressSpace::getP(). Reviewers: sdardis, compnerd Reviewed By: sdardis Differential Revision: https://reviews.llvm.org/D39074 llvm-svn: 326250
2018-01-09[libunwind][MIPS]: Rename Registers_mips_n64 to Registers_mips_newabi.John Baldwin1-1/+1
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
2018-01-02Reland [PPC64] Port to ppc64le - initial versionMartin Storsjo1-0/+2
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
2018-01-02Revert `rL321667: [PPC64] Port to ppc64le - initial version`Tim Shen1-2/+0
Differential Revision: https://reviews.llvm.org/D41386 llvm-svn: 321678
2018-01-02[PPC64] Port to ppc64le - initial versionMartin Storsjo1-0/+2
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
2017-12-12[libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.John Baldwin1-1/+5
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
2017-11-02Fix building for ARM with dwarf exception handlingMartin Storsjo1-1/+1
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
2017-10-30Change unw_word_t to always have the same size as the pointer sizeMartin Storsjo1-2/+2
This matches the original libunwind API. This also unifies the type between ARM EHABI and the other configurations, and allows getting rid of a number of casts in log messages. The cursor size updates for ppc and or1k are untested, but unw_proc_info_t shrinks by 4 uint64_t units on i386 at least. Differential Revision: https://reviews.llvm.org/D39365 llvm-svn: 316942
2017-09-26Skip building unused parts when targeting SJLJMartin Storsjo1-0/+2
When SJLJ exceptions are used, those functions aren't used. This fixes build failures on ARM with SJLJ enabled (e.g. on armv7/iOS) when built using the CMake project files. Differential Revision: https://reviews.llvm.org/D38249 llvm-svn: 314197
2017-03-31[libunwind] Clean up macro usage.Ranjeet Singh1-4/+4
Convention in libunwind is to use !defined(FOOT) not !FOO. Differential Revision: https://reviews.llvm.org/D31078 llvm-svn: 299225
2017-03-09Fix up the places where AddressSpace.hpp is included.Ed Schouten1-0/+1
The AddressSpace.hpp header declares two classes: LocalAddressSpace and RemoteAddressSpace. These classes are only used in a very small number of source files, but passed in as template arguments to many other classes. Let's go ahead and only include AddressSpace.hpp in source files where at least one of these two classes is mentioned. This gets rid of a cyclic header dependency that was already present, but only caused breakage on macOS until recently. Reported by: Marshall Clow llvm-svn: 297364
2017-01-21DWARF: allow enabling tracing at runtimeSaleem Abdulrasool1-0/+12
Introduce `logDWARF` and the associated environment variable `LIBUNWIND_PRINT_DWARF` to trace the CFI instructions. llvm-svn: 292722
2017-01-21rename OtherAddressSpace to RemoteAddressSpace; NFCSaleem Abdulrasool1-6/+6
llvm-svn: 292719