brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 277182a Raw
59 lines · cpp
1//===--- rtsan_stats.cpp - 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#include "rtsan/rtsan_stats.h"14#include "rtsan/rtsan_flags.h"15 16#include "sanitizer_common/sanitizer_atomic.h"17#include "sanitizer_common/sanitizer_common.h"18 19using namespace __sanitizer;20using namespace __rtsan;21 22static atomic_uint32_t total_error_count{0};23static atomic_uint32_t unique_error_count{0};24static atomic_uint32_t suppressed_count{0};25 26void __rtsan::IncrementTotalErrorCount() {27  atomic_fetch_add(&total_error_count, 1, memory_order_relaxed);28}29 30void __rtsan::IncrementUniqueErrorCount() {31  atomic_fetch_add(&unique_error_count, 1, memory_order_relaxed);32}33 34static u32 GetTotalErrorCount() {35  return atomic_load(&total_error_count, memory_order_relaxed);36}37 38static u32 GetUniqueErrorCount() {39  return atomic_load(&unique_error_count, memory_order_relaxed);40}41 42void __rtsan::IncrementSuppressedCount() {43  atomic_fetch_add(&suppressed_count, 1, memory_order_relaxed);44}45 46static u32 GetSuppressedCount() {47  return atomic_load(&suppressed_count, memory_order_relaxed);48}49 50void __rtsan::PrintStatisticsSummary() {51  ScopedErrorReportLock l;52  Printf("RealtimeSanitizer exit stats:\n");53  Printf("    Total error count: %u\n", GetTotalErrorCount());54  Printf("    Unique error count: %u\n", GetUniqueErrorCount());55 56  if (flags().ContainsSuppresionFile())57    Printf("    Suppression count: %u\n", GetSuppressedCount());58}59