Path: blob/main/contrib/llvm-project/compiler-rt/lib/rtsan/rtsan_assertions.h
213766 views
//===--- rtsan_assertions.h - Realtime Sanitizer ----------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// Part of the RealtimeSanitizer runtime library9//10//===----------------------------------------------------------------------===//1112#pragma once1314#include "rtsan/rtsan.h"15#include "rtsan/rtsan_context.h"16#include "rtsan/rtsan_diagnostics.h"17#include "rtsan/rtsan_stats.h"18#include "rtsan/rtsan_suppressions.h"1920#include "sanitizer_common/sanitizer_stacktrace.h"2122namespace __rtsan {2324template <typename OnViolationAction>25void ExpectNotRealtime(Context &context, const DiagnosticsInfo &info,26OnViolationAction &&OnViolation) {27CHECK(__rtsan_is_initialized());28if (context.InRealtimeContext() && !context.IsBypassed()) {29ScopedBypass sb{context};3031if (IsFunctionSuppressed(info.func_name)) {32IncrementSuppressedCount();33return;34}3536__sanitizer::BufferedStackTrace stack;3738// We use the unwind_on_fatal flag here because of precedent with other39// sanitizers, this action is not necessarily fatal if halt_on_error=false40stack.Unwind(info.pc, info.bp, nullptr,41__sanitizer::common_flags()->fast_unwind_on_fatal);4243if (IsStackTraceSuppressed(stack)) {44IncrementSuppressedCount();45return;46}4748OnViolation(stack, info);49}50}5152} // namespace __rtsan535455