Commit Graph

420 Commits

Author SHA1 Message Date
Renato Golin fab3c735c3 Update copyright year to 2015.
llvm-svn: 232095
2015-03-12 20:13:54 +00:00
Eric Fiselier fe2f1f095f Remove unneeded const_cast in readPointerHelper. Pointed out by jroelofs
llvm-svn: 231852
2015-03-10 21:32:53 +00:00
Eric Fiselier e6cdf34116 [libcxx] Fix PR21580 - Undefined behavior in readEncodedPointer()
Summary: This patch fixes a bug in `readEncodedPointer()` where it would read from memory that was not suitably aligned. This patch fixes it by using memcpy.

Reviewers: danalbert, echristo, compnerd, mclow.lists

Reviewed By: compnerd, mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 231839
2015-03-10 20:43:34 +00:00
Saleem Abdulrasool 762ff68a95 Unwind: define more interfaces more often
These are also part of the Unwind interfaces.  However, their implementation is
different in EHABI vs frame tables based exception handling.  Always provide a
definition.  This partially undoes a movement change from earlier to make the
handling a bit simpler rather than grouping the two implementations together.

llvm-svn: 231690
2015-03-09 19:35:12 +00:00
Saleem Abdulrasool d9e577933b Unwind: always define unwind APIs
These interfaces are not zero cost related, but rather generic unwind APIs used
by consumers of the Unwind library.  Always provide the definition as they are
needed for both Zero Cost and Frame Table based implementations.

llvm-svn: 231666
2015-03-09 16:46:43 +00:00
Saleem Abdulrasool a99e152e80 Unwind: remove unnecessary check
Linux/GNU on AArch64 EH ABI Level III is implemented using exception frame
tables as defined in LSB II.11.6.  The exception frame tables use the DWARF
Exception Header Encoding as described in LSB II.11.5.1.  We already defined the
appropriate definition _LIBUNWIND_SUPPORT_DWARF_UNWIND to enable this.

llvm-svn: 231580
2015-03-07 22:21:31 +00:00
Saleem Abdulrasool af7e539595 Unwind: tweak register handling for AArch64
AArch64 uses // as the comment character (although, Darwin uses ;).  However,
since we are using the C preprocessor on these files, // can be used as the
comment character across the board.

Tweak the platform guard to recognise __aarch64__ as well as __arm64__ for the
platform identifier.

llvm-svn: 231578
2015-03-07 21:36:08 +00:00
Nick Lewycky 5b2d125c92 Fix build with GCC:
- GCC doesn't support #pragma mark, only Apple GCC and clang. Wrap the pragma mark's in #if 0 to make gcc ignore them but xcode still see them.
 - Wrap a bunch of "#pragma clang" lines in #ifdef __clang__.
 - Pacify gcc's -Wparenthesis in a case where it's quite reasonable.

llvm-svn: 231344
2015-03-05 02:56:05 +00:00
Eric Fiselier 14dbeaadc1 [libcxxabi] Build both static and shared versions of libc++abi by default.
Summary:
This patch builds both static and shared versions of libc++abi by default. It adds/repurposes the following cmake options:
* `LIBCXXABI_ENABLE_SHARED`: Enable/disable building the shared library. (Previously using `OFF` would build the static library instead)
* `LIBCXXABI_ENABLE_STATIC`: Enable/disable building the static library.

This patch also re-purposes the CMake target `cxxabi` to be a meta-target for `cxxabi_shared` and `cxxabi_static`. This could potentially break other builds that depend on `cxxabi` being a library target. We will need to apply a patch to libc++'s CMake before committing this change. 

Running the tests is still only supported when the shared version is built. Support for running the tests against the static library will come in another patch.


Reviewers: jroelofs, mclow.lists, danalbert, compnerd

Reviewed By: danalbert, compnerd

Subscribers: cfe-commits

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

llvm-svn: 231075
2015-03-03 15:59:09 +00:00
Saleem Abdulrasool 48205982a3 Unwind: make it build on Darwin again
The support for the LSB eh_frame_hdr extension was overzealous in trying to
include headers.  Be more careful to permit building on Darwin.

llvm-svn: 230837
2015-02-28 02:23:54 +00:00
Dan Albert 198d366fad Add .eh_frame_hdr search to Linux unwinder.
This improves the performance of unwinding on DWARF based targets. The
32-bit x86 support for scanning the full eh_frame
(CFI_Parser::findFDE) apparently does not work (at least not on
Linux). Since the eh_frame_hdr code delegates to that, this still
doesn't work for x86 Linux, but it has been tested on x86_64 Linux and
aarch64 Android.

llvm-svn: 230802
2015-02-27 22:21:07 +00:00
Jonathan Roelofs 0b57fc3147 Add remote testing support to the lit config
Now that the corresponding support in libcxx has landed (r230592), adding
support here is pretty simple.

llvm-svn: 230643
2015-02-26 15:55:01 +00:00
Saleem Abdulrasool bd04c44f48 Unwind: clean up some GCC warnings
This cleans up a set of -Wsign-conversion, -Wint-conversion, and -Wformat
warnings from GCC 4.9.2 on Linux.  NFC.

llvm-svn: 230606
2015-02-26 04:01:37 +00:00
Jonathan Roelofs ea163d9fa8 Add .fpu directives to ARM unwind save & restore functions.
TODO: The iwmmx register save & restore functions still need the same treatment.
      I didn't do that in this patch because the integrated assembler has a bug
      where it refuses to build them on -march=armv6-m, even with
         .march armv5t
         .arm
      in front of those functions.

This should fix PR22384.

http://reviews.llvm.org/D7258

llvm-svn: 230360
2015-02-24 20:09:29 +00:00
Eric Fiselier 64cfdfea5a Add temporary workaround for missing symbol __cxa_throw_bad_new_array_length on OS X.
llvm-svn: 230125
2015-02-21 04:30:36 +00:00
Sergey Dmitrouk 0aa66cf8f8 Do not add -fno-exceptions without -funwind-tables
Adding just -fno-exceptions breaks libunwind in quite mysterious way
when it's there, but exception handling doesn't work because of dummy
unwind tables.

Also as using exceptions implies references to symbols defined in
libcxx, abort build of libcxxabi as shared library if we have to keep
exceptions (when compiler supports -fno-exceptions, but not
-funwind-tables; one example would be a cross-compiler, in which case
testing for -funwind-tables flag by CMake actually requires libunwind to
be available before it's built).

llvm-svn: 229427
2015-02-16 19:51:06 +00:00
Jonathan Roelofs d76078f81b Moar post-commit review.
Apparently typing is hard.

llvm-svn: 229216
2015-02-14 02:02:56 +00:00
Jonathan Roelofs bb755d614a Address post-commit review comments
llvm-svn: 229207
2015-02-14 01:38:35 +00:00
Jonathan Roelofs c1d025fb61 Make the unwinder build on thumbv6-m with the integrated assembler.
http://reviews.llvm.org/D7630

llvm-svn: 229194
2015-02-14 00:21:03 +00:00
Saleem Abdulrasool 9dd5ca1fe8 unwind: always export unw_local_addr_space
It seems that the remote unwinder is entirely unused at this moment.
unw_local_addr_space was referencing sThisAddressSpace which use to be a static
in global namespace.  It has since then become a member variable of
LocalAddressSpace.  Update this definition and always export it (needed to
implement unw_get_proc_info_by_ip for ARM).

llvm-svn: 229133
2015-02-13 19:04:48 +00:00
Saleem Abdulrasool ebfe815f5c unwind: use sizeof() instead of hardcoded sizes
The statically allocated strings have a fixed size which can be computed using
the sizeof operator rather than duplicating the allocation size which can drift.
NFC.

llvm-svn: 229126
2015-02-13 17:36:11 +00:00
Ed Schouten 12dc2c4f3b Don't use bzero() and strcpy().
Instead of bzero(), we can simply use memset(). The strcpy() calls are
unneeded, as we can simply keep track of a pointer to the constant
strings we are copying.

Reviewed by:	Jonathan Roelofs

llvm-svn: 229074
2015-02-13 07:18:22 +00:00
Saleem Abdulrasool 3db633ab81 unwind: use explicit memcpy for register saving
Convert the register saving code to use an explicit memcpy rather than the
implicit memcpy from the assignment.  This avoids warnings from -Wcast-qual on
GCC and makes the code more explicit.  Furthermore, use sizeof to calculate the
offsets rather than adding magic numbers, improving legibility of the code.
NFC.

llvm-svn: 228904
2015-02-12 04:25:05 +00:00
Saleem Abdulrasool a6b32ccec4 unwind: move exported APIs out of header
Ideally, we would do something like inline __declspec(dllexport) to ensure that
the symbol was inlined within libunwind as well as emitted into the final DSO.
This simply moves the definition out of the header to ensure that the *public*
interfaces are defined and exported into the final DSO.

This change also has "gratuitous" code movement so that the EHABI and generic
implementations are co-located making it easier to find them.

The movement from the header has one minor change introduced into the code:
additional tracing to mirror the behaviour of the non-EHABI interfaces.

llvm-svn: 228903
2015-02-12 04:25:03 +00:00
Saleem Abdulrasool a9bd96e76a unwind: tweak inclusion ordering to work around GCC
This is a slightly convoluted workaround.  GCC does not support the
__has_feature extension of clang, and this results in some issues with
static_asserts.  config.h defines static_assert as a macro with a C-specific
trickery.  This then propagates into the C++ headers included after config.h,
which are used with C++11 mode, enabling constexpr constructors.  The macro'ed
static_assert does not get treated as the static_assert builtin, and will cause
an error due to a non-empty constexpr constructor.  Tweaking the include order
permits the use of libc++ headers to build libunwind with GCC on Linux.

llvm-svn: 228809
2015-02-11 05:20:53 +00:00
Saleem Abdulrasool b8a83fdf5c unwind: clean up some -Werror=return-type warnings
Mark that the functions always return or abort if the register class is
unhandled.  Avoid placing the abort in the switch to permit -Wswitch-cover to
catch missing values.

llvm-svn: 228808
2015-02-11 05:20:50 +00:00
Saleem Abdulrasool e133422fa4 unwind: clean up more -Wformat warnings
This makes compilation on ARM -Wformat clean with GCC.  NFC.

llvm-svn: 228807
2015-02-11 05:20:47 +00:00
Saleem Abdulrasool 7ebbcd968b unwind: clean up straggling -Wundef warning
Conservatively define __ARM_ARCH to 4 in the case that it is undefined (e.g.
with GCC).

llvm-svn: 228806
2015-02-11 05:20:44 +00:00
Saleem Abdulrasool b5c3e56b38 unwind: silence -Wconversion warnings
Clean up implicit uint8_t to uint32_t conversion warnings identified by GCC.

llvm-svn: 228805
2015-02-11 05:20:42 +00:00
Eric Fiselier 1dfbfb8c9e Fix libcxxabi's library and object root for tests.
llvm-svn: 228779
2015-02-11 01:07:48 +00:00
Saleem Abdulrasool bb0aba7a00 unwind: improve compilation on Linux with gcc
gcc still defaults to C89 which does not support BCPL style comments.  This
splits up the sources list in CMakeLists and selectively adds compile flags for
using C99 which avoids a number of warnings in -Wpedantic mode.  NFC.

llvm-svn: 228665
2015-02-10 03:43:33 +00:00
Saleem Abdulrasool 10abd2ad1c unwind: clean up some stray semicolons
Clean up some stray semicolons found by GCC 4.9 -Wpedantic.  NFC.

llvm-svn: 228664
2015-02-10 03:43:31 +00:00
Saleem Abdulrasool 1dd9f685f4 unwind: clean up -Wundef warnings
The unified register management interfaces had multiple naked macros for
conditional logic.  This cleans them up to use the defined() form, avoiding
-Wundef warnings.  NFC.

llvm-svn: 228663
2015-02-10 03:43:28 +00:00
Saleem Abdulrasool 2fdc44021f unwind: fix -Wformat warnings from gcc
Clean up the format specifiers for pedantic compilation with gcc 4.9 on Linux.
NFC.

llvm-svn: 228662
2015-02-10 03:43:23 +00:00
Saleem Abdulrasool a805955910 Unwind: hoist placement delete into base class
Move the placement delete into the base class.  This permits the proper emission
of the virtual destructor in UnwindCursor by using the class specific placement
delete instead of the normal single element ::operator delete.  With this patch,
we can finally build libunwind as a DSO without a runtime dependency on
libc++/libc++abi.

llvm-svn: 228436
2015-02-06 20:34:17 +00:00
Saleem Abdulrasool fed959e02e Unwind: replace pure virtual functions with aborts
Convert all pure virtual functions in the UnwindCursor with implementations that
abort.  This is effectively manually replicating the current behaviour, whilst
removing the compiler generated calls to __cxa_pure_virtual, which will abort at
runtime with a message indicating that a pure virtual call was made.

The whitespace changes are the result of executing clang-format over the changed
region.

llvm-svn: 228423
2015-02-06 18:48:07 +00:00
Saleem Abdulrasool 123f44a2f6 unwind: use -fno-rtti -fno-exceptions -funwind-tables
RTTI and exceptions are not needed for the unwinder, the use of C++ there is for
very specific cases, and does not require dynamic_cast nor does it use
exceptions.  This avoids unnecessary references to type information being
emitted.

llvm-svn: 228408
2015-02-06 17:47:57 +00:00
Matthias Braun 8a3e33945e Fix build for apple machines.
HAVE_CRASHREPORTERCLIENT_H was potentially undefined and -Wundef is
enabled now.

llvm-svn: 228368
2015-02-06 01:25:08 +00:00
Dan Albert 02bc357b6c Fix build.
Had a bad rebase that merged the #if in two places. Whoops.

llvm-svn: 228366
2015-02-06 00:08:40 +00:00
Saleem Abdulrasool 37dd631804 Revert "indicate tag type in C"
This reverts commit 4963ea3107a2fdfae21f7806896905f20b21ff0d.

This change was wrong.  The parameter type is sugared via a typedef.  The errors
generated may have been due to a different root cause, and should be fixed
through the recent series of changes.

llvm-svn: 228365
2015-02-05 23:59:11 +00:00
Dan Albert f25c866ba6 [libcxxabi] Fix -Werror build for 32-bit non-ARM.
Summary:
The inclusion of Unwind-EHABI.h was insufficiently guarded
(LIBCXXABI_ARM_EHABI was beign checked without ever being defined).

Move the check into the header file itself, add the check to the
source file, and clean up the existing checks.

LIBCXXABI_ARM_EHABI didn't have a canonical defintion; it was
duplicated across cxxabi.h, libunwind.h, and unwind.h. Move the
definition into __cxxabi_config.h and clean up the old cruft (note: we
will have to ship this header).

There are also a few drive-by formatting/whitespace cleanups.

Reviewers: jroelofs, thakis, compnerd

Reviewed By: compnerd

Subscribers: compnerd, aemerson, cfe-commits

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

llvm-svn: 228363
2015-02-05 23:55:15 +00:00
Dan Albert b98c20cf7c Formatting fixes.
We should clang-format the whole thing when we finally move the
unwinder to its new home.

llvm-svn: 228360
2015-02-05 23:48:06 +00:00
Saleem Abdulrasool d88e51ced7 Fix compilation of unwind on Darwin-x86_64
EHABI related typedef sugar is gated via LIBCXXABI_ARM_EHABI which did not
protect the EHABI header.  This would cause declarations to be emitted on
non-EHABI targets, resulting in errors.  This permits compilation on Darwin.

llvm-svn: 228359
2015-02-05 23:27:41 +00:00
Saleem Abdulrasool ae1ca06a31 Silence some -Wundef warnings
config.h:53:7: warning 'FOR_DYLD' is not defined, evaluates to 0 [-Wundef]
Unwind_AppleExtras.cpp:44:5: warning '__arm__' is not defined, evaluates to 0 [-Wundef]
Unwind_AppleExtras.cpp:60:7: warning '__arm64__' is not defined, evaluates to 0 [-Wundef]
Unwind_AppleExtras.cpp:186:6: warning 'FOR_DYLD' is not defined, evaluates to 0 [-Wundef]

Use defined(macro) which should be equivalent in these cases, silencing -Wundef
warnings.  NFC.

llvm-svn: 228358
2015-02-05 23:27:39 +00:00
Saleem Abdulrasool ee0639d37e Silence warning about loss of precision
Explicitly cast to uintptr_t before casting to a 32-bit value.  Because this
code path is meant to be used in a 32-bit address space, this truncation should
be safe.

Unwind-EHABI.h:25:12: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information

llvm-svn: 228357
2015-02-05 23:27:36 +00:00
Saleem Abdulrasool bb66601d7c indicate tag type in C
Mark the tag type (struct) for the _Unwind_Exception in C code.  This silences a
warning from clang about missing struct specifier.

llvm-svn: 228356
2015-02-05 23:27:34 +00:00
Greg Fitzgerald b5d5bceefe Install header files
llvm-svn: 228351
2015-02-05 22:46:43 +00:00
Dan Albert 3be4efa341 Some more -Wundef issues.
This should be all of them for Linux. Might be some for the others.

llvm-svn: 228267
2015-02-05 02:44:50 +00:00
Dan Albert 3bd13ca4e1 Enable -Wundef.
The problem that caused the need for http://reviews.llvm.org/D7419 was
caused by testing the value of something that was undefined. This
should prevent that in the future.

llvm-svn: 228257
2015-02-05 01:33:15 +00:00
Dan Albert 39477c4c8b Whitespace cleanup.
llvm-svn: 228195
2015-02-04 21:23:20 +00:00