[compiler-rt] 039567b - [Darwin] Switch to new logging api for sanitizers
Dan Liew via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 4 21:05:11 PST 2021
Author: Emily Shi
Date: 2021-02-04T21:04:51-08:00
New Revision: 039567b664b4e5fad2c6fac1d6f9a6345a15f2d8
URL: https://github.com/llvm/llvm-project/commit/039567b664b4e5fad2c6fac1d6f9a6345a15f2d8
DIFF: https://github.com/llvm/llvm-project/commit/039567b664b4e5fad2c6fac1d6f9a6345a15f2d8.diff
LOG: [Darwin] Switch to new logging api for sanitizers
Switch to new logging api added in [[ https://developer.apple.com/documentation/os/os_log_error | macOS 10.12 ]] that is more memory safe and enables us to label the log messages in the future. Falls back to old API if ran on older OS versions.
Commited by Dan Liew on behalf of Emily Shi.
rdar://25181524
Reviewed By: delcypher, yln
Differential Revision: https://reviews.llvm.org/D95977
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index 2b53d7d730d7..643755af818c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -62,6 +62,7 @@ extern "C" {
#include <mach/mach_time.h>
#include <mach/vm_statistics.h>
#include <malloc/malloc.h>
+#include <os/log.h>
#include <pthread.h>
#include <sched.h>
#include <signal.h>
@@ -770,7 +771,11 @@ static BlockingMutex syslog_lock(LINKER_INITIALIZED);
void WriteOneLineToSyslog(const char *s) {
#if !SANITIZER_GO
syslog_lock.CheckLocked();
- asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", s);
+ if (GetMacosAlignedVersion() >= MacosVersion(10, 12)) {
+ os_log_error(OS_LOG_DEFAULT, "%{public}s", s);
+ } else {
+ asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", s);
+ }
#endif
}
More information about the llvm-commits
mailing list