[compiler-rt] [rtsan][compiler-rt] Introduce __rtsan_notify_blocking_call (PR #109529)

via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 21 08:51:00 PDT 2024


================
@@ -46,18 +46,50 @@ static void PrintStackTrace(uptr pc, uptr bp) {
   stack.Print();
 }
 
-void __rtsan::PrintDiagnostics(const char *intercepted_function_name, uptr pc,
-                               uptr bp) {
+template <class... Ts> struct Overloaded : Ts... {
+  using Ts::operator()...;
+};
+// TODO: Remove below when c++20
+template <class... Ts> Overloaded(Ts...) -> Overloaded<Ts...>;
+
+void PrintError(Decorator &decorator, const DiagnosticsCallerInfo &info) {
+  const char *violation_type = std::visit(
+      Overloaded{
+          [](const InterceptedCallInfo &) { return "unsafe-library-call"; },
+          [](const BlockingCallInfo &) { return "blocking-call"; }},
+      info);
+
+  Printf("%s", decorator.Error());
+  Report("ERROR: RealtimeSanitizer: %s\n", violation_type);
+}
+
+void PrintReason(Decorator &decorator, const DiagnosticsCallerInfo &info) {
----------------
davidtrevelyan wrote:

Should be `static`

https://github.com/llvm/llvm-project/pull/109529


More information about the llvm-commits mailing list