Skip to content

Commit 07045b5

Browse files
authored
[compiler-rt][rtsan] Create colorized reports (#109419)
1 parent 2672947 commit 07045b5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

compiler-rt/lib/rtsan/rtsan_context.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <rtsan/rtsan_stack.h>
1515

1616
#include <sanitizer_common/sanitizer_allocator_internal.h>
17+
#include <sanitizer_common/sanitizer_report_decorator.h>
1718
#include <sanitizer_common/sanitizer_stacktrace.h>
1819

1920
#include <new>
@@ -91,15 +92,28 @@ bool __rtsan::Context::InRealtimeContext() const { return realtime_depth_ > 0; }
9192

9293
bool __rtsan::Context::IsBypassed() const { return bypass_depth_ > 0; }
9394

95+
namespace {
96+
class Decorator : public __sanitizer::SanitizerCommonDecorator {
97+
public:
98+
Decorator() : SanitizerCommonDecorator() {}
99+
const char *FunctionName() { return Green(); }
100+
const char *Reason() { return Blue(); }
101+
};
102+
} // namespace
103+
94104
void __rtsan::PrintDiagnostics(const char *intercepted_function_name, uptr pc,
95105
uptr bp) {
96106
ScopedErrorReportLock l;
97107

108+
Decorator d;
109+
Printf("%s", d.Error());
98110
Report("ERROR: RealtimeSanitizer: unsafe-library-call\n");
111+
Printf("%s", d.Reason());
99112
Printf("Intercepted call to real-time unsafe function "
100-
"`%s` in real-time context!\n",
101-
intercepted_function_name);
113+
"`%s%s%s` in real-time context!\n",
114+
d.FunctionName(), intercepted_function_name, d.Reason());
102115

116+
Printf("%s", d.Default());
103117
__rtsan::PrintStackTrace(pc, bp);
104118
}
105119

0 commit comments

Comments
 (0)