Retro68/gcc/libsanitizer/tsan/tsan_stat.cc

186 lines
12 KiB
C++
Raw Normal View History

2014-09-21 17:33:12 +00:00
//===-- tsan_stat.cc ------------------------------------------------------===//
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of ThreadSanitizer (TSan), a race detector.
//
//===----------------------------------------------------------------------===//
#include "tsan_stat.h"
#include "tsan_rtl.h"
namespace __tsan {
2017-04-10 11:32:00 +00:00
#if TSAN_COLLECT_STATS
2014-09-21 17:33:12 +00:00
void StatAggregate(u64 *dst, u64 *src) {
for (int i = 0; i < StatCnt; i++)
dst[i] += src[i];
}
void StatOutput(u64 *stat) {
stat[StatShadowNonZero] = stat[StatShadowProcessed] - stat[StatShadowZero];
static const char *name[StatCnt] = {};
name[StatMop] = "Memory accesses ";
name[StatMopRead] = " Including reads ";
name[StatMopWrite] = " writes ";
name[StatMop1] = " Including size 1 ";
name[StatMop2] = " size 2 ";
name[StatMop4] = " size 4 ";
name[StatMop8] = " size 8 ";
name[StatMopSame] = " Including same ";
2015-08-28 15:33:40 +00:00
name[StatMopIgnored] = " Including ignored ";
2014-09-21 17:33:12 +00:00
name[StatMopRange] = " Including range ";
name[StatMopRodata] = " Including .rodata ";
name[StatMopRangeRodata] = " Including .rodata range ";
name[StatShadowProcessed] = "Shadow processed ";
name[StatShadowZero] = " Including empty ";
name[StatShadowNonZero] = " Including non empty ";
name[StatShadowSameSize] = " Including same size ";
name[StatShadowIntersect] = " intersect ";
name[StatShadowNotIntersect] = " not intersect ";
name[StatShadowSameThread] = " Including same thread ";
name[StatShadowAnotherThread] = " another thread ";
name[StatShadowReplace] = " Including evicted ";
name[StatFuncEnter] = "Function entries ";
name[StatFuncExit] = "Function exits ";
name[StatEvents] = "Events collected ";
name[StatThreadCreate] = "Total threads created ";
name[StatThreadFinish] = " threads finished ";
name[StatThreadReuse] = " threads reused ";
name[StatThreadMaxTid] = " max tid ";
name[StatThreadMaxAlive] = " max alive threads ";
name[StatMutexCreate] = "Mutexes created ";
name[StatMutexDestroy] = " destroyed ";
name[StatMutexLock] = " lock ";
name[StatMutexUnlock] = " unlock ";
name[StatMutexRecLock] = " recursive lock ";
name[StatMutexRecUnlock] = " recursive unlock ";
name[StatMutexReadLock] = " read lock ";
name[StatMutexReadUnlock] = " read unlock ";
name[StatSyncCreated] = "Sync objects created ";
name[StatSyncDestroyed] = " destroyed ";
name[StatSyncAcquire] = " acquired ";
name[StatSyncRelease] = " released ";
2015-08-28 15:33:40 +00:00
name[StatClockAcquire] = "Clock acquire ";
name[StatClockAcquireEmpty] = " empty clock ";
name[StatClockAcquireFastRelease] = " fast from release-store ";
name[StatClockAcquireFull] = " full (slow) ";
name[StatClockAcquiredSomething] = " acquired something ";
name[StatClockRelease] = "Clock release ";
name[StatClockReleaseResize] = " resize ";
2018-12-28 15:30:48 +00:00
name[StatClockReleaseFast] = " fast ";
2015-08-28 15:33:40 +00:00
name[StatClockReleaseSlow] = " dirty overflow (slow) ";
name[StatClockReleaseFull] = " full (slow) ";
name[StatClockReleaseAcquired] = " was acquired ";
name[StatClockReleaseClearTail] = " clear tail ";
name[StatClockStore] = "Clock release store ";
name[StatClockStoreResize] = " resize ";
name[StatClockStoreFast] = " fast ";
name[StatClockStoreFull] = " slow ";
name[StatClockStoreTail] = " clear tail ";
name[StatClockAcquireRelease] = "Clock acquire-release ";
2014-09-21 17:33:12 +00:00
name[StatAtomic] = "Atomic operations ";
name[StatAtomicLoad] = " Including load ";
name[StatAtomicStore] = " store ";
name[StatAtomicExchange] = " exchange ";
name[StatAtomicFetchAdd] = " fetch_add ";
name[StatAtomicFetchSub] = " fetch_sub ";
name[StatAtomicFetchAnd] = " fetch_and ";
name[StatAtomicFetchOr] = " fetch_or ";
name[StatAtomicFetchXor] = " fetch_xor ";
name[StatAtomicFetchNand] = " fetch_nand ";
name[StatAtomicCAS] = " compare_exchange ";
name[StatAtomicFence] = " fence ";
name[StatAtomicRelaxed] = " Including relaxed ";
name[StatAtomicConsume] = " consume ";
name[StatAtomicAcquire] = " acquire ";
name[StatAtomicRelease] = " release ";
name[StatAtomicAcq_Rel] = " acq_rel ";
name[StatAtomicSeq_Cst] = " seq_cst ";
name[StatAtomic1] = " Including size 1 ";
name[StatAtomic2] = " size 2 ";
name[StatAtomic4] = " size 4 ";
name[StatAtomic8] = " size 8 ";
name[StatAtomic16] = " size 16 ";
name[StatAnnotation] = "Dynamic annotations ";
name[StatAnnotateHappensBefore] = " HappensBefore ";
name[StatAnnotateHappensAfter] = " HappensAfter ";
name[StatAnnotateCondVarSignal] = " CondVarSignal ";
name[StatAnnotateCondVarSignalAll] = " CondVarSignalAll ";
name[StatAnnotateMutexIsNotPHB] = " MutexIsNotPHB ";
name[StatAnnotateCondVarWait] = " CondVarWait ";
name[StatAnnotateRWLockCreate] = " RWLockCreate ";
name[StatAnnotateRWLockCreateStatic] = " StatAnnotateRWLockCreateStatic ";
name[StatAnnotateRWLockDestroy] = " RWLockDestroy ";
name[StatAnnotateRWLockAcquired] = " RWLockAcquired ";
name[StatAnnotateRWLockReleased] = " RWLockReleased ";
name[StatAnnotateTraceMemory] = " TraceMemory ";
name[StatAnnotateFlushState] = " FlushState ";
name[StatAnnotateNewMemory] = " NewMemory ";
name[StatAnnotateNoOp] = " NoOp ";
name[StatAnnotateFlushExpectedRaces] = " FlushExpectedRaces ";
name[StatAnnotateEnableRaceDetection] = " EnableRaceDetection ";
name[StatAnnotateMutexIsUsedAsCondVar] = " MutexIsUsedAsCondVar ";
name[StatAnnotatePCQGet] = " PCQGet ";
name[StatAnnotatePCQPut] = " PCQPut ";
name[StatAnnotatePCQDestroy] = " PCQDestroy ";
name[StatAnnotatePCQCreate] = " PCQCreate ";
name[StatAnnotateExpectRace] = " ExpectRace ";
name[StatAnnotateBenignRaceSized] = " BenignRaceSized ";
name[StatAnnotateBenignRace] = " BenignRace ";
name[StatAnnotateIgnoreReadsBegin] = " IgnoreReadsBegin ";
name[StatAnnotateIgnoreReadsEnd] = " IgnoreReadsEnd ";
name[StatAnnotateIgnoreWritesBegin] = " IgnoreWritesBegin ";
name[StatAnnotateIgnoreWritesEnd] = " IgnoreWritesEnd ";
name[StatAnnotateIgnoreSyncBegin] = " IgnoreSyncBegin ";
name[StatAnnotateIgnoreSyncEnd] = " IgnoreSyncEnd ";
name[StatAnnotatePublishMemoryRange] = " PublishMemoryRange ";
name[StatAnnotateUnpublishMemoryRange] = " UnpublishMemoryRange ";
name[StatAnnotateThreadName] = " ThreadName ";
2018-12-28 15:30:48 +00:00
name[Stat__tsan_mutex_create] = " __tsan_mutex_create ";
name[Stat__tsan_mutex_destroy] = " __tsan_mutex_destroy ";
name[Stat__tsan_mutex_pre_lock] = " __tsan_mutex_pre_lock ";
name[Stat__tsan_mutex_post_lock] = " __tsan_mutex_post_lock ";
name[Stat__tsan_mutex_pre_unlock] = " __tsan_mutex_pre_unlock ";
name[Stat__tsan_mutex_post_unlock] = " __tsan_mutex_post_unlock ";
name[Stat__tsan_mutex_pre_signal] = " __tsan_mutex_pre_signal ";
name[Stat__tsan_mutex_post_signal] = " __tsan_mutex_post_signal ";
name[Stat__tsan_mutex_pre_divert] = " __tsan_mutex_pre_divert ";
name[Stat__tsan_mutex_post_divert] = " __tsan_mutex_post_divert ";
2014-09-21 17:33:12 +00:00
name[StatMtxTotal] = "Contentionz ";
name[StatMtxTrace] = " Trace ";
name[StatMtxThreads] = " Threads ";
name[StatMtxReport] = " Report ";
name[StatMtxSyncVar] = " SyncVar ";
name[StatMtxSyncTab] = " SyncTab ";
name[StatMtxSlab] = " Slab ";
name[StatMtxAtExit] = " Atexit ";
name[StatMtxAnnotations] = " Annotations ";
name[StatMtxMBlock] = " MBlock ";
2015-08-28 15:33:40 +00:00
name[StatMtxDeadlockDetector] = " DeadlockDetector ";
2017-04-10 11:32:00 +00:00
name[StatMtxFired] = " FiredSuppressions ";
name[StatMtxRacy] = " RacyStacks ";
2014-09-21 17:33:12 +00:00
name[StatMtxFD] = " FD ";
name[StatMtxGlobalProc] = " GlobalProc ";
2014-09-21 17:33:12 +00:00
Printf("Statistics:\n");
for (int i = 0; i < StatCnt; i++)
2015-08-28 15:33:40 +00:00
Printf("%s: %16zu\n", name[i], (uptr)stat[i]);
2014-09-21 17:33:12 +00:00
}
2017-04-10 11:32:00 +00:00
#endif
2014-09-21 17:33:12 +00:00
} // namespace __tsan