| 48 | } |
| 49 | |
| 50 | std::string decipher_trace(const std::string& trace) |
| 51 | { |
| 52 | std::string result; |
| 53 | |
| 54 | if (trace.empty()) |
| 55 | { |
| 56 | result += "??\n"; |
| 57 | return result; |
| 58 | } |
| 59 | |
| 60 | auto* begin = strchr(trace.c_str(), '(') + 1; |
| 61 | auto* end = strchr(begin, '+'); |
| 62 | |
| 63 | if (!end) |
| 64 | end = strchr(begin, ')'); |
| 65 | |
| 66 | std::string mangled_name(begin, end); |
| 67 | |
| 68 | int status; |
| 69 | char* realname = abi::__cxa_demangle(mangled_name.c_str(), 0, 0, &status); |
| 70 | result.insert(result.end(), trace.c_str(), begin); |
| 71 | |
| 72 | if (realname) |
| 73 | result += realname; |
| 74 | else |
| 75 | result.insert(result.end(), begin, end); |
| 76 | |
| 77 | free(realname); |
| 78 | result.insert(result.size(), end); |
| 79 | |
| 80 | return result; |
| 81 | } |
| 82 | |
| 83 | void print_trace() |
| 84 | { |