Home | History | Annotate | Download | only in rtl

Lines Matching defs:thr

26 void ReportDeadlock(ThreadState *thr, uptr pc, DDReport *r);
29 ThreadState *thr;
32 Callback(ThreadState *thr, uptr pc)
33 : thr(thr)
35 DDCallback::pt = thr->proc()->dd_pt;
36 DDCallback::lt = thr->dd_lt;
39 u32 Unwind() override { return CurrentStackId(thr, pc); }
40 int UniqueTid() override { return thr->unique_id; }
43 void DDMutexInit(ThreadState *thr, uptr pc, SyncVar *s) {
44 Callback cb(thr, pc);
49 static void ReportMutexMisuse(ThreadState *thr, uptr pc, ReportType typ,
59 ObtainCurrentStack(thr, pc, &trace);
62 OutputReport(thr, rep);
65 void MutexCreate(ThreadState *thr, uptr pc, uptr addr,
67 DPrintf("#%d: MutexCreate %zx\n", thr->tid, addr);
68 StatInc(thr, StatMutexCreate);
70 CHECK(!thr->is_freeing);
71 thr->is_freeing = true;
72 MemoryWrite(thr, pc, addr, kSizeLog1);
73 thr->is_freeing = false;
75 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
80 s->creation_stack_id = CurrentStackId(thr, pc);
84 void MutexDestroy(ThreadState *thr, uptr pc, uptr addr) {
85 DPrintf("#%d: MutexDestroy %zx\n", thr->tid, addr);
86 StatInc(thr, StatMutexDestroy);
96 Callback cb(thr, pc);
110 s->Reset(thr->proc()); // must not reset it before the report is printed
117 ObtainCurrentStack(thr, pc, &trace);
123 OutputReport(thr, rep);
127 s->Reset(thr->proc());
131 thr->mset.Remove(mid);
136 CHECK(!thr->is_freeing);
137 thr->is_freeing = true;
138 MemoryWrite(thr, pc, addr, kSizeLog1);
139 thr->is_freeing = false;
144 void MutexLock(ThreadState *thr, uptr pc, uptr addr, int rec, bool try_lock) {
145 DPrintf("#%d: MutexLock %zx rec=%d\n", thr->tid, addr, rec);
148 MemoryReadAtomic(thr, pc, addr, kSizeLog1);
149 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
150 thr->fast_state.IncrementEpoch();
151 TraceAddEvent(thr, thr->fast_state, EventTypeLock, s->GetId());
155 s->owner_tid = thr->tid;
156 s->last_lock = thr->fast_state.raw();
157 } else if (s->owner_tid == thr->tid) {
164 StatInc(thr, StatMutexLock);
165 AcquireImpl(thr, pc, &s->clock);
166 AcquireImpl(thr, pc, &s->read_clock);
168 StatInc(thr, StatMutexRecLock);
171 thr->mset.Add(s->GetId(), true, thr->fast_state.epoch());
173 Callback cb(thr, pc);
182 ReportMutexMisuse(thr, pc, ReportTypeMutexDoubleLock, addr, mid);
184 Callback cb(thr, pc);
185 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb));
189 int MutexUnlock(ThreadState *thr, uptr pc, uptr addr, bool all) {
190 DPrintf("#%d: MutexUnlock %zx all=%d\n", thr->tid, addr, all);
192 MemoryReadAtomic(thr, pc, addr, kSizeLog1);
193 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
194 thr->fast_state.IncrementEpoch();
195 TraceAddEvent(thr, thr->fast_state, EventTypeUnlock, s->GetId());
198 if (kCppMode && (s->recursion == 0 || s->owner_tid != thr->tid)) {
207 StatInc(thr, StatMutexUnlock);
209 ReleaseStoreImpl(thr, pc, &s->clock);
211 StatInc(thr, StatMutexRecUnlock);
214 thr->mset.Del(s->GetId(), true);
217 Callback cb(thr, pc);
224 ReportMutexMisuse(thr, pc, ReportTypeMutexBadUnlock, addr, mid);
226 Callback cb(thr, pc);
227 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb));
232 void MutexReadLock(ThreadState *thr, uptr pc, uptr addr, bool trylock) {
233 DPrintf("#%d: MutexReadLock %zx\n", thr->tid, addr);
234 StatInc(thr, StatMutexReadLock);
236 MemoryReadAtomic(thr, pc, addr, kSizeLog1);
237 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, false);
238 thr->fast_state.IncrementEpoch();
239 TraceAddEvent(thr, thr->fast_state, EventTypeRLock, s->GetId());
247 AcquireImpl(thr, pc, &s->clock);
248 s->last_lock = thr->fast_state.raw();
249 thr->mset.Add(s->GetId(), false, thr->fast_state.epoch());
251 Callback cb(thr, pc);
260 ReportMutexMisuse(thr, pc, ReportTypeMutexBadReadLock, addr, mid);
262 Callback cb(thr, pc);
263 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb));
267 void MutexReadUnlock(ThreadState *thr, uptr pc, uptr addr) {
268 DPrintf("#%d: MutexReadUnlock %zx\n", thr->tid, addr);
269 StatInc(thr, StatMutexReadUnlock);
271 MemoryReadAtomic(thr, pc, addr, kSizeLog1);
272 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
273 thr->fast_state.IncrementEpoch();
274 TraceAddEvent(thr, thr->fast_state, EventTypeRUnlock, s->GetId());
282 ReleaseImpl(thr, pc, &s->read_clock);
284 Callback cb(thr, pc);
290 thr->mset.Del(mid, false);
292 ReportMutexMisuse(thr, pc, ReportTypeMutexBadReadUnlock, addr, mid);
294 Callback cb(thr, pc);
295 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb));
299 void MutexReadOrWriteUnlock(ThreadState *thr, uptr pc, uptr addr) {
300 DPrintf("#%d: MutexReadOrWriteUnlock %zx\n", thr->tid, addr);
302 MemoryReadAtomic(thr, pc, addr, kSizeLog1);
303 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
309 StatInc(thr, StatMutexReadUnlock);
310 thr->fast_state.IncrementEpoch();
311 TraceAddEvent(thr, thr->fast_state, EventTypeRUnlock, s->GetId());
312 ReleaseImpl(thr, pc, &s->read_clock);
313 } else if (s->owner_tid == thr->tid) {
315 thr->fast_state.IncrementEpoch();
316 TraceAddEvent(thr, thr->fast_state, EventTypeUnlock, s->GetId());
320 StatInc(thr, StatMutexUnlock);
322 ReleaseImpl(thr, pc, &s->clock);
324 StatInc(thr, StatMutexRecUnlock);
330 thr->mset.Del(s->GetId(), write);
332 Callback cb(thr, pc);
339 ReportMutexMisuse(thr, pc, ReportTypeMutexBadUnlock, addr, mid);
341 Callback cb(thr, pc);
342 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb));
346 void MutexRepair(ThreadState *thr, uptr pc, uptr addr) {
347 DPrintf("#%d: MutexRepair %zx\n", thr->tid, addr);
348 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
354 void MutexInvalidAccess(ThreadState *thr, uptr pc, uptr addr) {
355 DPrintf("#%d: MutexInvalidAccess %zx\n", thr->tid, addr);
356 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
359 ReportMutexMisuse(thr, pc, ReportTypeMutexInvalidAccess, addr, mid);
362 void Acquire(ThreadState *thr, uptr pc, uptr addr) {
363 DPrintf("#%d: Acquire %zx\n", thr->tid, addr);
364 if (thr->ignore_sync)
369 AcquireImpl(thr, pc, &s->clock);
374 ThreadState *thr = reinterpret_cast<ThreadState*>(arg);
377 thr->clock.set(tctx->tid, tctx->thr->fast_state.epoch());
379 thr->clock.set(tctx->tid, tctx->epoch1);
382 void AcquireGlobal(ThreadState *thr, uptr pc) {
383 DPrintf("#%d: AcquireGlobal\n", thr->tid);
384 if (thr->ignore_sync)
388 UpdateClockCallback, thr);
391 void Release(ThreadState *thr, uptr pc, uptr addr) {
392 DPrintf("#%d: Release %zx\n", thr->tid, addr);
393 if (thr->ignore_sync)
395 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
396 thr->fast_state.IncrementEpoch();
398 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0);
399 ReleaseImpl(thr, pc, &s->clock);
403 void ReleaseStore(ThreadState *thr, uptr pc, uptr addr) {
404 DPrintf("#%d: ReleaseStore %zx\n", thr->tid, addr);
405 if (thr->ignore_sync)
407 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
408 thr->fast_state.IncrementEpoch();
410 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0);
411 ReleaseStoreImpl(thr, pc, &s->clock);
417 ThreadState *thr = reinterpret_cast<ThreadState*>(arg);
420 thr->last_sleep_clock.set(tctx->tid, tctx->thr->fast_state.epoch());
422 thr->last_sleep_clock.set(tctx->tid, tctx->epoch1);
425 void AfterSleep(ThreadState *thr, uptr pc) {
426 DPrintf("#%d: AfterSleep %zx\n", thr->tid);
427 if (thr->ignore_sync)
429 thr->last_sleep_stack_id = CurrentStackId(thr, pc);
432 UpdateSleepClockCallback, thr);
436 void AcquireImpl(ThreadState *thr, uptr pc, SyncClock *c) {
437 if (thr->ignore_sync)
439 thr->clock.set(thr->fast_state.epoch());
440 thr->clock.acquire(&thr->proc()->clock_cache, c);
441 StatInc(thr, StatSyncAcquire);
444 void ReleaseImpl(ThreadState *thr, uptr pc, SyncClock *c) {
445 if (thr->ignore_sync)
447 thr->clock.set(thr->fast_state.epoch());
448 thr->fast_synch_epoch = thr->fast_state.epoch();
449 thr->clock.release(&thr->proc()->clock_cache, c);
450 StatInc(thr, StatSyncRelease);
453 void ReleaseStoreImpl(ThreadState *thr, uptr pc, SyncClock *c) {
454 if (thr->ignore_sync)
456 thr->clock.set(thr->fast_state.epoch());
457 thr->fast_synch_epoch = thr->fast_state.epoch();
458 thr->clock.ReleaseStore(&thr->proc()->clock_cache, c);
459 StatInc(thr, StatSyncRelease);
462 void AcquireReleaseImpl(ThreadState *thr, uptr pc, SyncClock *c) {
463 if (thr->ignore_sync)
465 thr->clock.set(thr->fast_state.epoch());
466 thr->fast_synch_epoch = thr->fast_state.epoch();
467 thr->clock.acq_rel(&thr->proc()->clock_cache, c);
468 StatInc(thr, StatSyncAcquire);
469 StatInc(thr, StatSyncRelease);
472 void ReportDeadlock(ThreadState *thr, uptr pc, DDReport *r) {
495 thr, rep);