Lines Matching refs:thr

26 void ReportDeadlock(ThreadState *thr, uptr pc, DDReport *r);
29 ThreadState *thr; member
32 Callback(ThreadState *thr, uptr pc) in Callback()
33 : thr(thr) in Callback()
35 DDCallback::pt = thr->dd_pt; in Callback()
36 DDCallback::lt = thr->dd_lt; in Callback()
39 u32 Unwind() override { return CurrentStackId(thr, pc); } in Unwind()
40 int UniqueTid() override { return thr->unique_id; } in UniqueTid()
43 void DDMutexInit(ThreadState *thr, uptr pc, SyncVar *s) { in DDMutexInit() argument
44 Callback cb(thr, pc); in DDMutexInit()
49 static void ReportMutexMisuse(ThreadState *thr, uptr pc, ReportType typ, in ReportMutexMisuse() argument
59 ObtainCurrentStack(thr, pc, &trace); in ReportMutexMisuse()
62 OutputReport(thr, rep); in ReportMutexMisuse()
65 void MutexCreate(ThreadState *thr, uptr pc, uptr addr, in MutexCreate() argument
67 DPrintf("#%d: MutexCreate %zx\n", thr->tid, addr); in MutexCreate()
68 StatInc(thr, StatMutexCreate); in MutexCreate()
70 CHECK(!thr->is_freeing); in MutexCreate()
71 thr->is_freeing = true; in MutexCreate()
72 MemoryWrite(thr, pc, addr, kSizeLog1); in MutexCreate()
73 thr->is_freeing = false; in MutexCreate()
75 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true); in MutexCreate()
80 s->creation_stack_id = CurrentStackId(thr, pc); in MutexCreate()
84 void MutexDestroy(ThreadState *thr, uptr pc, uptr addr) { in MutexDestroy() argument
85 DPrintf("#%d: MutexDestroy %zx\n", thr->tid, addr); in MutexDestroy()
86 StatInc(thr, StatMutexDestroy); in MutexDestroy()
94 CHECK(!thr->is_freeing); in MutexDestroy()
95 thr->is_freeing = true; in MutexDestroy()
96 MemoryWrite(thr, pc, addr, kSizeLog1); in MutexDestroy()
97 thr->is_freeing = false; in MutexDestroy()
103 Callback cb(thr, pc); in MutexDestroy()
117 s->Reset(thr); // must not reset it before the report is printed in MutexDestroy()
124 ObtainCurrentStack(thr, pc, &trace); in MutexDestroy()
130 OutputReport(thr, rep); in MutexDestroy()
135 s->Reset(thr); in MutexDestroy()
139 thr->mset.Remove(mid); in MutexDestroy()
143 void MutexLock(ThreadState *thr, uptr pc, uptr addr, int rec, bool try_lock) { in MutexLock() argument
144 DPrintf("#%d: MutexLock %zx rec=%d\n", thr->tid, addr, rec); in MutexLock()
147 MemoryReadAtomic(thr, pc, addr, kSizeLog1); in MutexLock()
148 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true); in MutexLock()
149 thr->fast_state.IncrementEpoch(); in MutexLock()
150 TraceAddEvent(thr, thr->fast_state, EventTypeLock, s->GetId()); in MutexLock()
154 s->owner_tid = thr->tid; in MutexLock()
155 s->last_lock = thr->fast_state.raw(); in MutexLock()
156 } else if (s->owner_tid == thr->tid) { in MutexLock()
163 StatInc(thr, StatMutexLock); in MutexLock()
164 AcquireImpl(thr, pc, &s->clock); in MutexLock()
165 AcquireImpl(thr, pc, &s->read_clock); in MutexLock()
167 StatInc(thr, StatMutexRecLock); in MutexLock()
170 thr->mset.Add(s->GetId(), true, thr->fast_state.epoch()); in MutexLock()
172 Callback cb(thr, pc); in MutexLock()
181 ReportMutexMisuse(thr, pc, ReportTypeMutexDoubleLock, addr, mid); in MutexLock()
183 Callback cb(thr, pc); in MutexLock()
184 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb)); in MutexLock()
188 int MutexUnlock(ThreadState *thr, uptr pc, uptr addr, bool all) { in MutexUnlock() argument
189 DPrintf("#%d: MutexUnlock %zx all=%d\n", thr->tid, addr, all); in MutexUnlock()
191 MemoryReadAtomic(thr, pc, addr, kSizeLog1); in MutexUnlock()
192 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true); in MutexUnlock()
193 thr->fast_state.IncrementEpoch(); in MutexUnlock()
194 TraceAddEvent(thr, thr->fast_state, EventTypeUnlock, s->GetId()); in MutexUnlock()
197 if (kCppMode && (s->recursion == 0 || s->owner_tid != thr->tid)) { in MutexUnlock()
206 StatInc(thr, StatMutexUnlock); in MutexUnlock()
208 ReleaseStoreImpl(thr, pc, &s->clock); in MutexUnlock()
210 StatInc(thr, StatMutexRecUnlock); in MutexUnlock()
213 thr->mset.Del(s->GetId(), true); in MutexUnlock()
216 Callback cb(thr, pc); in MutexUnlock()
223 ReportMutexMisuse(thr, pc, ReportTypeMutexBadUnlock, addr, mid); in MutexUnlock()
225 Callback cb(thr, pc); in MutexUnlock()
226 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb)); in MutexUnlock()
231 void MutexReadLock(ThreadState *thr, uptr pc, uptr addr, bool trylock) { in MutexReadLock() argument
232 DPrintf("#%d: MutexReadLock %zx\n", thr->tid, addr); in MutexReadLock()
233 StatInc(thr, StatMutexReadLock); in MutexReadLock()
235 MemoryReadAtomic(thr, pc, addr, kSizeLog1); in MutexReadLock()
236 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, false); in MutexReadLock()
237 thr->fast_state.IncrementEpoch(); in MutexReadLock()
238 TraceAddEvent(thr, thr->fast_state, EventTypeRLock, s->GetId()); in MutexReadLock()
246 AcquireImpl(thr, pc, &s->clock); in MutexReadLock()
247 s->last_lock = thr->fast_state.raw(); in MutexReadLock()
248 thr->mset.Add(s->GetId(), false, thr->fast_state.epoch()); in MutexReadLock()
250 Callback cb(thr, pc); in MutexReadLock()
259 ReportMutexMisuse(thr, pc, ReportTypeMutexBadReadLock, addr, mid); in MutexReadLock()
261 Callback cb(thr, pc); in MutexReadLock()
262 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb)); in MutexReadLock()
266 void MutexReadUnlock(ThreadState *thr, uptr pc, uptr addr) { in MutexReadUnlock() argument
267 DPrintf("#%d: MutexReadUnlock %zx\n", thr->tid, addr); in MutexReadUnlock()
268 StatInc(thr, StatMutexReadUnlock); in MutexReadUnlock()
270 MemoryReadAtomic(thr, pc, addr, kSizeLog1); in MutexReadUnlock()
271 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true); in MutexReadUnlock()
272 thr->fast_state.IncrementEpoch(); in MutexReadUnlock()
273 TraceAddEvent(thr, thr->fast_state, EventTypeRUnlock, s->GetId()); in MutexReadUnlock()
281 ReleaseImpl(thr, pc, &s->read_clock); in MutexReadUnlock()
283 Callback cb(thr, pc); in MutexReadUnlock()
289 thr->mset.Del(mid, false); in MutexReadUnlock()
291 ReportMutexMisuse(thr, pc, ReportTypeMutexBadReadUnlock, addr, mid); in MutexReadUnlock()
293 Callback cb(thr, pc); in MutexReadUnlock()
294 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb)); in MutexReadUnlock()
298 void MutexReadOrWriteUnlock(ThreadState *thr, uptr pc, uptr addr) { in MutexReadOrWriteUnlock() argument
299 DPrintf("#%d: MutexReadOrWriteUnlock %zx\n", thr->tid, addr); in MutexReadOrWriteUnlock()
301 MemoryReadAtomic(thr, pc, addr, kSizeLog1); in MutexReadOrWriteUnlock()
302 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true); in MutexReadOrWriteUnlock()
308 StatInc(thr, StatMutexReadUnlock); in MutexReadOrWriteUnlock()
309 thr->fast_state.IncrementEpoch(); in MutexReadOrWriteUnlock()
310 TraceAddEvent(thr, thr->fast_state, EventTypeRUnlock, s->GetId()); in MutexReadOrWriteUnlock()
311 ReleaseImpl(thr, pc, &s->read_clock); in MutexReadOrWriteUnlock()
312 } else if (s->owner_tid == thr->tid) { in MutexReadOrWriteUnlock()
314 thr->fast_state.IncrementEpoch(); in MutexReadOrWriteUnlock()
315 TraceAddEvent(thr, thr->fast_state, EventTypeUnlock, s->GetId()); in MutexReadOrWriteUnlock()
319 StatInc(thr, StatMutexUnlock); in MutexReadOrWriteUnlock()
321 ReleaseImpl(thr, pc, &s->clock); in MutexReadOrWriteUnlock()
323 StatInc(thr, StatMutexRecUnlock); in MutexReadOrWriteUnlock()
329 thr->mset.Del(s->GetId(), write); in MutexReadOrWriteUnlock()
331 Callback cb(thr, pc); in MutexReadOrWriteUnlock()
338 ReportMutexMisuse(thr, pc, ReportTypeMutexBadUnlock, addr, mid); in MutexReadOrWriteUnlock()
340 Callback cb(thr, pc); in MutexReadOrWriteUnlock()
341 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb)); in MutexReadOrWriteUnlock()
345 void MutexRepair(ThreadState *thr, uptr pc, uptr addr) { in MutexRepair() argument
346 DPrintf("#%d: MutexRepair %zx\n", thr->tid, addr); in MutexRepair()
347 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true); in MutexRepair()
353 void Acquire(ThreadState *thr, uptr pc, uptr addr) { in Acquire() argument
354 DPrintf("#%d: Acquire %zx\n", thr->tid, addr); in Acquire()
355 if (thr->ignore_sync) in Acquire()
357 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, false); in Acquire()
358 AcquireImpl(thr, pc, &s->clock); in Acquire()
363 ThreadState *thr = reinterpret_cast<ThreadState*>(arg); in UpdateClockCallback() local
366 thr->clock.set(tctx->tid, tctx->thr->fast_state.epoch()); in UpdateClockCallback()
368 thr->clock.set(tctx->tid, tctx->epoch1); in UpdateClockCallback()
371 void AcquireGlobal(ThreadState *thr, uptr pc) { in AcquireGlobal() argument
372 DPrintf("#%d: AcquireGlobal\n", thr->tid); in AcquireGlobal()
373 if (thr->ignore_sync) in AcquireGlobal()
377 UpdateClockCallback, thr); in AcquireGlobal()
380 void Release(ThreadState *thr, uptr pc, uptr addr) { in Release() argument
381 DPrintf("#%d: Release %zx\n", thr->tid, addr); in Release()
382 if (thr->ignore_sync) in Release()
384 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true); in Release()
385 thr->fast_state.IncrementEpoch(); in Release()
387 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0); in Release()
388 ReleaseImpl(thr, pc, &s->clock); in Release()
392 void ReleaseStore(ThreadState *thr, uptr pc, uptr addr) { in ReleaseStore() argument
393 DPrintf("#%d: ReleaseStore %zx\n", thr->tid, addr); in ReleaseStore()
394 if (thr->ignore_sync) in ReleaseStore()
396 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true); in ReleaseStore()
397 thr->fast_state.IncrementEpoch(); in ReleaseStore()
399 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0); in ReleaseStore()
400 ReleaseStoreImpl(thr, pc, &s->clock); in ReleaseStore()
406 ThreadState *thr = reinterpret_cast<ThreadState*>(arg); in UpdateSleepClockCallback() local
409 thr->last_sleep_clock.set(tctx->tid, tctx->thr->fast_state.epoch()); in UpdateSleepClockCallback()
411 thr->last_sleep_clock.set(tctx->tid, tctx->epoch1); in UpdateSleepClockCallback()
414 void AfterSleep(ThreadState *thr, uptr pc) { in AfterSleep() argument
415 DPrintf("#%d: AfterSleep %zx\n", thr->tid); in AfterSleep()
416 if (thr->ignore_sync) in AfterSleep()
418 thr->last_sleep_stack_id = CurrentStackId(thr, pc); in AfterSleep()
421 UpdateSleepClockCallback, thr); in AfterSleep()
425 void AcquireImpl(ThreadState *thr, uptr pc, SyncClock *c) { in AcquireImpl() argument
426 if (thr->ignore_sync) in AcquireImpl()
428 thr->clock.set(thr->fast_state.epoch()); in AcquireImpl()
429 thr->clock.acquire(&thr->clock_cache, c); in AcquireImpl()
430 StatInc(thr, StatSyncAcquire); in AcquireImpl()
433 void ReleaseImpl(ThreadState *thr, uptr pc, SyncClock *c) { in ReleaseImpl() argument
434 if (thr->ignore_sync) in ReleaseImpl()
436 thr->clock.set(thr->fast_state.epoch()); in ReleaseImpl()
437 thr->fast_synch_epoch = thr->fast_state.epoch(); in ReleaseImpl()
438 thr->clock.release(&thr->clock_cache, c); in ReleaseImpl()
439 StatInc(thr, StatSyncRelease); in ReleaseImpl()
442 void ReleaseStoreImpl(ThreadState *thr, uptr pc, SyncClock *c) { in ReleaseStoreImpl() argument
443 if (thr->ignore_sync) in ReleaseStoreImpl()
445 thr->clock.set(thr->fast_state.epoch()); in ReleaseStoreImpl()
446 thr->fast_synch_epoch = thr->fast_state.epoch(); in ReleaseStoreImpl()
447 thr->clock.ReleaseStore(&thr->clock_cache, c); in ReleaseStoreImpl()
448 StatInc(thr, StatSyncRelease); in ReleaseStoreImpl()
451 void AcquireReleaseImpl(ThreadState *thr, uptr pc, SyncClock *c) { in AcquireReleaseImpl() argument
452 if (thr->ignore_sync) in AcquireReleaseImpl()
454 thr->clock.set(thr->fast_state.epoch()); in AcquireReleaseImpl()
455 thr->fast_synch_epoch = thr->fast_state.epoch(); in AcquireReleaseImpl()
456 thr->clock.acq_rel(&thr->clock_cache, c); in AcquireReleaseImpl()
457 StatInc(thr, StatSyncAcquire); in AcquireReleaseImpl()
458 StatInc(thr, StatSyncRelease); in AcquireReleaseImpl()
461 void ReportDeadlock(ThreadState *thr, uptr pc, DDReport *r) { in ReportDeadlock() argument
484 OutputReport(thr, rep); in ReportDeadlock()