Path: blob/main/contrib/llvm-project/compiler-rt/lib/rtsan/rtsan_stats.cpp
213766 views
//===--- rtsan_stats.cpp - 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#include "rtsan/rtsan_stats.h"13#include "rtsan/rtsan_flags.h"1415#include "sanitizer_common/sanitizer_atomic.h"16#include "sanitizer_common/sanitizer_common.h"1718using namespace __sanitizer;19using namespace __rtsan;2021static atomic_uint32_t total_error_count{0};22static atomic_uint32_t unique_error_count{0};23static atomic_uint32_t suppressed_count{0};2425void __rtsan::IncrementTotalErrorCount() {26atomic_fetch_add(&total_error_count, 1, memory_order_relaxed);27}2829void __rtsan::IncrementUniqueErrorCount() {30atomic_fetch_add(&unique_error_count, 1, memory_order_relaxed);31}3233static u32 GetTotalErrorCount() {34return atomic_load(&total_error_count, memory_order_relaxed);35}3637static u32 GetUniqueErrorCount() {38return atomic_load(&unique_error_count, memory_order_relaxed);39}4041void __rtsan::IncrementSuppressedCount() {42atomic_fetch_add(&suppressed_count, 1, memory_order_relaxed);43}4445static u32 GetSuppressedCount() {46return atomic_load(&suppressed_count, memory_order_relaxed);47}4849void __rtsan::PrintStatisticsSummary() {50ScopedErrorReportLock l;51Printf("RealtimeSanitizer exit stats:\n");52Printf(" Total error count: %u\n", GetTotalErrorCount());53Printf(" Unique error count: %u\n", GetUniqueErrorCount());5455if (flags().ContainsSuppresionFile())56Printf(" Suppression count: %u\n", GetSuppressedCount());57}585960