diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-02-22 11:23:32 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-02-22 11:23:32 -0800 |
commit | dd979ed995ce4a82b505fba2f29a8f32dc900bdd (patch) | |
tree | a6f11f4ad5d17bfcfbcc53b0f477b60e7dff2dd7 /system/lib/libcxxabi/src | |
parent | f53e69d92372020949c5ac0ca8f5ffdc67fb42fb (diff) |
bundle libcxxabi
Diffstat (limited to 'system/lib/libcxxabi/src')
22 files changed, 15565 insertions, 0 deletions
diff --git a/system/lib/libcxxabi/src/abort_message.cpp b/system/lib/libcxxabi/src/abort_message.cpp new file mode 100644 index 00000000..7beb86b5 --- /dev/null +++ b/system/lib/libcxxabi/src/abort_message.cpp @@ -0,0 +1,60 @@ +//===------------------------- abort_message.cpp --------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <stdlib.h> +#include <stdio.h> +#include <stdarg.h> +#include "abort_message.h" + +#pragma GCC visibility push(hidden) + +#if __APPLE__ +# if defined(__has_include) && __has_include(<CrashReporterClient.h>) +# define HAVE_CRASHREPORTERCLIENT_H 1 +# include <CrashReporterClient.h> + + // If any clients of llvm try to link to libCrashReporterClient.a themselves, + // only one crash info struct will be used. + extern "C" { + CRASH_REPORTER_CLIENT_HIDDEN + struct crashreporter_annotations_t gCRAnnotations + __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION))) + = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 }; + } + +# endif +#endif + +__attribute__((visibility("hidden"), noreturn)) +void abort_message(const char* format, ...) +{ + // write message to stderr +#if __APPLE__ + fprintf(stderr, "libc++abi.dylib: "); +#endif + va_list list; + va_start(list, format); + vfprintf(stderr, format, list); + va_end(list); + fprintf(stderr, "\n"); + +#if __APPLE__ && HAVE_CRASHREPORTERCLIENT_H + // record message in crash report + char* buffer; + va_list list2; + va_start(list2, format); + vasprintf(&buffer, format, list2); + va_end(list2); + CRSetCrashLogMessage(buffer); +#endif + + abort(); +} + +#pragma GCC visibility pop diff --git a/system/lib/libcxxabi/src/abort_message.h b/system/lib/libcxxabi/src/abort_message.h new file mode 100644 index 00000000..2c5cb204 --- /dev/null +++ b/system/lib/libcxxabi/src/abort_message.h @@ -0,0 +1,33 @@ +//===-------------------------- abort_message.h-----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef __ABORT_MESSAGE_H_ +#define __ABORT_MESSAGE_H_ + +#include <stdio.h> + +#pragma GCC visibility push(hidden) + +#ifdef __cplusplus +extern "C" { +#endif + +__attribute__((visibility("hidden"), noreturn)) + void abort_message(const char* format, ...) + __attribute__((format(printf, 1, 2))); + + +#ifdef __cplusplus +} +#endif + +#pragma GCC visibility pop + +#endif + diff --git a/system/lib/libcxxabi/src/cxa_aux_runtime.cpp b/system/lib/libcxxabi/src/cxa_aux_runtime.cpp new file mode 100644 index 00000000..abd8091c --- /dev/null +++ b/system/lib/libcxxabi/src/cxa_aux_runtime.cpp @@ -0,0 +1,34 @@ +//===------------------------ cxa_aux_runtime.cpp -------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +// +// This file implements the "Auxiliary Runtime APIs" +// http://www.codesourcery.com/public/cxx-abi/abi-eh.html#cxx-aux +//===----------------------------------------------------------------------===// + +#include "cxxabi.h" +#include <typeinfo> + +namespace __cxxabiv1 +{ + +extern "C" +{ + +LIBCXXABI_NORETURN +void __cxa_bad_cast (void) { + throw std::bad_cast(); +} + +LIBCXXABI_NORETURN +void __cxa_bad_typeid(void) { + throw std::bad_typeid(); +} + +} // extern "C" + +} // abi diff --git a/system/lib/libcxxabi/src/cxa_demangle.cpp b/system/lib/libcxxabi/src/cxa_demangle.cpp new file mode 100644 index 00000000..1135c99b --- /dev/null +++ b/system/lib/libcxxabi/src/cxa_demangle.cpp @@ -0,0 +1,10798 @@ +//===-------------------------- cxa_demangle.cpp --------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "cxa_demangle.h" + +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <stdio.h> +#include <new> +#include <algorithm> +#include <assert.h> + + +#ifdef DEBUGGING + +#include <string> +#include <typeinfo> + +#endif + +namespace __cxxabiv1 +{ + +namespace __libcxxabi +{ + +#pragma GCC visibility push(hidden) + +class __node +{ + __node(const __node&); + __node& operator=(const __node&); +public: + const char* __name_; + size_t __size_; + __node* __left_; + __node* __right_; + long double __value_; + long __cached_size_; +public: + __node() + : __name_(0), __size_(0), __left_(0), __right_(0), __cached_size_(-1) + {} + virtual ~__node() {}; + + void reset_cached_size() + { + __cached_size_ = -1; + if (__left_) + __left_->reset_cached_size(); + if (__right_) + __right_->reset_cached_size(); + } + + virtual size_t first_size() const {return 0;} + virtual size_t second_size() const {return 0;} + virtual size_t size() const + { + if (__cached_size_ == -1) + const_cast<long&>(__cached_size_) = first_size() + second_size(); + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const {return buf;} + virtual char* second_demangled_name(char* buf) const {return buf;} + virtual char* get_demangled_name(char* buf) const + { + return second_demangled_name(first_demangled_name(buf)); + } + virtual size_t base_size() const {return size();} + virtual char* get_base_name(char* buf) const + { + return get_demangled_name(buf); + } + + virtual bool ends_with_template(bool parsing = false) const + { + return false; + } + virtual bool is_ctor_dtor_conv() const + { + return false; + } + virtual __node* base_name() const + { + return const_cast<__node*>(this); + } + virtual bool is_reference_or_pointer_to_function_or_array() const + { + return false; + } + virtual bool is_function() const + { + return false; + } + virtual bool is_cv_qualifer() const + { + return false; + } + virtual bool is_array() const + { + return false; + } + + virtual bool fix_forward_references(__node**, __node**) + { + return true; + } + virtual __node* extract_cv(__node*&) const + { + return 0; + } + virtual size_t list_len() const + { + return 0; + } + virtual bool is_sub() const + { + return false; + } +}; + +#ifdef DEBUGGING + +void display(__node* x, int indent = 0) +{ + if (x) + { + for (int i = 0; i < 2*indent; ++i) + printf(" "); + std::string buf(x->size(), '\0'); + x->get_demangled_name(&buf.front()); + printf("%s %s, %p\n", typeid(*x).name(), buf.c_str(), x); + display(x->__left_, indent+1); + display(x->__right_, indent+1); + } +} + +#endif + +class __vtable + : public __node +{ + static const ptrdiff_t n = sizeof("vtable for ") - 1; +public: + __vtable(__node* type) + { + __right_ = type; + } + + virtual size_t first_size() const + { + if (__cached_size_ == -1) + const_cast<long&>(__cached_size_) = n + __right_->size(); + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + strncpy(buf, "vtable for ", n); + return __right_->get_demangled_name(buf+n); + } + virtual __node* base_name() const + { + return __right_->base_name(); + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + return __right_->fix_forward_references(t_begin, t_end); + } +}; + +class __VTT + : public __node +{ + static const ptrdiff_t n = sizeof("VTT for ") - 1; +public: + __VTT(__node* type) + { + __right_ = type; + } + + virtual size_t first_size() const + { + if (__cached_size_ == -1) + const_cast<long&>(__cached_size_) = n + __right_->size(); + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + strncpy(buf, "VTT for ", n); + return __right_->get_demangled_name(buf+n); + } + virtual __node* base_name() const + { + return __right_->base_name(); + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + return __right_->fix_forward_references(t_begin, t_end); + } +}; + +class __construction_vtable + : public __node +{ + static const ptrdiff_t n = sizeof("construction vtable for ") - 1 + 4; +public: + __construction_vtable(__node* left, __node* right) + { + __left_ = left; + __right_ = right; + } + + virtual size_t first_size() const + { + if (__cached_size_ == -1) + const_cast<long&>(__cached_size_) = n + __left_->size() + + __right_->size(); + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + strncpy(buf, "construction vtable for ", n-4); + buf = __left_->get_demangled_name(buf+n-4); + *buf++ = '-'; + *buf++ = 'i'; + *buf++ = 'n'; + *buf++ = '-'; + return __right_->get_demangled_name(buf); + } + virtual __node* base_name() const + { + return __right_->base_name(); + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + bool r = true; + if (__left_) + r = __left_->fix_forward_references(t_begin, t_end); + return r && __right_->fix_forward_references(t_begin, t_end); + } +}; + +class __typeinfo + : public __node +{ + static const ptrdiff_t n = sizeof("typeinfo for ") - 1; +public: + __typeinfo(__node* type) + { + __right_ = type; + } + + virtual size_t first_size() const + { + if (__cached_size_ == -1) + const_cast<long&>(__cached_size_) = n + __right_->size(); + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + strncpy(buf, "typeinfo for ", n); + return __right_->get_demangled_name(buf+n); + } + virtual __node* base_name() const + { + return __right_->base_name(); + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + return __right_->fix_forward_references(t_begin, t_end); + } +}; + +class __typeinfo_name + : public __node +{ + static const ptrdiff_t n = sizeof("typeinfo name for ") - 1; +public: + __typeinfo_name(__node* type) + { + __right_ = type; + } + + virtual size_t first_size() const + { + if (__cached_size_ == -1) + const_cast<long&>(__cached_size_) = n + __right_->size(); + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + strncpy(buf, "typeinfo name for ", n); + return __right_->get_demangled_name(buf+n); + } + virtual __node* base_name() const + { + return __right_->base_name(); + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + return __right_->fix_forward_references(t_begin, t_end); + } +}; + +class __covariant_return_thunk + : public __node +{ + static const ptrdiff_t n = sizeof("covariant return thunk to ") - 1; +public: + __covariant_return_thunk(__node* type) + { + __right_ = type; + } + + virtual size_t first_size() const + { + if (__cached_size_ == -1) + const_cast<long&>(__cached_size_) = n + __right_->size(); + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + strncpy(buf, "covariant return thunk to ", n); + return __right_->get_demangled_name(buf+n); + } + virtual __node* base_name() const + { + return __right_->base_name(); + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + return __right_->fix_forward_references(t_begin, t_end); + } +}; + +class __virtual_thunk + : public __node +{ + static const size_t n = sizeof("virtual thunk to ") - 1; +public: + __virtual_thunk(__node* type) + { + __right_ = type; + } + + virtual size_t first_size() const + { + if (__cached_size_ == -1) + const_cast<long&>(__cached_size_) = n + __right_->size(); + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + strncpy(buf, "virtual thunk to ", n); + return __right_->get_demangled_name(buf+n); + } + virtual __node* base_name() const + { + return __right_->base_name(); + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + return __right_->fix_forward_references(t_begin, t_end); + } +}; + +class __non_virtual_thunk + : public __node +{ + static const size_t n = sizeof("non-virtual thunk to ") - 1; +public: + __non_virtual_thunk(__node* type) + { + __right_ = type; + } + + virtual size_t first_size() const + { + if (__cached_size_ == -1) + const_cast<long&>(__cached_size_) = n + __right_->size(); + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + strncpy(buf, "non-virtual thunk to ", n); + return __right_->get_demangled_name(buf+n); + } + virtual __node* base_name() const + { + return __right_->base_name(); + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + return __right_->fix_forward_references(t_begin, t_end); + } +}; + +class __guard_variable + : public __node +{ + static const size_t n = sizeof("guard variable for ") - 1; +public: + __guard_variable(__node* type) + { + __right_ = type; + } + + virtual size_t first_size() const + { + if (__cached_size_ == -1) + const_cast<long&>(__cached_size_) = n + __right_->size(); + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + strncpy(buf, "guard variable for ", n); + return __right_->get_demangled_name(buf+n); + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + return __right_->fix_forward_references(t_begin, t_end); + } +}; + +class __reference_temporary + : public __node +{ + static const size_t n = sizeof("reference temporary for ") - 1; +public: + __reference_temporary(__node* type) + { + __right_ = type; + } + + virtual size_t first_size() const + { + if (__cached_size_ == -1) + const_cast<long&>(__cached_size_) = n + __right_->size(); + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + strncpy(buf, "reference temporary for ", n); + return __right_->get_demangled_name(buf+n); + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + return __right_->fix_forward_references(t_begin, t_end); + } +}; + +class __source_name + : public __node +{ +public: + __source_name(const char* __name, unsigned __size) + { + __name_ = __name; + __size_ = __size; + } + + virtual size_t first_size() const + { + if (__cached_size_ == -1) + { + if (__size_ >= 10 && strncmp(__name_, "_GLOBAL__N", 10) == 0) + const_cast<long&>(__cached_size_) = 21; + else + const_cast<long&>(__cached_size_) = __size_; + } + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + if (__size_ >= 10 && strncmp(__name_, "_GLOBAL__N", 10) == 0) + return strncpy(buf, "(anonymous namespace)", 21) + 21; + return strncpy(buf, __name_, __size_) + __size_; + } +}; + +class __operator_new + : public __node +{ +public: + + virtual size_t first_size() const {return sizeof("operator new") - 1;} + virtual char* first_demangled_name(char* buf) const + { + return strncpy(buf, "operator new", sizeof("operator new") - 1) + + sizeof("operator new") - 1; + } +}; + +class __operator_new_array + : public __node +{ +public: + + virtual size_t first_size() const {return sizeof("operator new[]") - 1;} + virtual char* first_demangled_name(char* buf) const + { + return strncpy(buf, "operator new[]", sizeof("operator new[]") - 1) + + sizeof("operator new[]") - 1; + } +}; + +class __operator_delete + : public __node +{ +public: + + virtual size_t first_size() const {return sizeof("operator delete") - 1;} + virtual char* first_demangled_name(char* buf) const + { + return strncpy(buf, "operator delete", sizeof("operator delete") - 1) + + sizeof("operator delete") - 1; + } +}; + +class __operator_delete_array + : public __node +{ +public: + + virtual size_t first_size() const {return sizeof("operator delete[]") - 1;} + virtual char* first_demangled_name(char* buf) const + { + return strncpy(buf, "operator delete[]", sizeof("operator delete[]") - 1) + + sizeof("operator delete[]") - 1; + } +}; + +class __operator_logical_and + : public __node +{ +public: + + __operator_logical_and() {} + __operator_logical_and(__node* op1, __node* op2) + { + __left_ = op1; + __right_ = op2; + } + virtual size_t first_size() const + { + if (__cached_size_ == -1) + { + if (__left_) + const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); + else + const_cast<long&>(__cached_size_) = sizeof("operator&&") - 1; + } + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + if (__left_) + { + *buf++ = '('; + buf = __left_->get_demangled_name(buf); + strncpy(buf, ") && (", 6); + buf += 6; + buf = __right_->get_demangled_name(buf); + *buf++ = ')'; + } + else + { + strncpy(buf, "operator&&", sizeof("operator&&") - 1); + buf += sizeof("operator&&") - 1; + } + return buf; + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + bool r = true; + if (__left_) + r = r && __left_->fix_forward_references(t_begin, t_end); + if (__right_) + r = r && __right_->fix_forward_references(t_begin, t_end); + return r; + } +}; + +class __operator_addressof + : public __node +{ +public: + + __operator_addressof() {} + explicit __operator_addressof(__node* op) + { + __left_ = op; + } + virtual size_t first_size() const + { + if (__cached_size_ == -1) + { + if (__left_) + const_cast<long&>(__cached_size_) = 3+__left_->size(); + else + const_cast<long&>(__cached_size_) = sizeof("operator&") - 1; + } + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + if (__left_) + { + *buf++ = '&'; + *buf++ = '('; + buf = __left_->get_demangled_name(buf); + *buf++ = ')'; + } + else + { + strncpy(buf, "operator&", sizeof("operator&") - 1); + buf += sizeof("operator&") - 1; + } + return buf; + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + if (__left_) + return __left_->fix_forward_references(t_begin, t_end); + return true; + } +}; + +class __operator_bit_and + : public __node +{ +public: + + __operator_bit_and() {} + __operator_bit_and(__node* op1, __node* op2) + { + __left_ = op1; + __right_ = op2; + } + virtual size_t first_size() const + { + if (__cached_size_ == -1) + { + if (__left_) + const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); + else + const_cast<long&>(__cached_size_) = sizeof("operator&") - 1; + } + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + if (__left_) + { + *buf++ = '('; + buf = __left_->get_demangled_name(buf); + strncpy(buf, ") & (", 5); + buf += 5; + buf = __right_->get_demangled_name(buf); + *buf++ = ')'; + } + else + { + strncpy(buf, "operator&", sizeof("operator&") - 1); + buf += sizeof("operator&") - 1; + } + return buf; + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + bool r = true; + if (__left_) + r = r && __left_->fix_forward_references(t_begin, t_end); + if (__right_) + r = r && __right_->fix_forward_references(t_begin, t_end); + return r; + } +}; + +class __operator_and_equal + : public __node +{ +public: + + __operator_and_equal() {} + __operator_and_equal(__node* op1, __node* op2) + { + __left_ = op1; + __right_ = op2; + } + virtual size_t first_size() const + { + if (__cached_size_ == -1) + { + if (__left_) + const_cast<long&>(__cached_size_) = __left_->size() + 8 + __right_->size(); + else + const_cast<long&>(__cached_size_) = sizeof("operator&=") - 1; + } + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + if (__left_) + { + *buf++ = '('; + buf = __left_->get_demangled_name(buf); + strncpy(buf, ") &= (", 6); + buf += 6; + buf = __right_->get_demangled_name(buf); + *buf++ = ')'; + } + else + { + strncpy(buf, "operator&=", sizeof("operator&=") - 1); + buf += sizeof("operator&=") - 1; + } + return buf; + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + bool r = true; + if (__left_) + r = r && __left_->fix_forward_references(t_begin, t_end); + if (__right_) + r = r && __right_->fix_forward_references(t_begin, t_end); + return r; + } +}; + +class __operator_equal + : public __node +{ +public: + + __operator_equal() {} + __operator_equal(__node* op1, __node* op2) + { + __left_ = op1; + __right_ = op2; + } + virtual size_t first_size() const + { + if (__cached_size_ == -1) + { + if (__left_) + const_cast<long&>(__cached_size_) = __left_->size() + 7 + __right_->size(); + else + const_cast<long&>(__cached_size_) = sizeof("operator=") - 1; + } + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + if (__left_) + { + *buf++ = '('; + buf = __left_->get_demangled_name(buf); + strncpy(buf, ") = (", 5); + buf += 5; + buf = __right_->get_demangled_name(buf); + *buf++ = ')'; + } + else + { + strncpy(buf, "operator=", sizeof("operator=") - 1); + buf += sizeof("operator=") - 1; + } + return buf; + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + bool r = true; + if (__left_) + r = r && __left_->fix_forward_references(t_begin, t_end); + if (__right_) + r = r && __right_->fix_forward_references(t_begin, t_end); + return r; + } +}; + +class __operator_alignof_type + : public __node +{ +public: + + __operator_alignof_type() {} + __operator_alignof_type(__node* op) + { + __right_ = op; + } + virtual size_t first_size() const + { + if (__cached_size_ == -1) + { + if (__right_) + const_cast<long&>(__cached_size_) = __right_->size() + 10; + else + const_cast<long&>(__cached_size_) = sizeof("operator alignof") - 1; + } + return __cached_size_; + } + virtual char* first_demangled_name(char* buf) const + { + if (__right_) + { + strncpy(buf, "alignof (", 9); + buf += 9; + buf = __right_->get_demangled_name(buf); + *buf++ = ')'; + } + else + { + strncpy(buf, "operator alignof", sizeof("operator alignof") - 1); + buf += sizeof("operator alignof") - 1; + } + return buf; + } + virtual bool fix_forward_references(__node** t_begin, __node** t_end) + { + if (__right_) + return __right_->fix_forward_references(t_begin, t_end); + return true; + } +}; + +class __operator_alignof_expression + : public __node +{ +public: + |