| 3253 | |
| 3254 | #if defined(FASTGRIND_INSTRUMENT) |
| 3255 | MEM_NO_INSTRUMENT static const char *demangleFunc(const char *mangled) |
| 3256 | { |
| 3257 | if (!mangled) |
| 3258 | return mangled; |
| 3259 | |
| 3260 | struct protect |
| 3261 | { |
| 3262 | ~protect() |
| 3263 | { |
| 3264 | cache.clear(); |
| 3265 | } |
| 3266 | std::unordered_map<const char *, const char *> cache; |
| 3267 | std::mutex lk; |
| 3268 | }; |
| 3269 | |
| 3270 | static protect p; |
| 3271 | { |
| 3272 | std::lock_guard<std::mutex> g(p.lk); |
| 3273 | auto it = p.cache.find(mangled); |
| 3274 | if (it != p.cache.end()) |
| 3275 | return it->second; |
| 3276 | } |
| 3277 | |
| 3278 | int status = 0; |
| 3279 | char *tmp = abi::__cxa_demangle(mangled, nullptr, nullptr, &status); |
| 3280 | const char *ret = nullptr; |
| 3281 | |
| 3282 | if (status == 0 && tmp) |
| 3283 | { |
| 3284 | ret = strdup(tmp); |
| 3285 | free(tmp); |
| 3286 | } |
| 3287 | else |
| 3288 | { |
| 3289 | ret = mangled; |
| 3290 | } |
| 3291 | |
| 3292 | { |
| 3293 | std::lock_guard<std::mutex> g(p.lk); |
| 3294 | p.cache[mangled] = ret; |
| 3295 | } |
| 3296 | return ret; |
| 3297 | } |
| 3298 | |
| 3299 | MEM_NO_INSTRUMENT static const char *tryAddr2lineResolve(void *addr) |
| 3300 | { |
no outgoing calls
no test coverage detected