PR go/67101
[official-gcc.git] / libsanitizer / tsan / tsan_stat.cc
blobcdb483585514631614599338e4b912a9cfdf32c0
1 //===-- tsan_stat.cc ------------------------------------------------------===//
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 ThreadSanitizer (TSan), a race detector.
9 //
10 //===----------------------------------------------------------------------===//
11 #include "tsan_stat.h"
12 #include "tsan_rtl.h"
14 namespace __tsan {
16 void StatAggregate(u64 *dst, u64 *src) {
17 if (!kCollectStats)
18 return;
19 for (int i = 0; i < StatCnt; i++)
20 dst[i] += src[i];
23 void StatOutput(u64 *stat) {
24 if (!kCollectStats)
25 return;
27 stat[StatShadowNonZero] = stat[StatShadowProcessed] - stat[StatShadowZero];
29 static const char *name[StatCnt] = {};
30 name[StatMop] = "Memory accesses ";
31 name[StatMopRead] = " Including reads ";
32 name[StatMopWrite] = " writes ";
33 name[StatMop1] = " Including size 1 ";
34 name[StatMop2] = " size 2 ";
35 name[StatMop4] = " size 4 ";
36 name[StatMop8] = " size 8 ";
37 name[StatMopSame] = " Including same ";
38 name[StatMopIgnored] = " Including ignored ";
39 name[StatMopRange] = " Including range ";
40 name[StatMopRodata] = " Including .rodata ";
41 name[StatMopRangeRodata] = " Including .rodata range ";
42 name[StatShadowProcessed] = "Shadow processed ";
43 name[StatShadowZero] = " Including empty ";
44 name[StatShadowNonZero] = " Including non empty ";
45 name[StatShadowSameSize] = " Including same size ";
46 name[StatShadowIntersect] = " intersect ";
47 name[StatShadowNotIntersect] = " not intersect ";
48 name[StatShadowSameThread] = " Including same thread ";
49 name[StatShadowAnotherThread] = " another thread ";
50 name[StatShadowReplace] = " Including evicted ";
52 name[StatFuncEnter] = "Function entries ";
53 name[StatFuncExit] = "Function exits ";
54 name[StatEvents] = "Events collected ";
56 name[StatThreadCreate] = "Total threads created ";
57 name[StatThreadFinish] = " threads finished ";
58 name[StatThreadReuse] = " threads reused ";
59 name[StatThreadMaxTid] = " max tid ";
60 name[StatThreadMaxAlive] = " max alive threads ";
62 name[StatMutexCreate] = "Mutexes created ";
63 name[StatMutexDestroy] = " destroyed ";
64 name[StatMutexLock] = " lock ";
65 name[StatMutexUnlock] = " unlock ";
66 name[StatMutexRecLock] = " recursive lock ";
67 name[StatMutexRecUnlock] = " recursive unlock ";
68 name[StatMutexReadLock] = " read lock ";
69 name[StatMutexReadUnlock] = " read unlock ";
71 name[StatSyncCreated] = "Sync objects created ";
72 name[StatSyncDestroyed] = " destroyed ";
73 name[StatSyncAcquire] = " acquired ";
74 name[StatSyncRelease] = " released ";
76 name[StatClockAcquire] = "Clock acquire ";
77 name[StatClockAcquireEmpty] = " empty clock ";
78 name[StatClockAcquireFastRelease] = " fast from release-store ";
79 name[StatClockAcquireLarge] = " contains my tid ";
80 name[StatClockAcquireRepeat] = " repeated (fast) ";
81 name[StatClockAcquireFull] = " full (slow) ";
82 name[StatClockAcquiredSomething] = " acquired something ";
83 name[StatClockRelease] = "Clock release ";
84 name[StatClockReleaseResize] = " resize ";
85 name[StatClockReleaseFast1] = " fast1 ";
86 name[StatClockReleaseFast2] = " fast2 ";
87 name[StatClockReleaseSlow] = " dirty overflow (slow) ";
88 name[StatClockReleaseFull] = " full (slow) ";
89 name[StatClockReleaseAcquired] = " was acquired ";
90 name[StatClockReleaseClearTail] = " clear tail ";
91 name[StatClockStore] = "Clock release store ";
92 name[StatClockStoreResize] = " resize ";
93 name[StatClockStoreFast] = " fast ";
94 name[StatClockStoreFull] = " slow ";
95 name[StatClockStoreTail] = " clear tail ";
96 name[StatClockAcquireRelease] = "Clock acquire-release ";
98 name[StatAtomic] = "Atomic operations ";
99 name[StatAtomicLoad] = " Including load ";
100 name[StatAtomicStore] = " store ";
101 name[StatAtomicExchange] = " exchange ";
102 name[StatAtomicFetchAdd] = " fetch_add ";
103 name[StatAtomicFetchSub] = " fetch_sub ";
104 name[StatAtomicFetchAnd] = " fetch_and ";
105 name[StatAtomicFetchOr] = " fetch_or ";
106 name[StatAtomicFetchXor] = " fetch_xor ";
107 name[StatAtomicFetchNand] = " fetch_nand ";
108 name[StatAtomicCAS] = " compare_exchange ";
109 name[StatAtomicFence] = " fence ";
110 name[StatAtomicRelaxed] = " Including relaxed ";
111 name[StatAtomicConsume] = " consume ";
112 name[StatAtomicAcquire] = " acquire ";
113 name[StatAtomicRelease] = " release ";
114 name[StatAtomicAcq_Rel] = " acq_rel ";
115 name[StatAtomicSeq_Cst] = " seq_cst ";
116 name[StatAtomic1] = " Including size 1 ";
117 name[StatAtomic2] = " size 2 ";
118 name[StatAtomic4] = " size 4 ";
119 name[StatAtomic8] = " size 8 ";
120 name[StatAtomic16] = " size 16 ";
122 name[StatAnnotation] = "Dynamic annotations ";
123 name[StatAnnotateHappensBefore] = " HappensBefore ";
124 name[StatAnnotateHappensAfter] = " HappensAfter ";
125 name[StatAnnotateCondVarSignal] = " CondVarSignal ";
126 name[StatAnnotateCondVarSignalAll] = " CondVarSignalAll ";
127 name[StatAnnotateMutexIsNotPHB] = " MutexIsNotPHB ";
128 name[StatAnnotateCondVarWait] = " CondVarWait ";
129 name[StatAnnotateRWLockCreate] = " RWLockCreate ";
130 name[StatAnnotateRWLockCreateStatic] = " StatAnnotateRWLockCreateStatic ";
131 name[StatAnnotateRWLockDestroy] = " RWLockDestroy ";
132 name[StatAnnotateRWLockAcquired] = " RWLockAcquired ";
133 name[StatAnnotateRWLockReleased] = " RWLockReleased ";
134 name[StatAnnotateTraceMemory] = " TraceMemory ";
135 name[StatAnnotateFlushState] = " FlushState ";
136 name[StatAnnotateNewMemory] = " NewMemory ";
137 name[StatAnnotateNoOp] = " NoOp ";
138 name[StatAnnotateFlushExpectedRaces] = " FlushExpectedRaces ";
139 name[StatAnnotateEnableRaceDetection] = " EnableRaceDetection ";
140 name[StatAnnotateMutexIsUsedAsCondVar] = " MutexIsUsedAsCondVar ";
141 name[StatAnnotatePCQGet] = " PCQGet ";
142 name[StatAnnotatePCQPut] = " PCQPut ";
143 name[StatAnnotatePCQDestroy] = " PCQDestroy ";
144 name[StatAnnotatePCQCreate] = " PCQCreate ";
145 name[StatAnnotateExpectRace] = " ExpectRace ";
146 name[StatAnnotateBenignRaceSized] = " BenignRaceSized ";
147 name[StatAnnotateBenignRace] = " BenignRace ";
148 name[StatAnnotateIgnoreReadsBegin] = " IgnoreReadsBegin ";
149 name[StatAnnotateIgnoreReadsEnd] = " IgnoreReadsEnd ";
150 name[StatAnnotateIgnoreWritesBegin] = " IgnoreWritesBegin ";
151 name[StatAnnotateIgnoreWritesEnd] = " IgnoreWritesEnd ";
152 name[StatAnnotateIgnoreSyncBegin] = " IgnoreSyncBegin ";
153 name[StatAnnotateIgnoreSyncEnd] = " IgnoreSyncEnd ";
154 name[StatAnnotatePublishMemoryRange] = " PublishMemoryRange ";
155 name[StatAnnotateUnpublishMemoryRange] = " UnpublishMemoryRange ";
156 name[StatAnnotateThreadName] = " ThreadName ";
158 name[StatMtxTotal] = "Contentionz ";
159 name[StatMtxTrace] = " Trace ";
160 name[StatMtxThreads] = " Threads ";
161 name[StatMtxReport] = " Report ";
162 name[StatMtxSyncVar] = " SyncVar ";
163 name[StatMtxSyncTab] = " SyncTab ";
164 name[StatMtxSlab] = " Slab ";
165 name[StatMtxAtExit] = " Atexit ";
166 name[StatMtxAnnotations] = " Annotations ";
167 name[StatMtxMBlock] = " MBlock ";
168 name[StatMtxJavaMBlock] = " JavaMBlock ";
169 name[StatMtxDeadlockDetector] = " DeadlockDetector ";
170 name[StatMtxFD] = " FD ";
172 Printf("Statistics:\n");
173 for (int i = 0; i < StatCnt; i++)
174 Printf("%s: %16zu\n", name[i], (uptr)stat[i]);
177 } // namespace __tsan