typeinfo.cc revision 227983
1#include "typeinfo.h" 2#include <string.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6using std::type_info; 7 8type_info::~type_info() {} 9 10bool type_info::operator==(const type_info &other) const 11{ 12 return __type_name == other.__type_name; 13} 14bool type_info::operator!=(const type_info &other) const 15{ 16 return __type_name != other.__type_name; 17} 18bool type_info::before(const type_info &other) const 19{ 20 return __type_name < other.__type_name; 21} 22const char* type_info::name() const 23{ 24 return __type_name; 25} 26type_info::type_info (const type_info& rhs) 27{ 28 __type_name = rhs.__type_name; 29} 30type_info& type_info::operator= (const type_info& rhs) 31{ 32 return *new type_info(rhs); 33} 34 35ABI_NAMESPACE::__fundamental_type_info::~__fundamental_type_info() {} 36ABI_NAMESPACE::__array_type_info::~__array_type_info() {} 37ABI_NAMESPACE::__function_type_info::~__function_type_info() {} 38ABI_NAMESPACE::__enum_type_info::~__enum_type_info() {} 39ABI_NAMESPACE::__class_type_info::~__class_type_info() {} 40ABI_NAMESPACE::__si_class_type_info::~__si_class_type_info() {} 41ABI_NAMESPACE::__vmi_class_type_info::~__vmi_class_type_info() {} 42ABI_NAMESPACE::__pbase_type_info::~__pbase_type_info() {} 43ABI_NAMESPACE::__pointer_type_info::~__pointer_type_info() {} 44ABI_NAMESPACE::__pointer_to_member_type_info::~__pointer_to_member_type_info() {} 45 46// From libelftc 47extern "C" char *__cxa_demangle_gnu3(const char *); 48 49extern "C" char* __cxa_demangle(const char* mangled_name, 50 char* buf, 51 size_t* n, 52 int* status) 53{ 54 // TODO: We should probably just be linking against libelf-tc, rather than 55 // copying their code. This requires them to do an actual release, 56 // however, and for our changes to be pushed upstream. We also need to 57 // call a different demangling function here depending on the ABI (e.g. 58 // ARM). 59 char *demangled = __cxa_demangle_gnu3(mangled_name); 60 if (NULL != demangled) 61 { 62 size_t len = strlen(demangled); 63 buf = (char*)realloc(buf, len+1); 64 if (0 != buf) 65 { 66 memcpy(buf, demangled, len); 67 buf[len] = 0; 68 *n = len; 69 *status = 0; 70 } 71 else 72 { 73 *status = -1; 74 } 75 free(demangled); 76 } 77 else 78 { 79 *status = -2; 80 return NULL; 81 } 82 return buf; 83} 84