1 //===-- asan_stats.h --------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of AddressSanitizer, an address sanity checker.
12 // ASan-private header for statistics.
13 //===----------------------------------------------------------------------===//
17 #include "asan_allocator.h"
18 #include "asan_internal.h"
22 // AsanStats struct is NOT thread-safe.
23 // Each AsanThread has its own AsanStats, which are sometimes flushed
24 // to the accumulated AsanStats.
26 // AsanStats must be a struct consisting of uptr fields only.
27 // When merging two AsanStats structs, we treat them as arrays of uptr.
30 uptr malloced_redzones;
42 uptr malloced_by_size[kNumberOfSizeClasses];
44 // Ctor for global AsanStats (accumulated stats for dead threads).
45 explicit AsanStats(LinkerInitialized) { }
46 // Creates empty stats.
49 void Print(); // Prints formatted stats to stderr.
51 void MergeFrom(const AsanStats *stats);
54 // Returns stats for GetCurrentThread(), or stats for fake "unknown thread"
55 // if GetCurrentThread() returns 0.
56 AsanStats &GetCurrentThreadStats();
57 // Flushes a given stats into accumulated stats of dead threads.
58 void FlushToDeadThreadStats(AsanStats *stats);
60 // A cross-platform equivalent of malloc_statistics_t on Mac OS.
61 struct AsanMallocStats {
68 void FillMallocStatistics(AsanMallocStats *malloc_stats);
72 #endif // ASAN_STATS_H