diff options
Diffstat (limited to 'compiler-rt/lib')
| -rw-r--r-- | compiler-rt/lib/xray/xray_fdr_logging.cc | 19 | ||||
| -rw-r--r-- | compiler-rt/lib/xray/xray_fdr_logging.h | 8 | ||||
| -rw-r--r-- | compiler-rt/lib/xray/xray_log_interface.cc | 5 | ||||
| -rw-r--r-- | compiler-rt/lib/xray/xray_utils.cc | 5 |
4 files changed, 13 insertions, 24 deletions
diff --git a/compiler-rt/lib/xray/xray_fdr_logging.cc b/compiler-rt/lib/xray/xray_fdr_logging.cc index df95c1d66e7..a86cf0b1410 100644 --- a/compiler-rt/lib/xray/xray_fdr_logging.cc +++ b/compiler-rt/lib/xray/xray_fdr_logging.cc @@ -51,19 +51,18 @@ std::unique_ptr<FDRLoggingOptions> FDROptions; XRayLogInitStatus fdrLoggingInit(std::size_t BufferSize, std::size_t BufferMax, void *Options, size_t OptionsSize) XRAY_NEVER_INSTRUMENT { - assert(OptionsSize == sizeof(FDRLoggingOptions)); + if (OptionsSize != sizeof(FDRLoggingOptions)) + return static_cast<XRayLogInitStatus>(__sanitizer::atomic_load( + &LoggingStatus, __sanitizer::memory_order_acquire)); s32 CurrentStatus = XRayLogInitStatus::XRAY_LOG_UNINITIALIZED; - if (__sanitizer::atomic_compare_exchange_strong( + if (!__sanitizer::atomic_compare_exchange_strong( &LoggingStatus, &CurrentStatus, XRayLogInitStatus::XRAY_LOG_INITIALIZING, __sanitizer::memory_order_release)) return static_cast<XRayLogInitStatus>(CurrentStatus); FDROptions.reset(new FDRLoggingOptions()); - *FDROptions = *reinterpret_cast<FDRLoggingOptions *>(Options); - if (FDROptions->ReportErrors) - SetPrintfAndReportCallback(printToStdErr); - + memcpy(FDROptions.get(), Options, OptionsSize); bool Success = false; BQ = std::make_shared<BufferQueue>(BufferSize, BufferMax, Success); if (!Success) { @@ -77,6 +76,7 @@ XRayLogInitStatus fdrLoggingInit(std::size_t BufferSize, std::size_t BufferMax, __sanitizer::atomic_store(&LoggingStatus, XRayLogInitStatus::XRAY_LOG_INITIALIZED, __sanitizer::memory_order_release); + Report("XRay FDR init successful.\n"); return XRayLogInitStatus::XRAY_LOG_INITIALIZED; } @@ -88,7 +88,7 @@ XRayLogFlushStatus fdrLoggingFlush() XRAY_NEVER_INSTRUMENT { return XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING; s32 Result = XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING; - if (__sanitizer::atomic_compare_exchange_strong( + if (!__sanitizer::atomic_compare_exchange_strong( &LogFlushStatus, &Result, XRayLogFlushStatus::XRAY_LOG_FLUSHING, __sanitizer::memory_order_release)) return static_cast<XRayLogFlushStatus>(Result); @@ -140,7 +140,7 @@ XRayLogFlushStatus fdrLoggingFlush() XRAY_NEVER_INSTRUMENT { XRayLogInitStatus fdrLoggingFinalize() XRAY_NEVER_INSTRUMENT { s32 CurrentStatus = XRayLogInitStatus::XRAY_LOG_INITIALIZED; - if (__sanitizer::atomic_compare_exchange_strong( + if (!__sanitizer::atomic_compare_exchange_strong( &LoggingStatus, &CurrentStatus, XRayLogInitStatus::XRAY_LOG_FINALIZING, __sanitizer::memory_order_release)) @@ -168,8 +168,7 @@ XRayLogInitStatus fdrLoggingReset() XRAY_NEVER_INSTRUMENT { BQ.reset(); // Spin until the flushing status is flushed. - s32 CurrentFlushingStatus = - XRayLogFlushStatus::XRAY_LOG_FLUSHED; + s32 CurrentFlushingStatus = XRayLogFlushStatus::XRAY_LOG_FLUSHED; while (__sanitizer::atomic_compare_exchange_weak( &LogFlushStatus, &CurrentFlushingStatus, XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING, diff --git a/compiler-rt/lib/xray/xray_fdr_logging.h b/compiler-rt/lib/xray/xray_fdr_logging.h index 93c33b417ba..426b54dc788 100644 --- a/compiler-rt/lib/xray/xray_fdr_logging.h +++ b/compiler-rt/lib/xray/xray_fdr_logging.h @@ -26,14 +26,6 @@ // default mode of always writing fixed-size records. namespace __xray { - -// Options used by the FDR implementation. -struct FDRLoggingOptions { - bool ReportErrors = false; - int Fd = -1; -}; - -// Flight Data Recorder mode implementation interfaces. XRayLogInitStatus fdrLoggingInit(size_t BufferSize, size_t BufferMax, void *Options, size_t OptionsSize); XRayLogInitStatus fdrLoggingFinalize(); diff --git a/compiler-rt/lib/xray/xray_log_interface.cc b/compiler-rt/lib/xray/xray_log_interface.cc index 8fb6e39192e..ffed601c05c 100644 --- a/compiler-rt/lib/xray/xray_log_interface.cc +++ b/compiler-rt/lib/xray/xray_log_interface.cc @@ -35,8 +35,9 @@ void __xray_set_log_impl(XRayLogImpl Impl) XRAY_NEVER_INSTRUMENT { *GlobalXRayImpl = Impl; } -XRayLogInitStatus __xray_init(size_t BufferSize, size_t MaxBuffers, void *Args, - size_t ArgsSize) XRAY_NEVER_INSTRUMENT { +XRayLogInitStatus __xray_log_init(size_t BufferSize, size_t MaxBuffers, + void *Args, + size_t ArgsSize) XRAY_NEVER_INSTRUMENT { __sanitizer::SpinMutexLock Guard(&XRayImplMutex); if (!GlobalXRayImpl) return XRayLogInitStatus::XRAY_LOG_UNINITIALIZED; diff --git a/compiler-rt/lib/xray/xray_utils.cc b/compiler-rt/lib/xray/xray_utils.cc index 5d6390c802a..b9a38d1b98e 100644 --- a/compiler-rt/lib/xray/xray_utils.cc +++ b/compiler-rt/lib/xray/xray_utils.cc @@ -93,8 +93,6 @@ bool readValueFromFile(const char *Filename, } int getLogFD() XRAY_NEVER_INSTRUMENT { - // FIXME: Figure out how to make this less stderr-dependent. - SetPrintfAndReportCallback(printToStdErr); // Open a temporary file once for the log. static char TmpFilename[256] = {}; static char TmpWildcardPattern[] = "XXXXXX"; @@ -119,8 +117,7 @@ int getLogFD() XRAY_NEVER_INSTRUMENT { TmpFilename); return -1; } - if (Verbosity()) - fprintf(stderr, "XRay: Log file in '%s'\n", TmpFilename); + Report("XRay: Log file in '%s'\n", TmpFilename); return Fd; } |

