1 //===-- asan_stats.h --------------------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of AddressSanitizer, an address sanity checker.
10 // ASan-private header for statistics.
11 //===----------------------------------------------------------------------===//
15 #include "asan_allocator.h"
16 #include "asan_internal.h"
20 // AsanStats struct is NOT thread-safe.
21 // Each AsanThread has its own AsanStats, which are sometimes flushed
22 // to the accumulated AsanStats.
24 // AsanStats must be a struct consisting of uptr fields only.
25 // When merging two AsanStats structs, we treat them as arrays of uptr.
28 uptr malloced_redzones
;
40 uptr malloced_by_size
[kNumberOfSizeClasses
];
42 // Ctor for global AsanStats (accumulated stats for dead threads).
43 explicit AsanStats(LinkerInitialized
) { }
44 // Creates empty stats.
47 void Print(); // Prints formatted stats to stderr.
49 void MergeFrom(const AsanStats
*stats
);
52 // Returns stats for GetCurrentThread(), or stats for fake "unknown thread"
53 // if GetCurrentThread() returns 0.
54 AsanStats
&GetCurrentThreadStats();
55 // Flushes a given stats into accumulated stats of dead threads.
56 void FlushToDeadThreadStats(AsanStats
*stats
);
58 // A cross-platform equivalent of malloc_statistics_t on Mac OS.
59 struct AsanMallocStats
{
66 void FillMallocStatistics(AsanMallocStats
*malloc_stats
);
70 #endif // ASAN_STATS_H