diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h --- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h @@ -27,7 +27,8 @@ // " frame 10: function foo::bar() at my/file.cc:10" // You may additionally pass "strip_path_prefix" to strip prefixes of paths to // source files and modules, and "strip_func_prefix" to strip prefixes of -// function names. +// function names (the pseudo-prefix "INTERCEPTOR" will strip all interceptor +// prefixes). // Here's the full list of available placeholders: // %% - represents a '%' character; // %n - frame number (copy of frame_no); @@ -49,7 +50,7 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no, uptr address, const AddressInfo *info, bool vs_style, const char *strip_path_prefix = "", - const char *strip_func_prefix = ""); + const char *strip_func_prefix = "INTERCEPTOR"); bool RenderNeedsSymbolization(const char *format); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp --- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp @@ -22,9 +22,22 @@ static const char *StripFunctionName(const char *function, const char *prefix) { if (!function) return nullptr; if (!prefix) return function; - uptr prefix_len = internal_strlen(prefix); - if (0 == internal_strncmp(function, prefix, prefix_len)) - return function + prefix_len; + auto try_strip = [function](const char *prefix) -> const char * { + const uptr prefix_len = internal_strlen(prefix); + if (!internal_strncmp(function, prefix, prefix_len)) + return function + prefix_len; + return nullptr; + }; + if (!internal_strcmp("INTERCEPTOR", prefix)) { + if (SANITIZER_APPLE) { + if (const char *s = try_strip("wrap_")) + return s; + } else { + if (const char *s = try_strip("__interceptor_")) + return s; + } + } else if (const char *s = try_strip(prefix)) + return s; return function; } diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_report.cpp --- a/compiler-rt/lib/tsan/rtl/tsan_report.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_report.cpp @@ -98,12 +98,6 @@ UNREACHABLE("missing case"); } -#if SANITIZER_APPLE -static const char *const kInterposedFunctionPrefix = "wrap_"; -#else -static const char *const kInterposedFunctionPrefix = "__interceptor_"; -#endif - void PrintStack(const ReportStack *ent) { if (ent == 0 || ent->frames == 0) { Printf(" [failed to restore the stack]\n\n"); @@ -115,7 +109,7 @@ RenderFrame(&res, common_flags()->stack_trace_format, i, frame->info.address, &frame->info, common_flags()->symbolize_vs_style, - common_flags()->strip_path_prefix, kInterposedFunctionPrefix); + common_flags()->strip_path_prefix); Printf("%s\n", res.data()); } Printf("\n");