[compiler-rt] [compiler-rt][rtsan] Create colorized reports (PR #109419)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 06:28:37 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Chris Apple (cjappl)
<details>
<summary>Changes</summary>
Mostly following asan here.
Our resulting color choices look like this on dark background
<img width="661" alt="Screenshot 2024-09-20 at 7 26 46 AM" src="https://github.com/user-attachments/assets/0765d2ff-e5a3-426a-b2d0-e3ef68b86b9c">
And this on white:
<img width="633" alt="Screenshot 2024-09-20 at 7 27 45 AM" src="https://github.com/user-attachments/assets/7d78f7f5-19a4-4c99-814d-e3412b8fa4f6">
---
Full diff: https://github.com/llvm/llvm-project/pull/109419.diff
1 Files Affected:
- (modified) compiler-rt/lib/rtsan/rtsan_context.cpp (+16-2)
``````````diff
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);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/109419
More information about the llvm-commits
mailing list