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
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
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
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
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
Summary:
The main section of this patch teaches CMake a new option `LIBCXXABI_LIBCXX_PATH` that specifies the path to the libcxx source root. This information is passed to lit so that it can better find libc++'s python module. `LIBCXXABI_LIBCXX_PATH` is also used to help find the libc++ headers.
The rest of this patch is misc cleanup, mostly to make pep8 and pylint happy.
I've also copied libc++'s .gitignore into libc++abi.
Reviewers: jroelofs, danalbert
Reviewed By: danalbert
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D7130
llvm-svn: 226855
Without -funwind-tables, the compiler won't generate the unwinding
table for these C functions. However, the functions in libunwind,
such as `_Unwind_Backtrace()`, WILL unwind stack to get the backtrace.
llvm-svn: 226823
If libcxxabi is compiled as a shared library, and the
executable references the user-defined personality routines
(e.g. __gxx_personality_v0), then the pointer comparison in
Unwind-EHABI.cpp won't work. This is due to the fact that
the PREL31 will point to the PLT stubs for the personality
routines (in the executable), while the __gxx_personality_v0
symbol reference is yet another (different) PLT stub (in the
libunwind.)
This will cause _Unwind_Backtrace() stops to unwind the frame
whenever it reaches __gxx_personality_v0(). This CL fix the
problem by calling the user-defined personality routines
with an undocumented API for force unwinding.
llvm-svn: 226822
This CL adds a new compilation flags LIBCXXABI_USE_LLVM_UNWINDER
to specify whether the LLVM unwinder is enabled. Besides, all
unwinder-specific code are guarded with this definition.
Now, libc++abi will be able to use the unwinding routine from libgcc
when LIBCXXABI_USE_LLVM_UNWINDER is disabled.
llvm-svn: 226819
This commit partially reverts r219629.
This functions are not a part of ARM EHABI specification, and AFAIK,
the de facto implementation does not export these functions.
Without this change, any programs compiled with this unwind.h
will be incompatible with other implementations due to linkage
error.
llvm-svn: 226818
The NDK doesn't have access to `android/set_abort_message.h`, so use
an extern declaration instead for API 21. For older releases, just use
`__assert2`, which will report to logcat and/or the tombstone for some
older releases.
llvm-svn: 226310
libdir suffixes like 'lib64' or 'lib32'.
This support is currently very rhudimentary. We define a variable
LIBCXXABI_LIBDIR_SUFFIX. In a standalone build of libc++abi this can be
directly set as a cached variable to control the multilib suffix used.
When building libc++abi within a larger LLVM build, it is hard wired to
whatever LLVM libdir suffix has been selected. If this doesn't work for
someone, just let me know. I'm happy to change it.
Unfortunately, libc++abi's lit setup made this somewhat problematic to
change. It was setting variables up in a way that caused the resulting
build to not work with lit at all. To fix that, I've moved some
variables around in the CMake build to more closely match where and how
they are defined in the libc++ CMake build. This includes specifically
defining a library root variable in the CMake build where the libdir
suffix can be applied, and then using that rather than re-computing it
from the object directory in the lit config.
This is essentially new functionality for libc++abi so I don't expect it
to have any impact for folks until they start setting these variables.
However, I know libc++abi is built in a diverse set of environments so
just let me know if this causes you any problems.
llvm-svn: 224927
* Remove the embedded directive undefined behavior by moving the
the #ifdef out of the macro arguments. [-Wembedded-directive]
* Remove the local variable shadowing warning by renaming
frameInfo in UnwindLevel1-gcc-ext.c. [-Wshadow]
* Explicitly cast the function pointer to void pointer to avoid
the comparison between function pointer and void pointer.
[-Wpedantic]
llvm-svn: 224690
Summary:
This patch adds CMake support for building and testing libc++abi without threads.
1. Add `LIBCXXABI_ENABLE_THREADS` option to CMake.
2. Propagate `LIBCXXABI_ENABLE_THREADS` to lit via lit.site.cfg.in
3. Configure tests for `LIBCXXABI_ENABLE_THREADS=OFF
Currently the test suite does not work when libc++abi is built without threads because that information does not propagate to the test suite.
Reviewers: danalbert, mclow.lists, jroelofs
Reviewed By: jroelofs
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D6393
llvm-svn: 222702
Summary:
When using LIT the timing output is entirely unused but introduces a dependency on `<chrono>`. When libc++ is built without a montonic clock this causes some of the tests to fail.
This patch factors out all of the timing logic into `support/timer.hpp` and disables it by default. To enable the timing you must define `LIBCXXABI_TIME_TESTS`.
Reviewers: mclow.lists, danalbert, jroelofs
Reviewed By: jroelofs
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D6391
llvm-svn: 222701
Summary:
This patch delays the dereference adjustment until we are sure the thrown type is a pointer type. It is possible the thrown type is not a pointer and is smaller than `sizeof(void*)`. If the thrown type is is smaller than `sizeof(void*)` the deference adjustment will result in a heap buffer overflow.
I audited all the call sites of `can_catch(...)` and there are no places where `adjustedPtr` is used if `can_catch(...)` returns false. For this reason the patch should not introduce any functionality change.
This patch fixes the following tests when using ASAN:
* unwind_01.cpp
* unwind_02.cpp
* unwind_04.cpp
Reviewers: danalbert, jroelofs, mclow.lists
Reviewed By: mclow.lists
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D6353
llvm-svn: 222674
Summary: ASAN fires on these tests because they don't clean up their memory.
Reviewers: danalbert, jroelofs, mclow.lists
Reviewed By: jroelofs
Subscribers: dblaikie, cfe-commits
Differential Revision: http://reviews.llvm.org/D6281
llvm-svn: 222493
_Unwind_Backtrace is not clearly defined in EHABI and needs more
testing. A bug was created with some initial investigation done
http://llvm.org/PR21444. This test fails with both libunwind and libgcc_s.
llvm-svn: 221348
Although the current method is valid up till python 3.3 (which is not supported)
this seems to be a clearer way of checking for linux and moves the tests towards
python 3 compatibility.
llvm-svn: 220535
Summary: Add support for LLVM_USE_SANITIZER to the libc++abi tests. Currently, if libc++abi is configured with LLVM_USE_SANITIZER then none of the tests will pass.
Reviewers: jroelofs, mclow.lists, danalbert
Reviewed By: danalbert
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D5926
llvm-svn: 220464
The current documentation does not explain that the standalone build requires
the LLVM sources. This patch updates the documentation to reflect this
requirement and explains how to manually specify the location of the required
files.
llvm-svn: 220049
These need to have normal linkage instead of being static inline as
many libraries expect to be able to declare these and have the linker
find them rather than needing to include the header.
http://mentorembedded.github.io/cxx-abi/abi-eh.html
Also clean up some warnings while I'm here.
Reviewers: jroelofs, kledzik
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D5754
llvm-svn: 219629
Also remove an extra extern "C" from a global variable redeclaration.
This allows building libcxxabi with GCC on my system.
Reviewers: majnemer
Differential Revision: http://reviews.llvm.org/D5604
llvm-svn: 219012
As the title says... also, fix all the ARM asm return sequences so that they
work on processors without the BX instruction.
http://reviews.llvm.org/D5314
llvm-svn: 218869
This patch fixes the bad argument that GAS accepted but the IAS didn't,
ie. {#0x20}, moving it to {0x20} which both accept. It also makes the
ARMv7+ save/restore correct by using VFP instructions rather than old
co-processor ones.
Fixes PR20529.
llvm-svn: 217585
Also remove the audotedection part so that if you're crazy enough to want a
single-threaded abi library, you'll say so explicitly in the build.
llvm-svn: 217262
Summary: Since the personality functions do the actual unwinding on ARM,
and will also stop unwinding when they encounter a handler, we invoke
_Unwind_VRS_Interpret() directly form _Unwind_Backtrace().
To simplify, the logic for decoding an EHT is moved out of
unwindOneFrame() and into its own function, decode_eht_entry(). Unlike
unwindOneFrame(), which could only handle ARM's compact personality
function entries (section 6.3) decode_eht_entry() can handle the generic
entries (section 6.2).
Reviewers: jroelofs
Reviewed By: jroelofs
Subscribers: piman, aemerson, cfe-commits
Differential Revision: http://reviews.llvm.org/D5112
llvm-svn: 216730
Depending on llvm-config allows for a few nice things (auto-detecting
LLVM source tree, version numbers, etc), but it's makes bootstrapping a
pain. Keep the llvm-config features around, but also fall back to being
able to configure based on -DLLVM_PATH=path/to/llvm.
Reviewers: jroelofs, loladiro
Reviewed By: loladiro
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D5016
llvm-svn: 216482
In Android, stderr only goes to the console, and as such will only ever
be seen by adb shell users. Since very few developers will ever actually
see that, also send the abort message to logcat and the tombstone.
llvm-svn: 215983
This fixes an interworking problem when the unwinder/libcxxabi is built for
Thumb. When unw_getcontext is not marked as a function, 'bl' is used for the
branch instead of 'bx'.
llvm-svn: 214573
No intended behavior change on Linux and Mac OS X. On Windows, having libcxxabi
in one's checkout should now no longer break running cmake. (cl.exe supports
c++11, but doesn't understand a -std= flag.)
llvm-svn: 213214
The cmake files for libc++abi and the unwinder weren't linking against
libpthread or an unwind library. If the tests were linked with
-Wl,--as-needed, these libraries wouldn't be linked, causing them to
fail.
Patch contributed by İsmail Dönmez.
llvm-svn: 212958
Note: The unwinder currently only works on Darwin and on ARM Linux.
Non-ARM Linux support is not yet implemented, and will fail to build.
llvm-svn: 212824
This makes running libcxxabi tests on Linux _much_ easier.
Adds a check-libcxxabi target to cmake.
Also defaults to building a dynamic libc++abi. This is so that the
default options still test the libc++abi that is being built. There are
two problems with testing a static libc++abi. In the case of a
standalone build, the tests will link the system's libc++, which might
not have been built against our libc++abi. In the case of an in tree
build, libc++ will prefer a dynamic libc++abi from the system over a
static libc++abi from the output directory.
llvm-svn: 212672
This commit reverts the LSDA-related change in r211745.
The r211745 adds a new argument to scan_eh_tab(), i.e. lsda.
However, IMO, calling _Unwind_GetLanguageSpecificData() directly in
scan_eh_tab() was more intuitive and reduces several function call
to _Unwind_GetLanguageSpecificData() in __cxx_personality_v0().
llvm-svn: 212037
This was written by:
Albert Wong <ajwong@chromium.org>
Antoine Labour <piman@chromium.org>
Dana Jansen <danakj@chromium.org
Jonathan Roelofs <jonathan@codesourcery.com>
Nico Weber <thakis@chromium.org>
llvm-svn: 211743
The new code will be behind a LIBCXXABI_ARM_EHABI define (so that platforms
that don't want it can continue using e.g. SJLJ). This commit mostly just
adds the LIBCXXABI_ARM_EHABI define.
llvm-svn: 211739
There was a single problem in cxa_demangle.cpp, where gcc would complain
`error: changes meaning of 'String'` about the line `typedef String String;`.
According to 3.3.7p2, this diagnostic is allowed (but not required, so clang
does not have to report this).
As a fix, make string_pair a template and pass String as template parameter.
This fixes the error with gcc and also removes some repetition from the code.
No behavior change.
llvm-svn: 209909
determine whether we get a mangling for a return type, rather than trying to
figure it out based on whether the mangled name ended with a '>'.
llvm-svn: 208611
To allow the compilation with gcc, we can't use the
__has_feature(cxx_noexcept) to detect the default destructor
exception specification, which is noexcept(true) by default
in C++11. We should use __cplusplus >= 201103L instead.
llvm-svn: 208465
The was working because, given __APPLE__, _LIBUNWIND_BUILD_SJLJ_APIS was set to
__arm__, but other ARM targets not using SJ/LJ will fail to compile.
llvm-svn: 206941
opcode is VAX. A function call pushes the number of arguments given onto
the stack and "ret" will pop it automatically. The FDE of the caller
contains the amount of stack space used for arguments (and possibly
extra padding), so unwinding has to compensate for this when "returning"
from a function. This is exactly the case when step() is done. The
existing handling in unw_set_reg no longer makes sense.
llvm-svn: 204290
This is in preparation for landing an implementation of unw_getcontext
on a system where it's mangled 'unw_getcontext', not '_unw_getcontext'.
llvm-svn: 197523
type_info* will work for typeids from the same compiled file but fail
for typeids from a DLL and an executable. Among other things, exceptions
are not caught by handlers since can_catch() returns false.
Defining _LIBCXX_DYNAMIC_FALLBACK does not help since can_catch() calls
is_equal() with use_strcmp=false so the string names are not compared.
This patch compares typeids first (cheap) and only they are different
calls strcmp.
llvm-svn: 195502
__attribute__ (( unavailable )) is for Apple specific builds. Create a macro
to conditionalise the usage of the macro. This is to aid in porting the
unwinder to other platforms.
llvm-svn: 192868
realized, it is not complete. It relies on some _Unwind_* functions to be
supplied by the OS. That means it cannot be ported to platforms that don’t
already have an unwinder.
Years ago Apple wrote its own unwinder for MacOSX and iOS. To make libcxxabi
complete, Apple has decided the source code for its unwinder can be contributed
to the open source LLVM libcxxabi project, with a dual licensed under LLVM
and MIT license.
So, I’ve spent some time cleaning up the sources to make them conform with
LLVM style and to conditionalize the sources in a way that should make it
easier to port to other platforms. The sources are in a separate "Unwind"
directory under "src" in libcxxabi.
Background:
Most architectures now use "zero cost" exceptions for C++. The zero cost means
there are no extra instructions executed if no exceptions are thrown. But if
an exception is thrown, the runtime must consult side tables and figure out how
to restore registers and "unwind" from the current stack frame to the catch
clause. That ability to modify the stack frames and cause the thread to resume
in a catch clause with all registers restored properly is the main purpose
of the unwinder.
This unwinder has two levels of API. The high level APIs are the _Unwind_*
functions which the cxa_* exception functions in libcxxabi require. The low
level APIs are the unw_* functions which are an interface defined by the the
old HP libunwind project (which shares no code with this unwinder).
llvm-svn: 192136
substitution forward references. That is, sometimes a mangled name refers to
a substitution that hasn't yet been defined. The demangler was derferencing a
null pointer in this case because it wasn't properly guarded against a
forward reference. Test case added to catch this problem.
llvm-svn: 161267