* Demangles a symbol name. * * @param sym The symbol name. * @returns A human-readable version of the symbol name. */
| 76 | * @returns A human-readable version of the symbol name. |
| 77 | */ |
| 78 | String Utility::DemangleSymbolName(const String& sym) |
| 79 | { |
| 80 | String result = sym; |
| 81 | |
| 82 | #ifdef HAVE_CXXABI_H |
| 83 | int status; |
| 84 | char *realname = abi::__cxa_demangle(sym.CStr(), nullptr, nullptr, &status); |
| 85 | |
| 86 | if (realname) { |
| 87 | result = String(realname); |
| 88 | free(realname); |
| 89 | } |
| 90 | #elif defined(_MSC_VER) /* HAVE_CXXABI_H */ |
| 91 | CHAR output[256]; |
| 92 | |
| 93 | if (UnDecorateSymbolName(sym.CStr(), output, sizeof(output), UNDNAME_COMPLETE) > 0) |
| 94 | result = output; |
| 95 | #else /* _MSC_VER */ |
| 96 | /* We're pretty much out of options here. */ |
| 97 | #endif /* _MSC_VER */ |
| 98 | |
| 99 | return result; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Returns a human-readable type name of a type_info object. |