Skip to content

Commit 4964d98

Browse files
authored
[compiler-rt] Replace deprecated os_trace calls on mac (#138908)
Currently there are deprecation warnings suppressed for `os_trace`; this patch replaces all uses with `os_log_error`. rdar://140295247
1 parent b99e575 commit 4964d98

File tree

1 file changed

+18
-33
lines changed

1 file changed

+18
-33
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@
3838
extern char **environ;
3939
# endif
4040

41-
# if defined(__has_include) && __has_include(<os/trace.h>)
42-
# define SANITIZER_OS_TRACE 1
43-
# include <os/trace.h>
44-
# else
45-
# define SANITIZER_OS_TRACE 0
46-
# endif
47-
4841
// Integrate with CrashReporter library if available
4942
# if defined(__has_include) && __has_include(<CrashReporterClient.h>)
5043
# define HAVE_CRASHREPORTERCLIENT_H 1
@@ -843,31 +836,23 @@ void LogMessageOnPrintf(const char *str) {
843836
}
844837

845838
void LogFullErrorReport(const char *buffer) {
846-
#if !SANITIZER_GO
847-
// Log with os_trace. This will make it into the crash log.
848-
#if SANITIZER_OS_TRACE
849-
#pragma clang diagnostic push
850-
// os_trace is deprecated.
851-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
852-
if (GetMacosAlignedVersion() >= MacosVersion(10, 10)) {
853-
// os_trace requires the message (format parameter) to be a string literal.
854-
if (internal_strncmp(SanitizerToolName, "AddressSanitizer",
855-
sizeof("AddressSanitizer") - 1) == 0)
856-
os_trace("Address Sanitizer reported a failure.");
857-
else if (internal_strncmp(SanitizerToolName, "UndefinedBehaviorSanitizer",
858-
sizeof("UndefinedBehaviorSanitizer") - 1) == 0)
859-
os_trace("Undefined Behavior Sanitizer reported a failure.");
860-
else if (internal_strncmp(SanitizerToolName, "ThreadSanitizer",
861-
sizeof("ThreadSanitizer") - 1) == 0)
862-
os_trace("Thread Sanitizer reported a failure.");
863-
else
864-
os_trace("Sanitizer tool reported a failure.");
865-
866-
if (common_flags()->log_to_syslog)
867-
os_trace("Consult syslog for more information.");
868-
}
869-
#pragma clang diagnostic pop
870-
#endif
839+
# if !SANITIZER_GO
840+
// Log with os_log_error. This will make it into the crash log.
841+
if (internal_strncmp(SanitizerToolName, "AddressSanitizer",
842+
sizeof("AddressSanitizer") - 1) == 0)
843+
os_log_error(OS_LOG_DEFAULT, "Address Sanitizer reported a failure.");
844+
else if (internal_strncmp(SanitizerToolName, "UndefinedBehaviorSanitizer",
845+
sizeof("UndefinedBehaviorSanitizer") - 1) == 0)
846+
os_log_error(OS_LOG_DEFAULT,
847+
"Undefined Behavior Sanitizer reported a failure.");
848+
else if (internal_strncmp(SanitizerToolName, "ThreadSanitizer",
849+
sizeof("ThreadSanitizer") - 1) == 0)
850+
os_log_error(OS_LOG_DEFAULT, "Thread Sanitizer reported a failure.");
851+
else
852+
os_log_error(OS_LOG_DEFAULT, "Sanitizer tool reported a failure.");
853+
854+
if (common_flags()->log_to_syslog)
855+
os_log_error(OS_LOG_DEFAULT, "Consult syslog for more information.");
871856

872857
// Log to syslog.
873858
// The logging on OS X may call pthread_create so we need the threading
@@ -881,7 +866,7 @@ void LogFullErrorReport(const char *buffer) {
881866
WriteToSyslog(buffer);
882867

883868
// The report is added to CrashLog as part of logging all of Printf output.
884-
#endif
869+
# endif // !SANITIZER_GO
885870
}
886871

887872
SignalContext::WriteFlag SignalContext::GetWriteFlag() const {

0 commit comments

Comments
 (0)