[compiler-rt] [TySan] Added a 'print_stacktrace' flag for more detailed errors (PR #121756)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 6 03:46:45 PST 2025


https://github.com/gbMattN created https://github.com/llvm/llvm-project/pull/121756

Raised in issue #121697

>From f55dd6c9c5b191a5a55f23cd036247abbf491afc Mon Sep 17 00:00:00 2001
From: gbMattN <matthew.nagy at sony.com>
Date: Mon, 6 Jan 2025 11:45:48 +0000
Subject: [PATCH] [TySan] Added a 'print_stacktrace' flag for more detailed
 errors

---
 compiler-rt/lib/tysan/tysan.cpp       | 2 +-
 compiler-rt/lib/tysan/tysan_flags.inc | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/tysan/tysan.cpp b/compiler-rt/lib/tysan/tysan.cpp
index 39d78e7c95e0cd..2786d826afb5f4 100644
--- a/compiler-rt/lib/tysan/tysan.cpp
+++ b/compiler-rt/lib/tysan/tysan.cpp
@@ -198,7 +198,7 @@ static void reportError(void *Addr, int Size, tysan_type_descriptor *TD,
 
   if (pc) {
 
-    bool request_fast = StackTrace::WillUseFastUnwind(true);
+    bool request_fast = StackTrace::WillUseFastUnwind(true) && !flags().print_stacktrace;
     BufferedStackTrace ST;
     ST.Unwind(kStackTraceMax, pc, bp, 0, 0, 0, request_fast);
     ST.Print();
diff --git a/compiler-rt/lib/tysan/tysan_flags.inc b/compiler-rt/lib/tysan/tysan_flags.inc
index 98b6591f844ef0..be65c8e828794a 100644
--- a/compiler-rt/lib/tysan/tysan_flags.inc
+++ b/compiler-rt/lib/tysan/tysan_flags.inc
@@ -15,3 +15,6 @@
 
 // TYSAN_FLAG(Type, Name, DefaultValue, Description)
 // See COMMON_FLAG in sanitizer_flags.inc for more details.
+
+TYSAN_FLAG(bool, print_stacktrace, false,
+           "Include full stacktrace into an error report")



More information about the llvm-commits mailing list