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