brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 28a272b Raw
54 lines · c
1//===--- rtsan_assertions.h - Realtime Sanitizer ----------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// Part of the RealtimeSanitizer runtime library10//11//===----------------------------------------------------------------------===//12 13#pragma once14 15#include "rtsan/rtsan.h"16#include "rtsan/rtsan_context.h"17#include "rtsan/rtsan_diagnostics.h"18#include "rtsan/rtsan_stats.h"19#include "rtsan/rtsan_suppressions.h"20 21#include "sanitizer_common/sanitizer_stacktrace.h"22 23namespace __rtsan {24 25template <typename OnViolationAction>26void ExpectNotRealtime(Context &context, const DiagnosticsInfo &info,27                       OnViolationAction &&OnViolation) {28  CHECK(__rtsan_is_initialized());29  if (context.InRealtimeContext() && !context.IsBypassed()) {30    ScopedBypass sb{context};31 32    if (IsFunctionSuppressed(info.func_name)) {33      IncrementSuppressedCount();34      return;35    }36 37    __sanitizer::BufferedStackTrace stack;38 39    // We use the unwind_on_fatal flag here because of precedent with other40    // sanitizers, this action is not necessarily fatal if halt_on_error=false41    stack.Unwind(info.pc, info.bp, nullptr,42                 __sanitizer::common_flags()->fast_unwind_on_fatal);43 44    if (IsStackTraceSuppressed(stack)) {45      IncrementSuppressedCount();46      return;47    }48 49    OnViolation(stack, info);50  }51}52 53} // namespace __rtsan54