From 54b352d8036bd07fd18e3ad2d4c1444bd6cf2d18 Mon Sep 17 00:00:00 2001 From: yinchuang Date: Thu, 6 Jun 2024 18:09:25 +0800 Subject: [PATCH] [Sanitizer] Fix wrong format of tsan log Issue:I9VQP5 Signed-off-by: yinchuang --- .../lib/sanitizer_common/sanitizer_linux_libcdep.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp index f84cdf3cb887..54c2526fac82 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp @@ -1063,6 +1063,7 @@ static bool ShouldLogAfterPrintf() { } extern "C" SANITIZER_WEAK_ATTRIBUTE int musl_log(const char *fmt, ...); +extern "C" SANITIZER_WEAK_ATTRIBUTE int ohos_dfx_log(const char *s); void WriteOneLineToSyslog(const char *s) { if (&musl_log) { musl_log(s); @@ -1085,6 +1086,12 @@ void SetAbortMessage(const char *str) {} #endif // SANITIZER_ANDROID void LogMessageOnPrintf(const char *str) { +#if SANITIZER_OHOS + // We need to call it before "WriteToSyslog" because "WriteToSyslog" will remove "\n". + if (&ohos_dfx_log) { + ohos_dfx_log(str); + } +#endif if (common_flags()->log_to_syslog && ShouldLogAfterPrintf()) WriteToSyslog(str); } -- Gitee