Import new snapshot of libcxxrt. Fixes demangling of anonymous
namespaces. Avoid use of old style (C) casts.
This commit is contained in:
parent
3504287a90
commit
d0b6b5d51b
|
@ -11,7 +11,7 @@
|
||||||
*/
|
*/
|
||||||
#if __has_builtin(__c11_atomic_exchange)
|
#if __has_builtin(__c11_atomic_exchange)
|
||||||
#define ATOMIC_SWAP(addr, val)\
|
#define ATOMIC_SWAP(addr, val)\
|
||||||
__c11_atomic_exchange((_Atomic(__typeof__(val))*)addr, val, __ATOMIC_ACQ_REL)
|
__c11_atomic_exchange(reinterpret_cast<_Atomic(__typeof__(val))*>(addr), val, __ATOMIC_ACQ_REL)
|
||||||
#elif __has_builtin(__sync_swap)
|
#elif __has_builtin(__sync_swap)
|
||||||
#define ATOMIC_SWAP(addr, val)\
|
#define ATOMIC_SWAP(addr, val)\
|
||||||
__sync_swap(addr, val)
|
__sync_swap(addr, val)
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#if __has_builtin(__c11_atomic_load)
|
#if __has_builtin(__c11_atomic_load)
|
||||||
#define ATOMIC_LOAD(addr)\
|
#define ATOMIC_LOAD(addr)\
|
||||||
__c11_atomic_load((_Atomic(__typeof__(*addr))*)addr, __ATOMIC_ACQUIRE)
|
__c11_atomic_load(reinterpret_cast<_Atomic(__typeof__(*addr))*>(addr), __ATOMIC_ACQUIRE)
|
||||||
#else
|
#else
|
||||||
#define ATOMIC_LOAD(addr)\
|
#define ATOMIC_LOAD(addr)\
|
||||||
(__sync_synchronize(), *addr)
|
(__sync_synchronize(), *addr)
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#ifndef __CXXABI_H_
|
#ifndef __CXXABI_H_
|
||||||
#define __CXXABI_H_
|
#define __CXXABI_H_
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "unwind.h"
|
#include "unwind.h"
|
||||||
namespace std
|
namespace std
|
||||||
|
|
|
@ -83,7 +83,7 @@ enum dwarf_data_encoding
|
||||||
*/
|
*/
|
||||||
static inline enum dwarf_data_encoding get_encoding(unsigned char x)
|
static inline enum dwarf_data_encoding get_encoding(unsigned char x)
|
||||||
{
|
{
|
||||||
return (enum dwarf_data_encoding)(x & 0xf);
|
return static_cast<enum dwarf_data_encoding>(x & 0xf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,7 +115,7 @@ enum dwarf_data_relative
|
||||||
*/
|
*/
|
||||||
static inline enum dwarf_data_relative get_base(unsigned char x)
|
static inline enum dwarf_data_relative get_base(unsigned char x)
|
||||||
{
|
{
|
||||||
return (enum dwarf_data_relative)(x & 0x70);
|
return static_cast<enum dwarf_data_relative>(x & 0x70);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns whether an encoding represents an indirect address.
|
* Returns whether an encoding represents an indirect address.
|
||||||
|
@ -206,9 +206,9 @@ static int64_t read_sleb128(dw_eh_ptr_t *data)
|
||||||
if ((uleb >> (bits-1)) == 1)
|
if ((uleb >> (bits-1)) == 1)
|
||||||
{
|
{
|
||||||
// Sign extend by setting all bits in front of it to 1
|
// Sign extend by setting all bits in front of it to 1
|
||||||
uleb |= ((int64_t)-1) << bits;
|
uleb |= static_cast<int64_t>(-1) << bits;
|
||||||
}
|
}
|
||||||
return (int64_t)uleb;
|
return static_cast<int64_t>(uleb);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Reads a value using the specified encoding from the address pointed to by
|
* Reads a value using the specified encoding from the address pointed to by
|
||||||
|
@ -224,7 +224,7 @@ static uint64_t read_value(char encoding, dw_eh_ptr_t *data)
|
||||||
// Read fixed-length types
|
// Read fixed-length types
|
||||||
#define READ(dwarf, type) \
|
#define READ(dwarf, type) \
|
||||||
case dwarf:\
|
case dwarf:\
|
||||||
v = (uint64_t)(*(type*)(*data));\
|
v = static_cast<uint64_t>(*reinterpret_cast<type*>(*data));\
|
||||||
*data += sizeof(type);\
|
*data += sizeof(type);\
|
||||||
break;
|
break;
|
||||||
READ(DW_EH_PE_udata2, uint16_t)
|
READ(DW_EH_PE_udata2, uint16_t)
|
||||||
|
@ -263,16 +263,16 @@ static uint64_t resolve_indirect_value(_Unwind_Context *c,
|
||||||
switch (get_base(encoding))
|
switch (get_base(encoding))
|
||||||
{
|
{
|
||||||
case DW_EH_PE_pcrel:
|
case DW_EH_PE_pcrel:
|
||||||
v += (uint64_t)start;
|
v += reinterpret_cast<uint64_t>(start);
|
||||||
break;
|
break;
|
||||||
case DW_EH_PE_textrel:
|
case DW_EH_PE_textrel:
|
||||||
v += (uint64_t)_Unwind_GetTextRelBase(c);
|
v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetTextRelBase(c)));
|
||||||
break;
|
break;
|
||||||
case DW_EH_PE_datarel:
|
case DW_EH_PE_datarel:
|
||||||
v += (uint64_t)_Unwind_GetDataRelBase(c);
|
v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetDataRelBase(c)));
|
||||||
break;
|
break;
|
||||||
case DW_EH_PE_funcrel:
|
case DW_EH_PE_funcrel:
|
||||||
v += (uint64_t)_Unwind_GetRegionStart(c);
|
v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetRegionStart(c)));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ static uint64_t resolve_indirect_value(_Unwind_Context *c,
|
||||||
// be a GCC extensions, so not properly documented...
|
// be a GCC extensions, so not properly documented...
|
||||||
if (is_indirect(encoding))
|
if (is_indirect(encoding))
|
||||||
{
|
{
|
||||||
v = (uint64_t)(uintptr_t)*(void**)v;
|
v = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(*reinterpret_cast<void**>(v)));
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -342,14 +342,14 @@ static inline struct dwarf_eh_lsda parse_lsda(_Unwind_Context *context,
|
||||||
{
|
{
|
||||||
struct dwarf_eh_lsda lsda;
|
struct dwarf_eh_lsda lsda;
|
||||||
|
|
||||||
lsda.region_start = (dw_eh_ptr_t)(uintptr_t)_Unwind_GetRegionStart(context);
|
lsda.region_start = reinterpret_cast<dw_eh_ptr_t>(_Unwind_GetRegionStart(context));
|
||||||
|
|
||||||
// If the landing pads are relative to anything other than the start of
|
// If the landing pads are relative to anything other than the start of
|
||||||
// this region, find out where. This is @LPStart in the spec, although the
|
// this region, find out where. This is @LPStart in the spec, although the
|
||||||
// encoding that GCC uses does not quite match the spec.
|
// encoding that GCC uses does not quite match the spec.
|
||||||
uint64_t v = (uint64_t)(uintptr_t)lsda.region_start;
|
uint64_t v = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(lsda.region_start));
|
||||||
read_value_with_encoding(context, &data, &v);
|
read_value_with_encoding(context, &data, &v);
|
||||||
lsda.landing_pads = (dw_eh_ptr_t)(uintptr_t)v;
|
lsda.landing_pads = reinterpret_cast<dw_eh_ptr_t>(static_cast<uintptr_t>(v));
|
||||||
|
|
||||||
// If there is a type table, find out where it is. This is @TTBase in the
|
// If there is a type table, find out where it is. This is @TTBase in the
|
||||||
// spec. Note: we find whether there is a type table pointer by checking
|
// spec. Note: we find whether there is a type table pointer by checking
|
||||||
|
@ -369,14 +369,14 @@ static inline struct dwarf_eh_lsda parse_lsda(_Unwind_Context *context,
|
||||||
lsda.type_table_encoding = (DW_EH_PE_pcrel | DW_EH_PE_indirect);
|
lsda.type_table_encoding = (DW_EH_PE_pcrel | DW_EH_PE_indirect);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lsda.callsite_encoding = (enum dwarf_data_encoding)(*(data++));
|
lsda.callsite_encoding = static_cast<enum dwarf_data_encoding>(*(data++));
|
||||||
|
|
||||||
// Action table is immediately after the call site table
|
// Action table is immediately after the call site table
|
||||||
lsda.action_table = data;
|
lsda.action_table = data;
|
||||||
uintptr_t callsite_size = (uintptr_t)read_uleb128(&data);
|
uintptr_t callsite_size = static_cast<uintptr_t>(read_uleb128(&data));
|
||||||
lsda.action_table = data + callsite_size;
|
lsda.action_table = data + callsite_size;
|
||||||
// Call site table is immediately after the header
|
// Call site table is immediately after the header
|
||||||
lsda.call_site_table = (dw_eh_ptr_t)data;
|
lsda.call_site_table = static_cast<dw_eh_ptr_t>(data);
|
||||||
|
|
||||||
|
|
||||||
return lsda;
|
return lsda;
|
||||||
|
@ -413,7 +413,7 @@ static bool dwarf_eh_find_callsite(struct _Unwind_Context *context,
|
||||||
result->landing_pad = 0;
|
result->landing_pad = 0;
|
||||||
// The current instruction pointer offset within the region
|
// The current instruction pointer offset within the region
|
||||||
uint64_t ip = _Unwind_GetIP(context) - _Unwind_GetRegionStart(context);
|
uint64_t ip = _Unwind_GetIP(context) - _Unwind_GetRegionStart(context);
|
||||||
unsigned char *callsite_table = (unsigned char*)lsda->call_site_table;
|
unsigned char *callsite_table = static_cast<unsigned char*>(lsda->call_site_table);
|
||||||
|
|
||||||
while (callsite_table <= lsda->action_table)
|
while (callsite_table <= lsda->action_table)
|
||||||
{
|
{
|
||||||
|
@ -463,17 +463,17 @@ static bool dwarf_eh_find_callsite(struct _Unwind_Context *context,
|
||||||
|
|
||||||
/// Defines an exception class from 8 bytes (endian independent)
|
/// Defines an exception class from 8 bytes (endian independent)
|
||||||
#define EXCEPTION_CLASS(a,b,c,d,e,f,g,h) \
|
#define EXCEPTION_CLASS(a,b,c,d,e,f,g,h) \
|
||||||
(((uint64_t)a << 56) +\
|
((static_cast<uint64_t>(a) << 56) +\
|
||||||
((uint64_t)b << 48) +\
|
(static_cast<uint64_t>(b) << 48) +\
|
||||||
((uint64_t)c << 40) +\
|
(static_cast<uint64_t>(c) << 40) +\
|
||||||
((uint64_t)d << 32) +\
|
(static_cast<uint64_t>(d) << 32) +\
|
||||||
((uint64_t)e << 24) +\
|
(static_cast<uint64_t>(e) << 24) +\
|
||||||
((uint64_t)f << 16) +\
|
(static_cast<uint64_t>(f) << 16) +\
|
||||||
((uint64_t)g << 8) +\
|
(static_cast<uint64_t>(g) << 8) +\
|
||||||
((uint64_t)h))
|
(static_cast<uint64_t>(h)))
|
||||||
|
|
||||||
#define GENERIC_EXCEPTION_CLASS(e,f,g,h) \
|
#define GENERIC_EXCEPTION_CLASS(e,f,g,h) \
|
||||||
((uint32_t)e << 24) +\
|
(static_cast<uint32_t>(e) << 24) +\
|
||||||
((uint32_t)f << 16) +\
|
(static_cast<uint32_t>(f) << 16) +\
|
||||||
((uint32_t)g << 8) +\
|
(static_cast<uint32_t>(g) << 8) +\
|
||||||
((uint32_t)h)
|
(static_cast<uint32_t>(h))
|
||||||
|
|
|
@ -44,7 +44,7 @@ struct vtable_header
|
||||||
* Simple macro that does pointer arithmetic in bytes but returns a value of
|
* Simple macro that does pointer arithmetic in bytes but returns a value of
|
||||||
* the same type as the original.
|
* the same type as the original.
|
||||||
*/
|
*/
|
||||||
#define ADD_TO_PTR(x, off) (__typeof__(x))(((char*)x) + off)
|
#define ADD_TO_PTR(x, off) reinterpret_cast<__typeof__(x)>(reinterpret_cast<char*>(x) + off)
|
||||||
|
|
||||||
bool std::type_info::__do_catch(std::type_info const *ex_type,
|
bool std::type_info::__do_catch(std::type_info const *ex_type,
|
||||||
void **exception_object,
|
void **exception_object,
|
||||||
|
@ -166,7 +166,7 @@ bool __vmi_class_type_info::__do_upcast(const __class_type_info *target,
|
||||||
if (info->isVirtual())
|
if (info->isVirtual())
|
||||||
{
|
{
|
||||||
// Object's vtable
|
// Object's vtable
|
||||||
ptrdiff_t *off = *(ptrdiff_t**)obj;
|
ptrdiff_t *off = *static_cast<ptrdiff_t**>(obj);
|
||||||
// Offset location in vtable
|
// Offset location in vtable
|
||||||
off = ADD_TO_PTR(off, offset);
|
off = ADD_TO_PTR(off, offset);
|
||||||
offset = *off;
|
offset = *off;
|
||||||
|
@ -202,9 +202,9 @@ extern "C" void* __dynamic_cast(const void *sub,
|
||||||
const __class_type_info *dst,
|
const __class_type_info *dst,
|
||||||
ptrdiff_t src2dst_offset)
|
ptrdiff_t src2dst_offset)
|
||||||
{
|
{
|
||||||
char *vtable_location = *(char**)sub;
|
const char *vtable_location = *static_cast<const char * const *>(sub);
|
||||||
const vtable_header *header =
|
const vtable_header *header =
|
||||||
(const vtable_header*)(vtable_location - sizeof(vtable_header));
|
reinterpret_cast<const vtable_header*>(vtable_location - sizeof(vtable_header));
|
||||||
void *leaf = ADD_TO_PTR((void*)sub, header->leaf_offset);
|
void *leaf = ADD_TO_PTR(const_cast<void *>(sub), header->leaf_offset);
|
||||||
return header->type->cast_to(leaf, dst);
|
return header->type->cast_to(leaf, dst);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,8 @@ static void saveLandingPad(struct _Unwind_Context *context,
|
||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
// On ARM, we store the saved exception in the generic part of the structure
|
// On ARM, we store the saved exception in the generic part of the structure
|
||||||
ucb->barrier_cache.sp = _Unwind_GetGR(context, 13);
|
ucb->barrier_cache.sp = _Unwind_GetGR(context, 13);
|
||||||
ucb->barrier_cache.bitpattern[1] = (uint32_t)selector;
|
ucb->barrier_cache.bitpattern[1] = static_cast<uint32_t>(selector);
|
||||||
ucb->barrier_cache.bitpattern[3] = (uint32_t)landingPad;
|
ucb->barrier_cache.bitpattern[3] = reinterpret_cast<uint32_t>(landingPad);
|
||||||
#endif
|
#endif
|
||||||
// Cache the results for the phase 2 unwind, if we found a handler
|
// Cache the results for the phase 2 unwind, if we found a handler
|
||||||
// and this is not a foreign exception.
|
// and this is not a foreign exception.
|
||||||
|
@ -97,13 +97,13 @@ static int loadLandingPad(struct _Unwind_Context *context,
|
||||||
{
|
{
|
||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
*selector = ucb->barrier_cache.bitpattern[1];
|
*selector = ucb->barrier_cache.bitpattern[1];
|
||||||
*landingPad = (dw_eh_ptr_t)ucb->barrier_cache.bitpattern[3];
|
*landingPad = reinterpret_cast<dw_eh_ptr_t>(ucb->barrier_cache.bitpattern[3]);
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
if (ex)
|
if (ex)
|
||||||
{
|
{
|
||||||
*selector = ex->handlerSwitchValue;
|
*selector = ex->handlerSwitchValue;
|
||||||
*landingPad = (dw_eh_ptr_t)ex->catchTemp;
|
*landingPad = reinterpret_cast<dw_eh_ptr_t>(ex->catchTemp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -267,13 +267,13 @@ static bool isDependentException(uint64_t cls)
|
||||||
|
|
||||||
static __cxa_exception *exceptionFromPointer(void *ex)
|
static __cxa_exception *exceptionFromPointer(void *ex)
|
||||||
{
|
{
|
||||||
return (__cxa_exception*)((char*)ex -
|
return reinterpret_cast<__cxa_exception*>(static_cast<char*>(ex) -
|
||||||
offsetof(struct __cxa_exception, unwindHeader));
|
offsetof(struct __cxa_exception, unwindHeader));
|
||||||
}
|
}
|
||||||
static __cxa_exception *realExceptionFromException(__cxa_exception *ex)
|
static __cxa_exception *realExceptionFromException(__cxa_exception *ex)
|
||||||
{
|
{
|
||||||
if (!isDependentException(ex->unwindHeader.exception_class)) { return ex; }
|
if (!isDependentException(ex->unwindHeader.exception_class)) { return ex; }
|
||||||
return ((__cxa_exception*)(((__cxa_dependent_exception*)ex)->primaryException))-1;
|
return reinterpret_cast<__cxa_exception*>((reinterpret_cast<__cxa_dependent_exception*>(ex))->primaryException)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,13 +304,13 @@ static pthread_key_t eh_key;
|
||||||
static void exception_cleanup(_Unwind_Reason_Code reason,
|
static void exception_cleanup(_Unwind_Reason_Code reason,
|
||||||
struct _Unwind_Exception *ex)
|
struct _Unwind_Exception *ex)
|
||||||
{
|
{
|
||||||
__cxa_free_exception((void*)ex);
|
__cxa_free_exception(static_cast<void*>(ex));
|
||||||
}
|
}
|
||||||
static void dependent_exception_cleanup(_Unwind_Reason_Code reason,
|
static void dependent_exception_cleanup(_Unwind_Reason_Code reason,
|
||||||
struct _Unwind_Exception *ex)
|
struct _Unwind_Exception *ex)
|
||||||
{
|
{
|
||||||
|
|
||||||
__cxa_free_dependent_exception((void*)ex);
|
__cxa_free_dependent_exception(static_cast<void*>(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -333,13 +333,13 @@ static void free_exception_list(__cxa_exception *ex)
|
||||||
*/
|
*/
|
||||||
static void thread_cleanup(void* thread_info)
|
static void thread_cleanup(void* thread_info)
|
||||||
{
|
{
|
||||||
__cxa_thread_info *info = (__cxa_thread_info*)thread_info;
|
__cxa_thread_info *info = static_cast<__cxa_thread_info*>(thread_info);
|
||||||
if (info->globals.caughtExceptions)
|
if (info->globals.caughtExceptions)
|
||||||
{
|
{
|
||||||
// If this is a foreign exception, ask it to clean itself up.
|
// If this is a foreign exception, ask it to clean itself up.
|
||||||
if (info->foreign_exception_state != __cxa_thread_info::none)
|
if (info->foreign_exception_state != __cxa_thread_info::none)
|
||||||
{
|
{
|
||||||
_Unwind_Exception *e = (_Unwind_Exception*)info->globals.caughtExceptions;
|
_Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions);
|
||||||
e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
|
e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -379,8 +379,8 @@ static void init_key(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pthread_key_create(&eh_key, thread_cleanup);
|
pthread_key_create(&eh_key, thread_cleanup);
|
||||||
pthread_setspecific(eh_key, (void*)0x42);
|
pthread_setspecific(eh_key, reinterpret_cast<void *>(0x42));
|
||||||
fakeTLS = (pthread_getspecific(eh_key) != (void*)0x42);
|
fakeTLS = (pthread_getspecific(eh_key) != reinterpret_cast<void *>(0x42));
|
||||||
pthread_setspecific(eh_key, 0);
|
pthread_setspecific(eh_key, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,10 +394,10 @@ static __cxa_thread_info *thread_info()
|
||||||
fakeTLS = true;
|
fakeTLS = true;
|
||||||
}
|
}
|
||||||
if (fakeTLS) { return &singleThreadInfo; }
|
if (fakeTLS) { return &singleThreadInfo; }
|
||||||
__cxa_thread_info *info = (__cxa_thread_info*)pthread_getspecific(eh_key);
|
__cxa_thread_info *info = static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key));
|
||||||
if (0 == info)
|
if (0 == info)
|
||||||
{
|
{
|
||||||
info = (__cxa_thread_info*)calloc(1, sizeof(__cxa_thread_info));
|
info = static_cast<__cxa_thread_info*>(calloc(1, sizeof(__cxa_thread_info)));
|
||||||
pthread_setspecific(eh_key, info);
|
pthread_setspecific(eh_key, info);
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
|
@ -409,7 +409,7 @@ static __cxa_thread_info *thread_info()
|
||||||
static __cxa_thread_info *thread_info_fast()
|
static __cxa_thread_info *thread_info_fast()
|
||||||
{
|
{
|
||||||
if (fakeTLS) { return &singleThreadInfo; }
|
if (fakeTLS) { return &singleThreadInfo; }
|
||||||
return (__cxa_thread_info*)pthread_getspecific(eh_key);
|
return static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* ABI function returning the __cxa_eh_globals structure.
|
* ABI function returning the __cxa_eh_globals structure.
|
||||||
|
@ -472,7 +472,7 @@ static char *emergency_malloc(size_t size)
|
||||||
if (0 != m)
|
if (0 != m)
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&emergency_malloc_lock);
|
pthread_mutex_unlock(&emergency_malloc_lock);
|
||||||
return (char*)m;
|
return static_cast<char*>(m);
|
||||||
}
|
}
|
||||||
for (int i=0 ; i<16 ; i++)
|
for (int i=0 ; i<16 ; i++)
|
||||||
{
|
{
|
||||||
|
@ -510,7 +510,7 @@ static void emergency_malloc_free(char *ptr)
|
||||||
// Find the buffer corresponding to this pointer.
|
// Find the buffer corresponding to this pointer.
|
||||||
for (int i=0 ; i<16 ; i++)
|
for (int i=0 ; i<16 ; i++)
|
||||||
{
|
{
|
||||||
if (ptr == (void*)(emergency_buffer + (1024 * i)))
|
if (ptr == static_cast<void*>(emergency_buffer + (1024 * i)))
|
||||||
{
|
{
|
||||||
buffer = i;
|
buffer = i;
|
||||||
break;
|
break;
|
||||||
|
@ -521,7 +521,7 @@ static void emergency_malloc_free(char *ptr)
|
||||||
// emergency_malloc() is expected to return 0-initialized data. We don't
|
// emergency_malloc() is expected to return 0-initialized data. We don't
|
||||||
// zero the buffer when allocating it, because the static buffers will
|
// zero the buffer when allocating it, because the static buffers will
|
||||||
// begin life containing 0 values.
|
// begin life containing 0 values.
|
||||||
memset((void*)ptr, 0, 1024);
|
memset(ptr, 0, 1024);
|
||||||
// Signal the condition variable to wake up any threads that are blocking
|
// Signal the condition variable to wake up any threads that are blocking
|
||||||
// waiting for some space in the emergency buffer
|
// waiting for some space in the emergency buffer
|
||||||
pthread_mutex_lock(&emergency_malloc_lock);
|
pthread_mutex_lock(&emergency_malloc_lock);
|
||||||
|
@ -535,7 +535,7 @@ static void emergency_malloc_free(char *ptr)
|
||||||
|
|
||||||
static char *alloc_or_die(size_t size)
|
static char *alloc_or_die(size_t size)
|
||||||
{
|
{
|
||||||
char *buffer = (char*)calloc(1, size);
|
char *buffer = static_cast<char*>(calloc(1, size));
|
||||||
|
|
||||||
// If calloc() doesn't want to give us any memory, try using an emergency
|
// If calloc() doesn't want to give us any memory, try using an emergency
|
||||||
// buffer.
|
// buffer.
|
||||||
|
@ -597,7 +597,7 @@ extern "C" void *__cxa_allocate_dependent_exception(void)
|
||||||
*/
|
*/
|
||||||
extern "C" void __cxa_free_exception(void *thrown_exception)
|
extern "C" void __cxa_free_exception(void *thrown_exception)
|
||||||
{
|
{
|
||||||
__cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1;
|
__cxa_exception *ex = reinterpret_cast<__cxa_exception*>(thrown_exception) - 1;
|
||||||
// Free the object that was thrown, calling its destructor
|
// Free the object that was thrown, calling its destructor
|
||||||
if (0 != ex->exceptionDestructor)
|
if (0 != ex->exceptionDestructor)
|
||||||
{
|
{
|
||||||
|
@ -612,7 +612,7 @@ extern "C" void __cxa_free_exception(void *thrown_exception)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free_exception((char*)ex);
|
free_exception(reinterpret_cast<char*>(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void releaseException(__cxa_exception *exception)
|
static void releaseException(__cxa_exception *exception)
|
||||||
|
@ -633,13 +633,13 @@ static void releaseException(__cxa_exception *exception)
|
||||||
|
|
||||||
void __cxa_free_dependent_exception(void *thrown_exception)
|
void __cxa_free_dependent_exception(void *thrown_exception)
|
||||||
{
|
{
|
||||||
__cxa_dependent_exception *ex = ((__cxa_dependent_exception*)thrown_exception) - 1;
|
__cxa_dependent_exception *ex = reinterpret_cast<__cxa_dependent_exception*>(thrown_exception) - 1;
|
||||||
assert(isDependentException(ex->unwindHeader.exception_class));
|
assert(isDependentException(ex->unwindHeader.exception_class));
|
||||||
if (ex->primaryException)
|
if (ex->primaryException)
|
||||||
{
|
{
|
||||||
releaseException(realExceptionFromException((__cxa_exception*)ex));
|
releaseException(realExceptionFromException(reinterpret_cast<__cxa_exception*>(ex)));
|
||||||
}
|
}
|
||||||
free_exception((char*)ex);
|
free_exception(reinterpret_cast<char*>(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -654,8 +654,8 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c)
|
||||||
{
|
{
|
||||||
Dl_info myinfo;
|
Dl_info myinfo;
|
||||||
int mylookup =
|
int mylookup =
|
||||||
dladdr((void*)(uintptr_t)__cxa_current_exception_type, &myinfo);
|
dladdr(reinterpret_cast<const void *>(__cxa_current_exception_type), &myinfo);
|
||||||
void *ip = (void*)_Unwind_GetIP(context);
|
void *ip = reinterpret_cast<void*>(_Unwind_GetIP(context));
|
||||||
Dl_info info;
|
Dl_info info;
|
||||||
if (dladdr(ip, &info) != 0)
|
if (dladdr(ip, &info) != 0)
|
||||||
{
|
{
|
||||||
|
@ -688,7 +688,7 @@ static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exce
|
||||||
#endif
|
#endif
|
||||||
case _URC_END_OF_STACK:
|
case _URC_END_OF_STACK:
|
||||||
fprintf(stderr, "Terminating due to uncaught exception %p",
|
fprintf(stderr, "Terminating due to uncaught exception %p",
|
||||||
(void*)thrown_exception);
|
static_cast<void*>(thrown_exception));
|
||||||
thrown_exception = realExceptionFromException(thrown_exception);
|
thrown_exception = realExceptionFromException(thrown_exception);
|
||||||
static const __class_type_info *e_ti =
|
static const __class_type_info *e_ti =
|
||||||
static_cast<const __class_type_info*>(&typeid(std::exception));
|
static_cast<const __class_type_info*>(&typeid(std::exception));
|
||||||
|
@ -697,8 +697,8 @@ static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exce
|
||||||
if (throw_ti)
|
if (throw_ti)
|
||||||
{
|
{
|
||||||
std::exception *e =
|
std::exception *e =
|
||||||
(std::exception*)e_ti->cast_to((void*)(thrown_exception+1),
|
static_cast<std::exception*>(e_ti->cast_to(static_cast<void*>(thrown_exception+1),
|
||||||
throw_ti);
|
throw_ti));
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
fprintf(stderr, " '%s'", e->what());
|
fprintf(stderr, " '%s'", e->what());
|
||||||
|
@ -706,12 +706,12 @@ static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exce
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t bufferSize = 128;
|
size_t bufferSize = 128;
|
||||||
char *demangled = (char*)malloc(bufferSize);
|
char *demangled = static_cast<char*>(malloc(bufferSize));
|
||||||
const char *mangled = thrown_exception->exceptionType->name();
|
const char *mangled = thrown_exception->exceptionType->name();
|
||||||
int status;
|
int status;
|
||||||
demangled = __cxa_demangle(mangled, demangled, &bufferSize, &status);
|
demangled = __cxa_demangle(mangled, demangled, &bufferSize, &status);
|
||||||
fprintf(stderr, " of type %s\n",
|
fprintf(stderr, " of type %s\n",
|
||||||
status == 0 ? (const char*)demangled : mangled);
|
status == 0 ? demangled : mangled);
|
||||||
if (status == 0) { free(demangled); }
|
if (status == 0) { free(demangled); }
|
||||||
// Print a back trace if no handler is found.
|
// Print a back trace if no handler is found.
|
||||||
// TODO: Make this optional
|
// TODO: Make this optional
|
||||||
|
@ -753,7 +753,7 @@ extern "C" void __cxa_throw(void *thrown_exception,
|
||||||
std::type_info *tinfo,
|
std::type_info *tinfo,
|
||||||
void(*dest)(void*))
|
void(*dest)(void*))
|
||||||
{
|
{
|
||||||
__cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1;
|
__cxa_exception *ex = reinterpret_cast<__cxa_exception*>(thrown_exception) - 1;
|
||||||
|
|
||||||
ex->referenceCount = 1;
|
ex->referenceCount = 1;
|
||||||
ex->exceptionType = tinfo;
|
ex->exceptionType = tinfo;
|
||||||
|
@ -771,7 +771,7 @@ extern "C" void __cxa_rethrow_primary_exception(void* thrown_exception)
|
||||||
if (NULL == thrown_exception) { return; }
|
if (NULL == thrown_exception) { return; }
|
||||||
|
|
||||||
__cxa_exception *original = exceptionFromPointer(thrown_exception);
|
__cxa_exception *original = exceptionFromPointer(thrown_exception);
|
||||||
__cxa_dependent_exception *ex = ((__cxa_dependent_exception*)__cxa_allocate_dependent_exception())-1;
|
__cxa_dependent_exception *ex = reinterpret_cast<__cxa_dependent_exception*>(__cxa_allocate_dependent_exception())-1;
|
||||||
|
|
||||||
ex->primaryException = thrown_exception;
|
ex->primaryException = thrown_exception;
|
||||||
__cxa_increment_exception_refcount(thrown_exception);
|
__cxa_increment_exception_refcount(thrown_exception);
|
||||||
|
@ -780,7 +780,7 @@ extern "C" void __cxa_rethrow_primary_exception(void* thrown_exception)
|
||||||
ex->unwindHeader.exception_class = dependent_exception_class;
|
ex->unwindHeader.exception_class = dependent_exception_class;
|
||||||
ex->unwindHeader.exception_cleanup = dependent_exception_cleanup;
|
ex->unwindHeader.exception_cleanup = dependent_exception_cleanup;
|
||||||
|
|
||||||
throw_exception((__cxa_exception*)ex);
|
throw_exception(reinterpret_cast<__cxa_exception*>(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void *__cxa_current_primary_exception(void)
|
extern "C" void *__cxa_current_primary_exception(void)
|
||||||
|
@ -797,14 +797,14 @@ extern "C" void *__cxa_current_primary_exception(void)
|
||||||
extern "C" void __cxa_increment_exception_refcount(void* thrown_exception)
|
extern "C" void __cxa_increment_exception_refcount(void* thrown_exception)
|
||||||
{
|
{
|
||||||
if (NULL == thrown_exception) { return; }
|
if (NULL == thrown_exception) { return; }
|
||||||
__cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1;
|
__cxa_exception *ex = static_cast<__cxa_exception*>(thrown_exception) - 1;
|
||||||
if (isDependentException(ex->unwindHeader.exception_class)) { return; }
|
if (isDependentException(ex->unwindHeader.exception_class)) { return; }
|
||||||
__sync_fetch_and_add(&ex->referenceCount, 1);
|
__sync_fetch_and_add(&ex->referenceCount, 1);
|
||||||
}
|
}
|
||||||
extern "C" void __cxa_decrement_exception_refcount(void* thrown_exception)
|
extern "C" void __cxa_decrement_exception_refcount(void* thrown_exception)
|
||||||
{
|
{
|
||||||
if (NULL == thrown_exception) { return; }
|
if (NULL == thrown_exception) { return; }
|
||||||
__cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1;
|
__cxa_exception *ex = static_cast<__cxa_exception*>(thrown_exception) - 1;
|
||||||
releaseException(ex);
|
releaseException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,7 +836,7 @@ extern "C" void __cxa_rethrow()
|
||||||
if (ti->foreign_exception_state != __cxa_thread_info::none)
|
if (ti->foreign_exception_state != __cxa_thread_info::none)
|
||||||
{
|
{
|
||||||
ti->foreign_exception_state = __cxa_thread_info::rethrown;
|
ti->foreign_exception_state = __cxa_thread_info::rethrown;
|
||||||
_Unwind_Exception *e = (_Unwind_Exception*)ex;
|
_Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ex);
|
||||||
_Unwind_Reason_Code err = _Unwind_Resume_or_Rethrow(e);
|
_Unwind_Reason_Code err = _Unwind_Resume_or_Rethrow(e);
|
||||||
report_failure(err, ex);
|
report_failure(err, ex);
|
||||||
return;
|
return;
|
||||||
|
@ -879,8 +879,8 @@ static std::type_info *get_type_info_entry(_Unwind_Context *context,
|
||||||
if (offset == 0) { return 0; }
|
if (offset == 0) { return 0; }
|
||||||
|
|
||||||
// ...so we need to resolve it
|
// ...so we need to resolve it
|
||||||
return (std::type_info*)resolve_indirect_value(context,
|
return reinterpret_cast<std::type_info*>(resolve_indirect_value(context,
|
||||||
lsda->type_table_encoding, offset, start);
|
lsda->type_table_encoding, offset, start));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -894,13 +894,13 @@ static bool check_type_signature(__cxa_exception *ex,
|
||||||
const std::type_info *type,
|
const std::type_info *type,
|
||||||
void *&adjustedPtr)
|
void *&adjustedPtr)
|
||||||
{
|
{
|
||||||
void *exception_ptr = (void*)(ex+1);
|
void *exception_ptr = static_cast<void*>(ex+1);
|
||||||
const std::type_info *ex_type = ex ? ex->exceptionType : 0;
|
const std::type_info *ex_type = ex ? ex->exceptionType : 0;
|
||||||
|
|
||||||
bool is_ptr = ex ? ex_type->__is_pointer_p() : false;
|
bool is_ptr = ex ? ex_type->__is_pointer_p() : false;
|
||||||
if (is_ptr)
|
if (is_ptr)
|
||||||
{
|
{
|
||||||
exception_ptr = *(void**)exception_ptr;
|
exception_ptr = *static_cast<void**>(exception_ptr);
|
||||||
}
|
}
|
||||||
// Always match a catchall, even with a foreign exception
|
// Always match a catchall, even with a foreign exception
|
||||||
//
|
//
|
||||||
|
@ -985,7 +985,7 @@ static handler_type check_action_record(_Unwind_Context *context,
|
||||||
handler_type = get_type_info_entry(context, lsda, filter--);
|
handler_type = get_type_info_entry(context, lsda, filter--);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
unsigned char *type_index = ((unsigned char*)lsda->type_table - filter - 1);
|
unsigned char *type_index = reinterpret_cast<unsigned char*>(lsda->type_table) - filter - 1;
|
||||||
while (*type_index)
|
while (*type_index)
|
||||||
{
|
{
|
||||||
std::type_info *handler_type = get_type_info_entry(context, lsda, *(type_index++));
|
std::type_info *handler_type = get_type_info_entry(context, lsda, *(type_index++));
|
||||||
|
@ -1062,8 +1062,13 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0)
|
||||||
realEx = realExceptionFromException(ex);
|
realEx = realExceptionFromException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __arm__
|
||||||
unsigned char *lsda_addr =
|
unsigned char *lsda_addr =
|
||||||
(unsigned char*)_Unwind_GetLanguageSpecificData(context);
|
static_cast<unsigned char*>(_Unwind_GetLanguageSpecificData(context));
|
||||||
|
#else
|
||||||
|
unsigned char *lsda_addr =
|
||||||
|
reinterpret_cast<unsigned char*>(static_cast<uintptr_t>(_Unwind_GetLanguageSpecificData(context)));
|
||||||
|
#endif
|
||||||
|
|
||||||
// No LSDA implies no landing pads - try the next frame
|
// No LSDA implies no landing pads - try the next frame
|
||||||
if (0 == lsda_addr) { return continueUnwinding(exceptionObject, context); }
|
if (0 == lsda_addr) { return continueUnwinding(exceptionObject, context); }
|
||||||
|
@ -1112,8 +1117,8 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0)
|
||||||
if (ex)
|
if (ex)
|
||||||
{
|
{
|
||||||
saveLandingPad(context, exceptionObject, ex, selector, action.landing_pad);
|
saveLandingPad(context, exceptionObject, ex, selector, action.landing_pad);
|
||||||
ex->languageSpecificData = (const char*)lsda_addr;
|
ex->languageSpecificData = reinterpret_cast<const char*>(lsda_addr);
|
||||||
ex->actionRecord = (const char*)action.action_record;
|
ex->actionRecord = reinterpret_cast<const char*>(action.action_record);
|
||||||
// ex->adjustedPtr is set when finding the action record.
|
// ex->adjustedPtr is set when finding the action record.
|
||||||
}
|
}
|
||||||
return _URC_HANDLER_FOUND;
|
return _URC_HANDLER_FOUND;
|
||||||
|
@ -1159,9 +1164,9 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_Unwind_SetIP(context, (unsigned long)action.landing_pad);
|
_Unwind_SetIP(context, reinterpret_cast<unsigned long>(action.landing_pad));
|
||||||
_Unwind_SetGR(context, __builtin_eh_return_data_regno(0),
|
_Unwind_SetGR(context, __builtin_eh_return_data_regno(0),
|
||||||
(unsigned long)exceptionObject);
|
reinterpret_cast<unsigned long>(exceptionObject));
|
||||||
_Unwind_SetGR(context, __builtin_eh_return_data_regno(1), selector);
|
_Unwind_SetGR(context, __builtin_eh_return_data_regno(1), selector);
|
||||||
|
|
||||||
return _URC_INSTALL_CONTEXT;
|
return _URC_INSTALL_CONTEXT;
|
||||||
|
@ -1185,7 +1190,7 @@ extern "C" void *__cxa_begin_catch(void *e)
|
||||||
__cxa_thread_info *ti = thread_info();
|
__cxa_thread_info *ti = thread_info();
|
||||||
__cxa_eh_globals *globals = &ti->globals;
|
__cxa_eh_globals *globals = &ti->globals;
|
||||||
globals->uncaughtExceptions--;
|
globals->uncaughtExceptions--;
|
||||||
_Unwind_Exception *exceptionObject = (_Unwind_Exception*)e;
|
_Unwind_Exception *exceptionObject = static_cast<_Unwind_Exception*>(e);
|
||||||
|
|
||||||
if (isCXXException(exceptionObject->exception_class))
|
if (isCXXException(exceptionObject->exception_class))
|
||||||
{
|
{
|
||||||
|
@ -1239,12 +1244,12 @@ extern "C" void *__cxa_begin_catch(void *e)
|
||||||
{
|
{
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
globals->caughtExceptions = (__cxa_exception*)exceptionObject;
|
globals->caughtExceptions = reinterpret_cast<__cxa_exception*>(exceptionObject);
|
||||||
ti->foreign_exception_state = __cxa_thread_info::caught;
|
ti->foreign_exception_state = __cxa_thread_info::caught;
|
||||||
}
|
}
|
||||||
// exceptionObject is the pointer to the _Unwind_Exception within the
|
// exceptionObject is the pointer to the _Unwind_Exception within the
|
||||||
// __cxa_exception. The throw object is after this
|
// __cxa_exception. The throw object is after this
|
||||||
return ((char*)exceptionObject + sizeof(_Unwind_Exception));
|
return (reinterpret_cast<char*>(exceptionObject) + sizeof(_Unwind_Exception));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1268,7 +1273,7 @@ extern "C" void __cxa_end_catch()
|
||||||
globals->caughtExceptions = 0;
|
globals->caughtExceptions = 0;
|
||||||
if (ti->foreign_exception_state != __cxa_thread_info::rethrown)
|
if (ti->foreign_exception_state != __cxa_thread_info::rethrown)
|
||||||
{
|
{
|
||||||
_Unwind_Exception *e = (_Unwind_Exception*)ti->globals.caughtExceptions;
|
_Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions);
|
||||||
e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
|
e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
|
||||||
}
|
}
|
||||||
ti->foreign_exception_state = __cxa_thread_info::none;
|
ti->foreign_exception_state = __cxa_thread_info::none;
|
||||||
|
@ -1330,7 +1335,7 @@ extern "C" std::type_info *__cxa_current_exception_type()
|
||||||
*/
|
*/
|
||||||
extern "C" void __cxa_call_unexpected(void*exception)
|
extern "C" void __cxa_call_unexpected(void*exception)
|
||||||
{
|
{
|
||||||
_Unwind_Exception *exceptionObject = (_Unwind_Exception*)exception;
|
_Unwind_Exception *exceptionObject = static_cast<_Unwind_Exception*>(exception);
|
||||||
if (exceptionObject->exception_class == exception_class)
|
if (exceptionObject->exception_class == exception_class)
|
||||||
{
|
{
|
||||||
__cxa_exception *ex = exceptionFromPointer(exceptionObject);
|
__cxa_exception *ex = exceptionFromPointer(exceptionObject);
|
||||||
|
|
|
@ -70,16 +70,16 @@
|
||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
// ARM ABI - 32-bit guards.
|
// ARM ABI - 32-bit guards.
|
||||||
typedef uint32_t guard_t;
|
typedef uint32_t guard_t;
|
||||||
static const uint32_t LOCKED = ((guard_t)1) << 31;
|
static const uint32_t LOCKED = static_cast<guard_t>(1) << 31;
|
||||||
static const uint32_t INITIALISED = 1;
|
static const uint32_t INITIALISED = 1;
|
||||||
#else
|
#else
|
||||||
typedef uint64_t guard_t;
|
typedef uint64_t guard_t;
|
||||||
# if defined(__LITTLE_ENDIAN__)
|
# if defined(__LITTLE_ENDIAN__)
|
||||||
static const guard_t LOCKED = ((guard_t)1) << 63;
|
static const guard_t LOCKED = static_cast<guard_t>(1) << 63;
|
||||||
static const guard_t INITIALISED = 1;
|
static const guard_t INITIALISED = 1;
|
||||||
# else
|
# else
|
||||||
static const guard_t LOCKED = 1;
|
static const guard_t LOCKED = 1;
|
||||||
static const guard_t INITIALISED = ((guard_t)1) << 56;
|
static const guard_t INITIALISED = static_cast<guard_t>(1) << 56;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -405,6 +405,7 @@ static int cpp_demangle_read_expression_trinary(struct cpp_demangle_data *,
|
||||||
const char *, size_t, const char *, size_t);
|
const char *, size_t, const char *, size_t);
|
||||||
static int cpp_demangle_read_function(struct cpp_demangle_data *, int *,
|
static int cpp_demangle_read_function(struct cpp_demangle_data *, int *,
|
||||||
struct vector_type_qualifier *);
|
struct vector_type_qualifier *);
|
||||||
|
static int cpp_demangle_local_source_name(struct cpp_demangle_data *ddata);
|
||||||
static int cpp_demangle_read_local_name(struct cpp_demangle_data *);
|
static int cpp_demangle_read_local_name(struct cpp_demangle_data *);
|
||||||
static int cpp_demangle_read_name(struct cpp_demangle_data *);
|
static int cpp_demangle_read_name(struct cpp_demangle_data *);
|
||||||
static int cpp_demangle_read_nested_name(struct cpp_demangle_data *);
|
static int cpp_demangle_read_nested_name(struct cpp_demangle_data *);
|
||||||
|
@ -453,20 +454,12 @@ __cxa_demangle_gnu3(const char *org)
|
||||||
struct cpp_demangle_data ddata;
|
struct cpp_demangle_data ddata;
|
||||||
ssize_t org_len;
|
ssize_t org_len;
|
||||||
unsigned int limit;
|
unsigned int limit;
|
||||||
char *rtn;
|
char *rtn = NULL;
|
||||||
|
|
||||||
if (org == NULL)
|
if (org == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
// Try demangling as a type for short encodings
|
org_len = strlen(org);
|
||||||
if (((org_len = strlen(org)) < 2) || (org[0] != '_' || org[1] != 'Z' )) {
|
|
||||||
if (!cpp_demangle_data_init(&ddata, org))
|
|
||||||
return (NULL);
|
|
||||||
if (!cpp_demangle_read_type(&ddata, 0))
|
|
||||||
goto clean;
|
|
||||||
rtn = vector_str_get_flat(&ddata.output, (size_t *) NULL);
|
|
||||||
goto clean;
|
|
||||||
}
|
|
||||||
if (org_len > 11 && !strncmp(org, "_GLOBAL__I_", 11)) {
|
if (org_len > 11 && !strncmp(org, "_GLOBAL__I_", 11)) {
|
||||||
if ((rtn = malloc(org_len + 19)) == NULL)
|
if ((rtn = malloc(org_len + 19)) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -475,6 +468,16 @@ __cxa_demangle_gnu3(const char *org)
|
||||||
return (rtn);
|
return (rtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try demangling as a type for short encodings
|
||||||
|
if ((org_len < 2) || (org[0] != '_' || org[1] != 'Z' )) {
|
||||||
|
if (!cpp_demangle_data_init(&ddata, org))
|
||||||
|
return (NULL);
|
||||||
|
if (!cpp_demangle_read_type(&ddata, 0))
|
||||||
|
goto clean;
|
||||||
|
rtn = vector_str_get_flat(&ddata.output, (size_t *) NULL);
|
||||||
|
goto clean;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!cpp_demangle_data_init(&ddata, org + 2))
|
if (!cpp_demangle_data_init(&ddata, org + 2))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -604,13 +607,12 @@ cpp_demangle_push_fp(struct cpp_demangle_data *ddata,
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
rtn = 0;
|
rtn = 0;
|
||||||
if ((len = strlen(f)) > 0 &&
|
if ((len = strlen(f)) > 0)
|
||||||
cpp_demangle_push_str(ddata, f, len))
|
rtn = cpp_demangle_push_str(ddata, f, len);
|
||||||
rtn = 1;
|
|
||||||
|
|
||||||
free(f);
|
free(f);
|
||||||
|
|
||||||
return (0);
|
return (rtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -655,6 +657,7 @@ cpp_demangle_push_subst_v(struct cpp_demangle_data *ddata, struct vector_str *v)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
rtn = cpp_demangle_push_subst(ddata, str, str_len);
|
rtn = cpp_demangle_push_subst(ddata, str, str_len);
|
||||||
|
|
||||||
free(str);
|
free(str);
|
||||||
|
|
||||||
return (rtn);
|
return (rtn);
|
||||||
|
@ -1868,9 +1871,18 @@ static int
|
||||||
cpp_demangle_read_sname(struct cpp_demangle_data *ddata)
|
cpp_demangle_read_sname(struct cpp_demangle_data *ddata)
|
||||||
{
|
{
|
||||||
long len;
|
long len;
|
||||||
|
int err;
|
||||||
|
|
||||||
if (ddata == NULL || cpp_demangle_read_number(ddata, &len) == 0 ||
|
if (ddata == NULL || cpp_demangle_read_number(ddata, &len) == 0 ||
|
||||||
len <= 0 || cpp_demangle_push_str(ddata, ddata->cur, len) == 0)
|
len <= 0)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
if (len == 12 && (memcmp("_GLOBAL__N_1", ddata->cur, 12) == 0))
|
||||||
|
err = cpp_demangle_push_str(ddata, "(anonymous namespace)", 21);
|
||||||
|
else
|
||||||
|
err = cpp_demangle_push_str(ddata, ddata->cur, len);
|
||||||
|
|
||||||
|
if (err == 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
assert(ddata->output.size > 0);
|
assert(ddata->output.size > 0);
|
||||||
|
@ -2054,7 +2066,7 @@ clean:
|
||||||
free(subst_str);
|
free(subst_str);
|
||||||
vector_str_dest(&v);
|
vector_str_dest(&v);
|
||||||
|
|
||||||
return (1);
|
return (rtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -2996,6 +3008,40 @@ cpp_demangle_read_uqname(struct cpp_demangle_data *ddata)
|
||||||
if (ELFTC_ISDIGIT(*ddata->cur) != 0)
|
if (ELFTC_ISDIGIT(*ddata->cur) != 0)
|
||||||
return (cpp_demangle_read_sname(ddata));
|
return (cpp_demangle_read_sname(ddata));
|
||||||
|
|
||||||
|
|
||||||
|
/* local source name */
|
||||||
|
if (*ddata->cur == 'L')
|
||||||
|
return (cpp_demangle_local_source_name(ddata));
|
||||||
|
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read local source name.
|
||||||
|
*
|
||||||
|
* References:
|
||||||
|
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31775
|
||||||
|
* http://gcc.gnu.org/viewcvs?view=rev&revision=124467
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
cpp_demangle_local_source_name(struct cpp_demangle_data *ddata)
|
||||||
|
{
|
||||||
|
/* L */
|
||||||
|
if (ddata == NULL || *ddata->cur != 'L')
|
||||||
|
return (0);
|
||||||
|
++ddata->cur;
|
||||||
|
|
||||||
|
/* source name */
|
||||||
|
if (!cpp_demangle_read_sname(ddata))
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
/* discriminator */
|
||||||
|
if (*ddata->cur == '_') {
|
||||||
|
++ddata->cur;
|
||||||
|
while (ELFTC_ISDIGIT(*ddata->cur) != 0)
|
||||||
|
++ddata->cur;
|
||||||
|
}
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,18 @@ extern "C" char* __cxa_demangle(const char* mangled_name,
|
||||||
if (NULL != demangled)
|
if (NULL != demangled)
|
||||||
{
|
{
|
||||||
size_t len = strlen(demangled);
|
size_t len = strlen(demangled);
|
||||||
buf = (char*)realloc(buf, len+1);
|
if (buf == NULL)
|
||||||
|
{
|
||||||
|
if (n)
|
||||||
|
{
|
||||||
|
*n = len;
|
||||||
|
}
|
||||||
|
return demangled;
|
||||||
|
}
|
||||||
|
if (*n < len+1)
|
||||||
|
{
|
||||||
|
buf = static_cast<char*>(realloc(buf, len+1));
|
||||||
|
}
|
||||||
if (0 != buf)
|
if (0 != buf)
|
||||||
{
|
{
|
||||||
memcpy(buf, demangled, len);
|
memcpy(buf, demangled, len);
|
||||||
|
|
|
@ -218,6 +218,6 @@ _Unwind_Reason_Code name(_Unwind_State state,\
|
||||||
break;\
|
break;\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
_Unwind_SetGR (context, 12, (unsigned long)exceptionObject);\
|
_Unwind_SetGR (context, 12, reinterpret_cast<unsigned long>(exceptionObject));\
|
||||||
|
|
||||||
#define CALL_PERSONALITY_FUNCTION(name) name(state,exceptionObject,context)
|
#define CALL_PERSONALITY_FUNCTION(name) name(state,exceptionObject,context)
|
||||||
|
|
|
@ -80,7 +80,7 @@ struct _Unwind_Exception
|
||||||
_Unwind_Exception_Cleanup_Fn exception_cleanup;
|
_Unwind_Exception_Cleanup_Fn exception_cleanup;
|
||||||
unsigned long private_1;
|
unsigned long private_1;
|
||||||
unsigned long private_2;
|
unsigned long private_2;
|
||||||
} __attribute__((__aligned__));
|
} ;
|
||||||
|
|
||||||
extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
|
extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
|
||||||
extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
|
extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
|
||||||
|
|
Loading…
Reference in New Issue