From 215a742b8804f33c84f866d3c5aacd8d35129c49 Mon Sep 17 00:00:00 2001 From: Marco Elver Date: Thu, 25 May 2023 11:10:48 +0200 Subject: [PATCH] [sanitizer_common] Check 'demangle' flag in StripFunctionName and DemangleFunctionName To allow getting the original stack trace. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D151411 --- .../lib/sanitizer_common/sanitizer_stacktrace_printer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp index 337e2d6..2285ad8 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp @@ -11,12 +11,16 @@ //===----------------------------------------------------------------------===// #include "sanitizer_stacktrace_printer.h" + #include "sanitizer_file.h" +#include "sanitizer_flags.h" #include "sanitizer_fuchsia.h" namespace __sanitizer { const char *StripFunctionName(const char *function) { + if (!common_flags()->demangle) + return function; if (!function) return nullptr; auto try_strip = [function](const char *prefix) -> const char * { @@ -39,7 +43,10 @@ const char *StripFunctionName(const char *function) { #if !SANITIZER_SYMBOLIZER_MARKUP static const char *DemangleFunctionName(const char *function) { - if (!function) return nullptr; + if (!common_flags()->demangle) + return function; + if (!function) + return nullptr; // NetBSD uses indirection for old threading functions for historical reasons // The mangled names are internal implementation detail and should not be -- 2.7.4