Skip to content

Commit 8d7ea62

Browse files
committed
[compiler-rt][sanitizer-common] Use os_log for DriverKit as os_log_error is undefined
1 parent bd4e7f5 commit 8d7ea62

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -837,22 +837,29 @@ void LogMessageOnPrintf(const char *str) {
837837

838838
void LogFullErrorReport(const char *buffer) {
839839
# if !SANITIZER_GO
840-
// Log with os_log_error. This will make it into the crash log.
840+
# if SANITIZER_DRIVERKIT
841+
# define SANITIZER_OS_LOG os_log
842+
# else
843+
# define SANITIZER_OS_LOG os_log_error
844+
# endif
845+
846+
// Log with os_log.*. This will make it into the crash log.
841847
if (internal_strncmp(SanitizerToolName, "AddressSanitizer",
842848
sizeof("AddressSanitizer") - 1) == 0)
843-
os_log_error(OS_LOG_DEFAULT, "Address Sanitizer reported a failure.");
849+
SANITIZER_OS_LOG(OS_LOG_DEFAULT, "Address Sanitizer reported a failure.");
844850
else if (internal_strncmp(SanitizerToolName, "UndefinedBehaviorSanitizer",
845851
sizeof("UndefinedBehaviorSanitizer") - 1) == 0)
846-
os_log_error(OS_LOG_DEFAULT,
852+
SANITIZER_OS_LOG(OS_LOG_DEFAULT,
847853
"Undefined Behavior Sanitizer reported a failure.");
848854
else if (internal_strncmp(SanitizerToolName, "ThreadSanitizer",
849855
sizeof("ThreadSanitizer") - 1) == 0)
850-
os_log_error(OS_LOG_DEFAULT, "Thread Sanitizer reported a failure.");
856+
SANITIZER_OS_LOG(OS_LOG_DEFAULT, "Thread Sanitizer reported a failure.");
851857
else
852-
os_log_error(OS_LOG_DEFAULT, "Sanitizer tool reported a failure.");
858+
SANITIZER_OS_LOG(OS_LOG_DEFAULT, "Sanitizer tool reported a failure.");
853859

854860
if (common_flags()->log_to_syslog)
855-
os_log_error(OS_LOG_DEFAULT, "Consult syslog for more information.");
861+
SANITIZER_OS_LOG(OS_LOG_DEFAULT, "Consult syslog for more information.");
862+
# undef SANITIZER_OS_LOG
856863

857864
// Log to syslog.
858865
// The logging on OS X may call pthread_create so we need the threading

0 commit comments

Comments
 (0)