Lines Matching refs:thr

307 void UnmapShadow(ThreadState *thr, uptr addr, uptr size) {  in UnmapShadow()  argument
312 ctx->metamap.ResetRange(thr->proc(), addr, size); in UnmapShadow()
396 void Initialize(ThreadState *thr) { in Initialize() argument
427 ProcWire(proc, thr); in Initialize()
448 Tid tid = ThreadCreate(thr, 0, 0, true); in Initialize()
450 ThreadStart(thr, tid, GetTid(), ThreadType::Regular); in Initialize()
486 int Finalize(ThreadState *thr) { in Finalize() argument
492 if (flags()->atexit_sleep_ms > 0 && ThreadCount(thr) > 1) in Finalize()
504 ThreadFinalize(thr); in Finalize()
524 void ForkBefore(ThreadState *thr, uptr pc) SANITIZER_NO_THREAD_SAFETY_ANALYSIS { in ForkBefore() argument
534 thr->suppress_reports++; in ForkBefore()
539 thr->ignore_interceptors++; in ForkBefore()
541 thr->ignore_reads_and_writes++; in ForkBefore()
546 void ForkParentAfter(ThreadState *thr, in ForkParentAfter() argument
548 thr->suppress_reports--; // Enabled in ForkBefore. in ForkParentAfter()
549 thr->ignore_interceptors--; in ForkParentAfter()
550 thr->ignore_reads_and_writes--; in ForkParentAfter()
557 void ForkChildAfter(ThreadState *thr, uptr pc, in ForkChildAfter() argument
559 thr->suppress_reports--; // Enabled in ForkBefore. in ForkChildAfter()
560 thr->ignore_interceptors--; in ForkChildAfter()
561 thr->ignore_reads_and_writes--; in ForkChildAfter()
579 thr->ignore_interceptors++; in ForkChildAfter()
580 ThreadIgnoreBegin(thr, pc); in ForkChildAfter()
581 ThreadIgnoreSyncBegin(thr, pc); in ForkChildAfter()
588 void GrowShadowStack(ThreadState *thr) { in GrowShadowStack() argument
589 const int sz = thr->shadow_stack_end - thr->shadow_stack; in GrowShadowStack()
592 internal_memcpy(newstack, thr->shadow_stack, sz * sizeof(uptr)); in GrowShadowStack()
593 Free(thr->shadow_stack); in GrowShadowStack()
594 thr->shadow_stack = newstack; in GrowShadowStack()
595 thr->shadow_stack_pos = newstack + sz; in GrowShadowStack()
596 thr->shadow_stack_end = newstack + newsz; in GrowShadowStack()
600 StackID CurrentStackId(ThreadState *thr, uptr pc) { in CurrentStackId() argument
601 if (!thr->is_inited) // May happen during bootstrap. in CurrentStackId()
605 DCHECK_LT(thr->shadow_stack_pos, thr->shadow_stack_end); in CurrentStackId()
607 if (thr->shadow_stack_pos == thr->shadow_stack_end) in CurrentStackId()
608 GrowShadowStack(thr); in CurrentStackId()
610 thr->shadow_stack_pos[0] = pc; in CurrentStackId()
611 thr->shadow_stack_pos++; in CurrentStackId()
614 StackTrace(thr->shadow_stack, thr->shadow_stack_pos - thr->shadow_stack)); in CurrentStackId()
616 thr->shadow_stack_pos--; in CurrentStackId()
623 void TraceSwitchPart(ThreadState *thr) { in TraceSwitchPart() argument
624 Trace *trace = &thr->tctx->trace; in TraceSwitchPart()
625 Event *pos = reinterpret_cast<Event *>(atomic_load_relaxed(&thr->trace_pos)); in TraceSwitchPart()
643 atomic_store_relaxed(&thr->trace_pos, reinterpret_cast<uptr>(pos)); in TraceSwitchPart()
647 CHECK(TraceAcquire(thr, &ev)); in TraceSwitchPart()
657 atomic_store_relaxed(&thr->trace_pos, in TraceSwitchPart()
664 thr->trace_prev_pc = 0; in TraceSwitchPart()
668 atomic_store_relaxed(&thr->trace_pos, in TraceSwitchPart()
673 TraceTime(thr); in TraceSwitchPart()
674 for (uptr *pos = &thr->shadow_stack[0]; pos < thr->shadow_stack_pos; pos++) in TraceSwitchPart()
675 CHECK(TryTraceFunc(thr, *pos)); in TraceSwitchPart()
676 for (uptr i = 0; i < thr->mset.Size(); i++) { in TraceSwitchPart()
677 MutexSet::Desc d = thr->mset.Get(i); in TraceSwitchPart()
678 TraceMutexLock(thr, d.write ? EventType::kLock : EventType::kRLock, 0, in TraceSwitchPart()
685 void TraceSwitch(ThreadState *thr) { in TraceSwitch() argument
690 thr->nomalloc++; in TraceSwitch()
691 Trace *thr_trace = ThreadTrace(thr->tid); in TraceSwitch()
693 unsigned trace = (thr->fast_state.epoch() / kTracePartSize) % TraceParts(); in TraceSwitch()
695 hdr->epoch0 = thr->fast_state.epoch(); in TraceSwitch()
696 ObtainCurrentStack(thr, 0, &hdr->stack0); in TraceSwitch()
697 hdr->mset0 = thr->mset; in TraceSwitch()
698 thr->nomalloc--; in TraceSwitch()
703 uptr TraceTopPC(ThreadState *thr) { in TraceTopPC() argument
704 Event *events = (Event*)GetThreadTrace(thr->tid); in TraceTopPC()
705 uptr pc = events[thr->fast_state.GetTracePos()]; in TraceTopPC()
727 void ThreadIgnoreBegin(ThreadState *thr, uptr pc) { in ThreadIgnoreBegin() argument
728 DPrintf("#%d: ThreadIgnoreBegin\n", thr->tid); in ThreadIgnoreBegin()
729 thr->ignore_reads_and_writes++; in ThreadIgnoreBegin()
730 CHECK_GT(thr->ignore_reads_and_writes, 0); in ThreadIgnoreBegin()
731 thr->fast_state.SetIgnoreBit(); in ThreadIgnoreBegin()
734 thr->mop_ignore_set.Add(CurrentStackId(thr, pc)); in ThreadIgnoreBegin()
738 void ThreadIgnoreEnd(ThreadState *thr) { in ThreadIgnoreEnd() argument
739 DPrintf("#%d: ThreadIgnoreEnd\n", thr->tid); in ThreadIgnoreEnd()
740 CHECK_GT(thr->ignore_reads_and_writes, 0); in ThreadIgnoreEnd()
741 thr->ignore_reads_and_writes--; in ThreadIgnoreEnd()
742 if (thr->ignore_reads_and_writes == 0) { in ThreadIgnoreEnd()
743 thr->fast_state.ClearIgnoreBit(); in ThreadIgnoreEnd()
745 thr->mop_ignore_set.Reset(); in ThreadIgnoreEnd()
753 ThreadState *thr = cur_thread(); in __tsan_testonly_shadow_stack_current_size() local
754 return thr->shadow_stack_pos - thr->shadow_stack; in __tsan_testonly_shadow_stack_current_size()
758 void ThreadIgnoreSyncBegin(ThreadState *thr, uptr pc) { in ThreadIgnoreSyncBegin() argument
759 DPrintf("#%d: ThreadIgnoreSyncBegin\n", thr->tid); in ThreadIgnoreSyncBegin()
760 thr->ignore_sync++; in ThreadIgnoreSyncBegin()
761 CHECK_GT(thr->ignore_sync, 0); in ThreadIgnoreSyncBegin()
764 thr->sync_ignore_set.Add(CurrentStackId(thr, pc)); in ThreadIgnoreSyncBegin()
768 void ThreadIgnoreSyncEnd(ThreadState *thr) { in ThreadIgnoreSyncEnd() argument
769 DPrintf("#%d: ThreadIgnoreSyncEnd\n", thr->tid); in ThreadIgnoreSyncEnd()
770 CHECK_GT(thr->ignore_sync, 0); in ThreadIgnoreSyncEnd()
771 thr->ignore_sync--; in ThreadIgnoreSyncEnd()
773 if (thr->ignore_sync == 0) in ThreadIgnoreSyncEnd()
774 thr->sync_ignore_set.Reset(); in ThreadIgnoreSyncEnd()