• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- asan_stats.h --------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of AddressSanitizer, an address sanity checker.
11 //
12 // ASan-private header for statistics.
13 //===----------------------------------------------------------------------===//
14 #ifndef ASAN_STATS_H
15 #define ASAN_STATS_H
16 
17 #include "asan_allocator.h"
18 #include "asan_internal.h"
19 
20 namespace __asan {
21 
22 // AsanStats struct is NOT thread-safe.
23 // Each AsanThread has its own AsanStats, which are sometimes flushed
24 // to the accumulated AsanStats.
25 struct AsanStats {
26   // AsanStats must be a struct consisting of size_t fields only.
27   // When merging two AsanStats structs, we treat them as arrays of size_t.
28   size_t mallocs;
29   size_t malloced;
30   size_t malloced_redzones;
31   size_t frees;
32   size_t freed;
33   size_t real_frees;
34   size_t really_freed;
35   size_t really_freed_redzones;
36   size_t reallocs;
37   size_t realloced;
38   size_t mmaps;
39   size_t mmaped;
40   size_t mmaped_by_size[kNumberOfSizeClasses];
41   size_t malloced_by_size[kNumberOfSizeClasses];
42   size_t freed_by_size[kNumberOfSizeClasses];
43   size_t really_freed_by_size[kNumberOfSizeClasses];
44 
45   size_t malloc_large;
46   size_t malloc_small_slow;
47 
48   // Ctor for global AsanStats (accumulated stats and main thread stats).
AsanStatsAsanStats49   explicit AsanStats(LinkerInitialized) { }
50   // Default ctor for thread-local stats.
51   AsanStats();
52 
53   // Prints formatted stats to stderr.
54   void Print();
55 };
56 
57 }  // namespace __asan
58 
59 #endif  // ASAN_STATS_H
60