Commit Graph

200 Commits

Author SHA1 Message Date
Petr Hosek 63524f56f1 [libunwind][CMake] Use libc++ headers when available
libunwind depends on C++ library headers. When building libunwind
as part of LLVM and libc++ is available, use its headers.

Differential Revision: https://reviews.llvm.org/D29997

llvm-svn: 295285
2017-02-16 05:18:08 +00:00
Petr Hosek ce47cf3532 Revert "[libunwind][CMake] Use libc++ headers when available"
This causing build failure on sanitizer bots because of the unused
argument '-nostdinc++' during linking of libunwind.

This reverts commit 0e14fd1a1d37b9c6d55a2d3bc7649e5b39ce74d3.

llvm-svn: 295202
2017-02-15 17:15:41 +00:00
Petr Hosek 9eff8a336b [libunwind][CMake] Use libc++ headers when available
libunwind depends on C++ library headers. When building libunwind
as part of LLVM and libc++ is available, use its headers.

Differential Revision: https://reviews.llvm.org/D29800

llvm-svn: 295153
2017-02-15 06:41:57 +00:00
Petr Hosek 50b1a33211 Revert "[libunwind][CMake] Use libc++ headers when available"
This is causing build failure when building libc++abi with libunwind.

This reverts commit 42bf29501dfa79f211841de060386d539933e811.

llvm-svn: 294556
2017-02-09 03:56:47 +00:00
Petr Hosek 34f63ccc40 [libunwind][CMake] Use libc++ headers when available
libunwind depends on C++ library headers. When building libunwind
as part of LLVM and libc++ is available, use its headers.

Differential Revision: https://reviews.llvm.org/D29573

llvm-svn: 294554
2017-02-09 02:20:25 +00:00
Saleem Abdulrasool 2b2f4dadc4 Revert "DWARF: convert error logs to _LIBUNWIND_LOG"
This reverts SVN r292721.  Avoid the use of the GNU extension as the
preprocessor in C++11 mode requires at least one argument, and this
warning cannot be disabled, resulting in failing -Werror builds.

llvm-svn: 293257
2017-01-27 02:26:52 +00:00
Saleem Abdulrasool 9a75332cab DWARF: fix -Asserts builds
no-op the DWARF tracing macros in non-debug builds.

llvm-svn: 293008
2017-01-25 02:27:45 +00:00
Saleem Abdulrasool e6de7d333a DWARF: correct cast (NFC)
Change the case of a PRIu64 value from `long` to `uint64_t`.  NFC.

llvm-svn: 292728
2017-01-21 21:27:29 +00:00
Saleem Abdulrasool b64d3273a3 X86: swap EBP, ESP on !APPLE
Restore the `libunwind.h` enumeration values back to the inverted
values.  This diverges from the DWARF definition of the register values.
However, this allows our header to be compatible with other unwind
implementations (e.g. HP, GNU Savannah, GCC).

The register IDs are only swapped in the header and need to be unswapped
when accessing the unwind register file.  The flipped EBP and ESP only
applies on non-Apple x86 targets.

When optimizations were enabled, EBP and ESP would no longer be
equivalent.  As a result, the incorrect access on Linux would manifest
as a failure to unwind the stack.  We can now unwind the stack with and
without FPO on Linux x86.

Resolves PR30879!

llvm-svn: 292723
2017-01-21 16:22:59 +00:00
Saleem Abdulrasool c06f0cf88c DWARF: allow enabling tracing at runtime
Introduce `logDWARF` and the associated environment variable
`LIBUNWIND_PRINT_DWARF` to trace the CFI instructions.

llvm-svn: 292722
2017-01-21 16:22:57 +00:00
Saleem Abdulrasool c3bf7da9cf DWARF: convert error logs to _LIBUNWIND_LOG
Use the `_LIBUNWIND_LOG` macro instead of the explicit `fprintf` call.
NFC.

llvm-svn: 292721
2017-01-21 16:22:55 +00:00
Saleem Abdulrasool 8ecd010547 config: clean up some of the macro definition
Unify the definition of `_LIBUNWIND_LOG_NON_ZERO` to make it clear what
it is defined to and make the definition unconditional.  Reorder the
debug and tracing macros to be defined in the same order.  NFC.

llvm-svn: 292720
2017-01-21 16:22:53 +00:00
Saleem Abdulrasool eae1b66c1b rename OtherAddressSpace to RemoteAddressSpace; NFC
llvm-svn: 292719
2017-01-21 16:22:46 +00:00
Eric Fiselier b703fd32d6 Don't dump llvm-config --cmakedir output if command fails.
This patch adjusts the out-of-tree CMake configuration so that
the stderr output is ignored when an old llvm-config is found
that doesn't support --cmakedir.

llvm-svn: 291992
2017-01-14 03:46:05 +00:00
Hans Wennborg f501d07dbf Bump version to 5.0.0svn
llvm-svn: 291830
2017-01-12 21:37:55 +00:00
Michal Gorny 33f27fd842 [cmake] Obtain LLVM_CMAKE_PATH from llvm-config if available
Use the new --cmakedir option to obtain LLVM_CMAKE_PATH straight from
llvm-config. Fallback to local reconstruction if llvm-config does not
support this option.

llvm-svn: 291505
2017-01-09 23:27:04 +00:00
Saleem Abdulrasool f27bfd256b EHABI: mark some functions as exported
These are part of the EHABI specification and are exported to be available to
users.  Mark them as `_LIBUNWIND_EXPORT` like the rest of the unwind interfaces.

llvm-svn: 287283
2016-11-17 23:53:35 +00:00
Petr Hosek 92e71965ad [CMake] Get libunwind building under LLVM/runtimes
The new LLVM runtimes directory requires the same conventions to be
followed across the runtime projects. These changes make libunwind
build under the runtimes subdirectory.

This patch contains the following changes:

* Rename LLVM_CONFIG to LLVM_CONFIG_PATH
* Check if compiler supports C++11 (required by libunwind)

Differential Revision: https://reviews.llvm.org/D26360

llvm-svn: 286308
2016-11-08 23:02:49 +00:00
Marshall Clow cee23446e1 Add support for old versions of MacOS to libunwind. Fixes PR22203. Thanks to Jeremy for the bug report and the patch.
llvm-svn: 285845
2016-11-02 17:56:05 +00:00
Marshall Clow b8292c3d65 Add conditions for PPC to libunwind. Fixes PR22200. Thanks to Jeremy for the bug report and the patch.
llvm-svn: 285831
2016-11-02 16:39:55 +00:00
Nick Kledzik 56e6135774 fix _dyld_find_unwind_sections() for pre-10.7. Patch by Jeremy Sequoia
llvm-svn: 285636
2016-10-31 21:04:17 +00:00
Petr Hosek 93d28f3507 [libunwind] Add support for Fuchsia
Fuchsia is a new operating system which uses libunwind as unwinder.

Differential Revision: https://reviews.llvm.org/D25899

llvm-svn: 284951
2016-10-23 21:48:47 +00:00
Asiri Rathnayake 8295d54868 [libunwind] Add missing <stdint.h> include. NFC.
This missing include seems to cause compilation failures on older MacOS
versions (< 10.9). This is because r270692 has introduced uint64_t into
config.h without including this header.

Patch from: Jeremy Huddleston Sequoia (jeremyhu@apple.com)

llvm-svn: 284125
2016-10-13 14:32:24 +00:00
Ed Maste a2ebee6f50 libunwind: Add OpenBSD case for _Unwind_Ptr typedef
Patch by Mark Kettenis

llvm-svn: 282599
2016-09-28 15:37:21 +00:00
Ed Schouten 47ca99b372 Also use the proper register numbers on CloudABI.
Without this change applied, unw_step() fails to obtain the next frame
properly.

llvm-svn: 282589
2016-09-28 13:51:23 +00:00
Asiri Rathnayake 6264758cc8 [libunwind] Add support for a single-threaded libunwind build
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
2016-09-28 10:57:15 +00:00
Dimitry Andric 84af6d10a2 Add missing _US_ACTION_MASK constant to unwind.h
Summary:
During building of recent compiler-rt sources on FreeBSD for arm, I
noticed that our unwind.h (which originates in libunwind) was missing
the `_US_ACTION_MASK` constant:

    compiler-rt/lib/builtins/gcc_personality_v0.c:187:18: error: use of undeclared identifier '_US_ACTION_MASK'
        if ((state & _US_ACTION_MASK) != _US_UNWIND_FRAME_STARTING)
                     ^

It appears that both clang's internal unwind.h, and libgcc's unwind.h
define this constant as 3, so let's add this to libunwind's version too.

Reviewers: logan, kledzik, davide, emaste

Subscribers: joerg, davide, aemerson, emaste, llvm-commits

Differential Revision: https://reviews.llvm.org/D24222

llvm-svn: 280669
2016-09-05 18:01:13 +00:00
Ed Maste 92c948901a consistently add \n to log and trace messages
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
2016-08-30 15:38:10 +00:00
Ed Maste b0abba5c32 libunwind: fix X86 register numbers for FreeBSD/i386
For historical reasons i386 has ebp and esp swapped in the eh_frame
register numbering on at least Darwin.  That is:

                 Darwin      FreeBSD
        Reg #    eh_frame    eh_frame    DWARF
        =====    ========    ========    =====
          4        ebp         esp        esp
          5        esp         ebp        ebp

Although the UNW_X86_* constants are not intended to be coupled with
DWARF / eh_frame numbering they are currently conflated in libunwind.

Differential Revision:	https://reviews.llvm.org/D22508

llvm-svn: 280099
2016-08-30 15:10:08 +00:00
Ed Maste e8a15cef9d libunwind: correct 'libuwind' typo
There were several instances of libuwind (missing an "n"), dating to
the initial import of libunwind.

llvm-svn: 280086
2016-08-30 13:08:21 +00:00
Saleem Abdulrasool 9d5977b199 EHABI: fail on WMMX vops without WMMX support
When the unwinder is built without WMMX support, if we encounter a WMMX register
virtual operation, early rather than attempting to continue as we would not have
saved the register set anyways.  This should never come down this path, but,
just in case, help it abort more explicitly.

llvm-svn: 279941
2016-08-28 20:10:33 +00:00
Renato Golin 70984fed05 [ARM] Adding .arch directives around WMMX unwind code
Some unwind code is purposedly old enough to work on previous architecutres
and they're guaranteed to never trigger in newer architectures, so we need
to add .arch directives to tell the compiler/assembler that it's fine and we
know what we're doing.

Fixes PR29149.

llvm-svn: 279871
2016-08-26 21:45:39 +00:00
Saleem Abdulrasool c2f1e32365 EHABI: cover switch once more
When making WMMX support optional, we uncovered the switch.  Add the missing
entries.  Since the entry is a break leading to a dead path, it should get
optimized out yet retain the switch overage.

llvm-svn: 279180
2016-08-18 23:59:12 +00:00
Petr Hosek f3f5f1209e Allow building both shared and static library
This change allows building both shared and static version of libunwind
in a single build, sharing object files between both versions.

Differential Revision: https://reviews.llvm.org/D23233

llvm-svn: 278067
2016-08-08 22:55:48 +00:00
Eugene Zelenko 5608df9b6a CMakeLists.txt cleanups: synchronize version and CMake minimum required version with rest of LLVM, consistent spacing.
Differential revision: https://reviews.llvm.org/D23094

llvm-svn: 278029
2016-08-08 17:56:28 +00:00
Saleem Abdulrasool f7e4524910 unwind: disable executable stacks
Similar to compiler-rt, ensure that we disable executable stacks for the custom
assembly.

llvm-svn: 277868
2016-08-05 21:35:28 +00:00
Ed Maste 1ed39291a5 libunwind: correct return code in unwinding trace log message
llvm-svn: 277215
2016-07-29 21:24:19 +00:00
Oliver Stannard 1224c809f1 [libunwind][ARM] Add support for Thumb1 targets
The Thumb1 version of the code for saving and restoring the unwind
context has a few bugs which prevent it from working:
* It uses the STM instruction without writeback, which is not valid for Thumb1
  (It was introduced in Thumb2).
* It only saves/restores the low 8 registers, the sp and the lr, so if a
  program uses r8-r12 they will not be correctly restored when throwing an
  exception.

There aren't currently any Thumb1 build-bots to test this, but we have
been successfully running the libc++abi and libc++ test suites on
Cortex-M0 models, as well as some other test suites that use C++
exceptions on a downstream version of libunwind with this patch applied.

Differential Revision: https://reviews.llvm.org/D22292

llvm-svn: 276625
2016-07-25 09:21:56 +00:00
Eric Fiselier 19f802ff68 [libunwind] Properly align _Unwind_Exception.
Summary: _Unwind_Exception is required to be double word aligned. Currently the struct is under aligned.

Reviewers: mclow.lists, compnerd, kledzik, emaste

Subscribers: emaste, cfe-commits

Differential Revision: https://reviews.llvm.org/D22543

llvm-svn: 276215
2016-07-20 23:56:42 +00:00
Eric Fiselier de337b876f Update .arcconfig
llvm-svn: 276214
2016-07-20 23:56:17 +00:00
Ed Maste 41020b94a3 libunwind: limit stack usage in unwind cursor
Obtained from FreeBSD SVN r302475

Differential Revision:	https://reviews.llvm.org/D22570

llvm-svn: 276128
2016-07-20 15:19:09 +00:00
Ed Maste 5c5e51459f libunwind: sync some coments with NetBSD's version
NetBSD's system unwinder is a modified version of LLVM's libunwind.
Slightly reduce diffs by updating comments to match theirs where
appropriate.

llvm-svn: 275997
2016-07-19 17:28:38 +00:00
Ed Maste c073b1bac9 libunwind: Use conventional DWARF capitalization in comments and errors
llvm-svn: 275996
2016-07-19 17:15:50 +00:00
Asiri Rathnayake 0bdb5f971b [PATCH] [libunwind][ehabi] Use early returns where possible.
Just a minor code cleanup. NFC.

llvm-svn: 274840
2016-07-08 12:13:31 +00:00
Asiri Rathnayake f33c3423ec [libunwind][ARM] Improve unwinder stack usage - Make WMMX support optional
These registers are only available on a limited set of ARM targets (those
based on XScale). Other targets should not have to pay the cost of these.

This patch shaves off about ~300 bytes of stack usage and ~1KB of code-size.

Differential revision: http://reviews.llvm.org/D21991
Reviewers: bcraig, compnerd

Change-Id: I2d7a1911a193bd70b123e78747e1a7d1482463c7
llvm-svn: 274744
2016-07-07 10:55:39 +00:00
Asiri Rathnayake af914fa2db [libunwind] Improve unwinder stack usage - III
Implement the same optimization committed under r271004 on non-EHABI,
non-SJLJ unwinder as well.

Change-Id: I7f80ed91a75d1e778b50ba87cf8fb68658a083c7
llvm-svn: 272680
2016-06-14 15:51:01 +00:00
Asiri Rathnayake b3698ba361 [libunwind] Remove unused code.
The whole file is guarded with #if _LIBUNWIND_ARM_EHABI, and then in the
middle we have these two blocks, which render them pretty unused. An
artefact of a refactoring it seems.

NFC.

llvm-svn: 271737
2016-06-03 20:57:48 +00:00
Eric Fiselier b1403c9d99 Attempt to fix libunwind build
llvm-svn: 271466
2016-06-02 01:50:10 +00:00
Eric Fiselier b7a373971d Add status/warning message for 32 bit builds
llvm-svn: 271462
2016-06-02 01:19:52 +00:00
Eric Fiselier 0447bde044 [libunwind] Allow target flags to affect CMake configuration tests
Summary:
This patch changes the libunwind CMake so that it adds certain target flags like '-m32' or '--gcc-toolchain' before including config-ix.cmake.
Since these flags can affect things like check_library_exists([...]) they needed to be added before the tests are performed.

Additionally this patch adds LIBUNWIND_BUILD_32_BITS which defaults to LLVM_BUILD_32_BITS.

This patch fixes:

https://llvm.org/bugs/show_bug.cgi?id=27950
https://llvm.org/bugs/show_bug.cgi?id=27959

Reviewers: jroelofs, danalbert, bcraig, rmaprath, compnerd

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20889

llvm-svn: 271458
2016-06-02 01:02:10 +00:00
Asiri Rathnayake 45e59f7198 [libunwind] Improve unwinder stack usage - II
unwind_phase1 and unwind_phase2 allocate their own copies of unw_cursor_t buffers
on the stack. This can blow-up stack usage of the unwinder depending on how these
two functions get inlined into _Unwind_RaiseException. Clang seems to inline
unwind_phase1 into _Unwind_RaiseException but not unwind_phase2, thus creating
two unw_cursor_t buffers on the stack.

One way to work-around this problem is to mark both unwind_phase1 and
unwind_phase2 as noinline. This patch takes the less compiler-dependent approach
and explicitly allocate a unw_cursor_t buffer and pass that into unwind_phase1
and unwind_phase2 functions.

A follow-up patch will replicate this behavior for the non-EHABI and non-SJLJ
implementations.

Reviewers: jroelofs, bcraig.

Differential revision: http://reviews.llvm.org/D20320

llvm-svn: 271004
2016-05-27 15:41:45 +00:00
Asiri Rathnayake 85624c5de3 [libunwind] Disable cross-unwinding by default.
Cross unwinding requires larger sizes for unw_context_t and unw_cursor_t
buffers (large enough to hold the VRS of any architecture). This is not
desirable for the most common situation where libunwind is used for native
unwinding only.

This patch makes native unwinding the default build configuration. This
will start testing the tigher (compile-time) bounds of unw_context_t
and unw_cursor_t buffers for each architecture.

Change-Id: Ic61c476a75603ca4812959c233cfe56f83dc0b00
llvm-svn: 270972
2016-05-27 08:29:27 +00:00
Asiri Rathnayake 88fe85071d Use size_t to store the results of sizeof calculations.
NFC.

llvm-svn: 270927
2016-05-26 21:56:04 +00:00
Asiri Rathnayake c6a4ab0ce3 Fix gcc libunwind build.
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
2016-05-26 21:45:54 +00:00
Asiri Rathnayake 54387eef07 Introduce a native-only unwinder build.
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
2016-05-25 12:36:34 +00:00
Saleem Abdulrasool 9a6a8eaf07 unwind: remove last instance of -Wexpansion-to-defined
This unifies the definition of _LIBUNWIND_BUILD_SJLJ_APIS.  It also further
generalises the definition to allow building these APIs on non-Apple targets
when `-fsjlj-excceptions` is used.  The header is now clean of macros which
expand to defined checks.

llvm-svn: 267509
2016-04-26 01:11:29 +00:00
Saleem Abdulrasool 2d59e711a7 unwind: remove unnecessary header
Availablity.h is not used within config.h.  The locations which use the
availability infrastructure already include the necessary header(s).  NFC.

llvm-svn: 267365
2016-04-24 21:01:04 +00:00
Saleem Abdulrasool 03a061ffeb unwind: unify _LIBUNWIND_ABORT
Rather than use the `__assert_rtn` on libSystem based targets and a local
`assert_rtn` function on others, expand the function definition into a macro
which will perform the writing to stderr and then abort.  This unifies the
definition and behaviour across targets.

Ensure that we flush stderr prior to aborting.

llvm-svn: 267364
2016-04-24 21:00:59 +00:00
Saleem Abdulrasool 39d86f44cb unwind: unify some more macros
The macros were defined identically across both cases.  Unify the definitions to
have a single definition for _LIBUWNIND_{HIDDEN,EXPORT} and _LIBUNWIND_LOG.
NFC.

llvm-svn: 267169
2016-04-22 17:11:05 +00:00
Saleem Abdulrasool 0195c5e796 unwind: remove another instance of -Wexpansion-to-defined
Remove the use of undefined behaviour in the c preprocessor by always defining
the value according to the state that was being checked.  NFC.

llvm-svn: 266927
2016-04-20 22:18:50 +00:00
Saleem Abdulrasool cb06f7511c unwind: unify the definition of _LIBUNWIND_SUPPORT_FRAME_APIS
Unify the definition of the _LIBUNWIND_SUPPORT_FRAME_APIS macro.  This is in
preparation to remove another instance of -Wexpansion-to-defined.  NFC.

llvm-svn: 266926
2016-04-20 22:18:47 +00:00
Saleem Abdulrasool a0ec6a58f5 unwind: remove a second instance of -Wexpansion-to-defined
Remove the use of undefined behaviour in the c preprocessor by always defining
the value according to the state that was being checked.  NFC.

llvm-svn: 266916
2016-04-20 20:54:55 +00:00
Saleem Abdulrasool 87bd085e88 unwind: remove an instance of -Wexpansion-to-defined
This follows the pattern in the Apple clause duplicating a tuple of definitions.
However, it will define them to a value rather than a defined check to remove
the `-Wexpansion-to-defined` warning (which may be treated as an error).

This also opens the door to unifying the two code paths into one.

NFC.

llvm-svn: 266915
2016-04-20 20:54:51 +00:00
Saleem Abdulrasool 62f3726365 unwind: unify _LIBUNWIND_SUPPORT_DWARF_UNWIND
Join the two paths for this macro.  At the end of the day, the difference was
that MIPS and ARM on Apple have different behaviour.  This is a setup change to
remove an instance of -Wexpansion-to-defined.  NFC.

llvm-svn: 266913
2016-04-20 20:53:40 +00:00
Renato Golin a6a92a4421 [AArch64] Fix libunwind build when using GNU assembler
Use x29 and x30 for fp and lr respectively.

This does not change the code generation with integrated asm
but using x30 and x29 helps compile the code with gnu as. Currently gas
fails to assemble this code with errors as below.

Error: operand X should be an integer register.

Newer versions of binutils should be fixed, but enough exists in the wild
to make this change harmless and worthy.

Patch by Khem Raj.

llvm-svn: 260595
2016-02-11 21:22:57 +00:00
Kamil Rytarowski c94bd04802 Introduce NetBSD support
Current FreeBSD and NetBSD code is compatible.

llvm-svn: 260001
2016-02-06 18:19:29 +00:00
Kamil Rytarowski d08eabfeb5 Adapt LLVM_CMAKE_PATH for recent cmake path changes
Current LLVM installs CMake files under lib/cmake/llvm.

llvm-svn: 259994
2016-02-06 16:23:18 +00:00
Evgeniy Stepanov 9b44fa87f3 Replace cmake check for printf with a check for fopen.
Printf is a builtin, and the check fails with -Werror because of a clang
warning about an incompatible redeclaration.

llvm-svn: 255188
2015-12-10 00:47:08 +00:00
Peter Zotov b0342a66a0 Make it possible to use libunwind without heap.
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
2015-11-09 06:57:29 +00:00
Ed Maste 5f1896a1ab Add FreeBSD _Unwind_Ptr typedef
Differential Revision:	http://reviews.llvm.org/D13820

llvm-svn: 250541
2015-10-16 19:40:09 +00:00
Vasileios Kalintiris 8518eb54f3 unwind: Allow the building of libunwind for MIPS.
Summary:
Currently, libunwind doesn't support MIPS. However, with this patch
we do allow the library to build, and we warn the user about the lack of
support for MIPS. Also, the dummy unw_getcontext() implementation for MIPS just
traps on function entry in order to avoid any confusion with silent/weird
failures at runtime.

This allows us to test an LLVM-based toolchain without the dependency on a
GCC toolchain. Of course, C++ exception handling and other things that depend
on stack unwinding will not work until we add a proper implementation of the
stub functions.

Reviewers: compnerd, logan

Subscribers: dsanders, llvm-commits

Differential Revision: http://reviews.llvm.org/D13160

llvm-svn: 248673
2015-09-26 18:26:01 +00:00
Saleem Abdulrasool 520aaa2f7d unwind: cleanup -Wunused-parameter
Cleanup a number of `-Wunused-parameter` warnings.  NFC.

llvm-svn: 246528
2015-09-01 04:29:03 +00:00
Peter Zotov ce4c5c9849 [libunwind] Add support for OpenRISC 1000.
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
2015-08-31 05:26:37 +00:00
Peter Zotov 43ad01462a [libunwind] Remove unused includes.
llvm-svn: 246143
2015-08-27 06:58:31 +00:00
Saleem Abdulrasool fddd0e66de unwind: fix invalid memory access
Fix out-of-bounds array access when setting arm float registers.

Patch by Leandro Graciá Gil!

llvm-svn: 245665
2015-08-21 03:21:31 +00:00
Ed Maste ef766a7e70 Enable zero-cost exceptions on non-Apple arm64 platforms
Use the canonical __aarch64__ predefined macro for 64-bit ARM. Apple-
specific cases are left as __arm64__. Also add an #error for unsupported
architectures to catch this sort of case in the future.

Differential Revision: http://reviews.llvm.org/D12005

llvm-svn: 244893
2015-08-13 14:21:03 +00:00
Ed Maste 76050da17e Correct sense of unwind return address register range assertion
I encountered this on FreeBSD/arm64, and then found the same issue was
reported by Daniil Troshkov.

llvm-svn: 244892
2015-08-13 13:45:45 +00:00
Tanya Lattner d93178de50 Revert test commit.
llvm-svn: 244297
2015-08-06 23:31:37 +00:00
Tanya Lattner 901f3c7bc0 Test commit
llvm-svn: 244296
2015-08-06 23:30:28 +00:00
Renato Golin 14c3c4bb85 [ARM/Unwind] Fix wrong usage of write-back on register save
The register save routine in libunwind was using write-back addressing
mode to r0 for thumb, when that was not only different from the ARM
version and more importantly the register restore, but also saving the
wrong address.

Patch by Manuel Freiberger.

Fixes PR24331.

llvm-svn: 244237
2015-08-06 18:15:17 +00:00
Tanya Lattner c1452f80cf Update to new lists.llvm.org
llvm-svn: 244005
2015-08-05 04:01:47 +00:00
Renato Golin 57cb9919c5 [libunwind] Flip order of extern "C" and attribute(visibility)
GCC doesn't seems to like having the attribute before extern, but
Clang accepts it either way. This patch makes it compile on both.

llvm-svn: 243147
2015-07-24 19:29:05 +00:00
Logan Chien ff8fbf9f90 unwind: Fix libc++abi and libgcc build.
To build libc++abi without libunwind, we should make sure that all
function calls to _Unwind_{Get,Set}{GR,IP}() are inlined as function
calls to _Unwind_VRS_{Get,Set}().  Otherwise, libc++abi.so will fail to
link since libgcc does not provide these symbol at all.

This commit fixes the problem by providing both the inlined version and
exported version.

llvm-svn: 243073
2015-07-24 00:16:48 +00:00
Hans Wennborg 483d4ed212 Update version to 3.8.0svn
llvm-svn: 242942
2015-07-22 21:36:42 +00:00
Logan Chien 5191fe9509 libunwind: Introduce __libunwind_config.h.
Introduce __libunwind_config.h to avoid cross repository circular
dependency with libcxxabi.

llvm-svn: 242642
2015-07-19 15:23:10 +00:00
Logan Chien 549d405877 Fix unw_getcontext() return value on AArch64.
unw_getcontext() should return UNW_ESUCCESS on success.  Therefore, the
assembly for AArch64 is incorrect because "ldr x0, #0" is a PC-relative
load instead of an immediate value load.

llvm-svn: 240648
2015-06-25 15:12:46 +00:00
Logan Chien aa938fa6b6 Avoid C99 for-declaration statement in C files. (NFC)
To compile libunwind with gcc/g++ 4.9, it is required to avoid the
for-declaration statement from C99.

llvm-svn: 240609
2015-06-25 00:05:24 +00:00
Logan Chien b08cf1cfd2 Code cleanup: Reindent statements.
llvm-svn: 238656
2015-05-30 14:00:39 +00:00
Logan Chien 7fab97f364 libunwind: Fix unw_step() for ARM EHABI.
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
2015-05-29 15:33:38 +00:00
Logan Chien c6ec96f9be Code cleanup: Remove duplicated line.
llvm-svn: 237542
2015-05-17 13:49:18 +00:00
Saleem Abdulrasool 5ccb0b5f87 unwind: permit building against libstdc++
Include algorithm early as otherwise you get a number of particularly unhelpful
messages about failed static assertions.  This fixes compilation on Linux with
gcc.

llvm-svn: 237002
2015-05-11 16:35:13 +00:00
Anton Korobeynikov 398ae2dee1 Add ARC config
llvm-svn: 236935
2015-05-09 20:56:15 +00:00
Saleem Abdulrasool 0c809e87be unwind: add a .clang-format
This just copies the default clang-format from the LLVM project.  Many
developers use clang-format to ensure that the code is appropriately formatted,
and this commit should also test the git-svn bridge.

llvm-svn: 236767
2015-05-07 19:50:18 +00:00
Viktor Kutuzov 66f711d185 Fix libunwind to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D9272

llvm-svn: 236585
2015-05-06 10:32:28 +00:00
Ed Schouten 8fd97a3ade Make the .eh_frame_hdr code work on FreeBSD as well.
We currently only include <link.h> on CloudABI and Linux. We can enable
it on FreeBSD as well, as it also supports the dl_iterate_phdr()
function that's provided by <link.h>.

FreeBSD, however, does not provide the ElfW() macro. Instead, the
host-specific ELF datastructures are named just Elf_XXX in addition to
the host-independent Elf32_XXX and Elf64_XXX types.

Differential Revision:	http://reviews.llvm.org/D8169
Approved by:	emaste

llvm-svn: 236154
2015-04-29 20:43:44 +00:00
Saleem Abdulrasool 93174d9542 unwind: remove inclusion of private_typeinfo.h
This include is not currently used.  It is intended for type info based
switching, which is part of the EHABI specification.  However, the unwinder does
not currently support this functionality. This backwards dependency into
libc++abi is currently causing a buildbot failure, remove it until we have a
better solution.

llvm-svn: 235893
2015-04-27 16:51:52 +00:00
Saleem Abdulrasool ea9c4fc75d unwind: clean up warnings from the build
Now thta the build is split, clean up some of the warnings in the build:
  cc1: warning: command line option '-nostdinc++' is valid for C++/ObjC++ but not for C
  cc1: warning: command line option '-fno-rtti' is valid for C++/ObjC++ but not for C

Append the C++ specific flags specifically to the C++ sources.  Avoids the
spurious warnings due to invalid flags being passed during the compilation of
C++ sources.

llvm-svn: 235797
2015-04-25 02:06:15 +00:00
Saleem Abdulrasool c5d132b336 libunwind: add new build logic
This replicates most of the build infrastructure from libc++abi ported to
libunwind.  This allows building libunwind without requiring libc++abi.

llvm-svn: 235795
2015-04-25 01:46:35 +00:00
Saleem Abdulrasool a211afa448 unwind: remove libc++abi tests
These are related to libc++abi's personality routine and not core unwinding.
These have been restored in libc++abi, and are no longer needed here.

llvm-svn: 235766
2015-04-24 20:21:43 +00:00
Saleem Abdulrasool b1b1911777 unwind: move src/Unwind, include/, and test/ unwind content
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
2015-04-24 19:39:17 +00:00