Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / libsanitizer / asan / asan_stats.h
1 //===-- asan_stats.h --------------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // ASan-private header for statistics.
11 //===----------------------------------------------------------------------===//
12 #ifndef ASAN_STATS_H
13 #define ASAN_STATS_H
14
15 #include "asan_allocator.h"
16 #include "asan_internal.h"
17
18 namespace __asan {
19
20 // AsanStats struct is NOT thread-safe.
21 // Each AsanThread has its own AsanStats, which are sometimes flushed
22 // to the accumulated AsanStats.
23 struct 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.
26   uptr mallocs;
27   uptr malloced;
28   uptr malloced_redzones;
29   uptr frees;
30   uptr freed;
31   uptr real_frees;
32   uptr really_freed;
33   uptr really_freed_redzones;
34   uptr reallocs;
35   uptr realloced;
36   uptr mmaps;
37   uptr mmaped;
38   uptr munmaps;
39   uptr munmaped;
40   uptr mmaped_by_size[kNumberOfSizeClasses];
41   uptr malloced_by_size[kNumberOfSizeClasses];
42   uptr freed_by_size[kNumberOfSizeClasses];
43   uptr really_freed_by_size[kNumberOfSizeClasses];
44
45   uptr malloc_large;
46   uptr malloc_small_slow;
47
48   // Ctor for global AsanStats (accumulated stats and main thread stats).
49   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 // A cross-platform equivalent of malloc_statistics_t on Mac OS.
58 struct AsanMallocStats {
59   uptr blocks_in_use;
60   uptr size_in_use;
61   uptr max_size_in_use;
62   uptr size_allocated;
63 };
64
65 }  // namespace __asan
66
67 #endif  // ASAN_STATS_H