[compiler-rt] [compiler-rt][rtsan] Create colorized reports (PR #109419)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 08:01:22 PDT 2024
https://github.com/cjappl updated https://github.com/llvm/llvm-project/pull/109419
>From df2ddffa11faaec8f0829680ade6dbd74bc3af98 Mon Sep 17 00:00:00 2001
From: Chris Apple <cja-private at pm.me>
Date: Fri, 6 Sep 2024 09:14:53 -0700
Subject: [PATCH] [compiler-rt][rtsan] Create colorized reports
---
compiler-rt/lib/rtsan/rtsan_context.cpp | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/lib/rtsan/rtsan_context.cpp b/compiler-rt/lib/rtsan/rtsan_context.cpp
index e69fb259798d94..9cf15207e63840 100644
--- a/compiler-rt/lib/rtsan/rtsan_context.cpp
+++ b/compiler-rt/lib/rtsan/rtsan_context.cpp
@@ -14,6 +14,7 @@
#include <rtsan/rtsan_stack.h>
#include <sanitizer_common/sanitizer_allocator_internal.h>
+#include <sanitizer_common/sanitizer_report_decorator.h>
#include <sanitizer_common/sanitizer_stacktrace.h>
#include <new>
@@ -91,15 +92,28 @@ bool __rtsan::Context::InRealtimeContext() const { return realtime_depth_ > 0; }
bool __rtsan::Context::IsBypassed() const { return bypass_depth_ > 0; }
+namespace {
+class Decorator : public __sanitizer::SanitizerCommonDecorator {
+public:
+ Decorator() : SanitizerCommonDecorator() {}
+ const char *FunctionName() { return Green(); }
+ const char *Reason() { return Blue(); }
+};
+} // namespace
+
void __rtsan::PrintDiagnostics(const char *intercepted_function_name, uptr pc,
uptr bp) {
ScopedErrorReportLock l;
+ Decorator d;
+ Printf("%s", d.Error());
Report("ERROR: RealtimeSanitizer: unsafe-library-call\n");
+ Printf("%s", d.Reason());
Printf("Intercepted call to real-time unsafe function "
- "`%s` in real-time context!\n",
- intercepted_function_name);
+ "`%s%s%s` in real-time context!\n",
+ d.FunctionName(), intercepted_function_name, d.Reason());
+ Printf("%s", d.Default());
__rtsan::PrintStackTrace(pc, bp);
}
More information about the llvm-commits
mailing list