]> git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/lib/asan/asan_stats.h
New upstream version 1.20.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / lib / asan / asan_stats.h
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 uptr fields only.
27 // When merging two AsanStats structs, we treat them as arrays of uptr.
28 uptr mallocs;
29 uptr malloced;
30 uptr malloced_redzones;
31 uptr frees;
32 uptr freed;
33 uptr real_frees;
34 uptr really_freed;
35 uptr reallocs;
36 uptr realloced;
37 uptr mmaps;
38 uptr mmaped;
39 uptr munmaps;
40 uptr munmaped;
41 uptr malloc_large;
42 uptr malloced_by_size[kNumberOfSizeClasses];
43
44 // Ctor for global AsanStats (accumulated stats for dead threads).
45 explicit AsanStats(LinkerInitialized) { }
46 // Creates empty stats.
47 AsanStats();
48
49 void Print(); // Prints formatted stats to stderr.
50 void Clear();
51 void MergeFrom(const AsanStats *stats);
52 };
53
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);
59
60 // A cross-platform equivalent of malloc_statistics_t on Mac OS.
61 struct AsanMallocStats {
62 uptr blocks_in_use;
63 uptr size_in_use;
64 uptr max_size_in_use;
65 uptr size_allocated;
66 };
67
68 void FillMallocStatistics(AsanMallocStats *malloc_stats);
69
70 } // namespace __asan
71
72 #endif // ASAN_STATS_H