Lines Matching refs:thr
24 ThreadContext::ThreadContext(Tid tid) : ThreadContextBase(tid), thr(), sync() {} in ThreadContext()
74 static void ThreadCheckIgnore(ThreadState *thr) { in ThreadCheckIgnore() argument
77 if (thr->ignore_reads_and_writes) in ThreadCheckIgnore()
78 ReportIgnoresEnabled(thr->tctx, &thr->mop_ignore_set); in ThreadCheckIgnore()
79 if (thr->ignore_sync) in ThreadCheckIgnore()
80 ReportIgnoresEnabled(thr->tctx, &thr->sync_ignore_set); in ThreadCheckIgnore()
83 static void ThreadCheckIgnore(ThreadState *thr) {} in ThreadCheckIgnore() argument
86 void ThreadFinalize(ThreadState *thr) { in ThreadFinalize() argument
87 ThreadCheckIgnore(thr); in ThreadFinalize()
89 if (!ShouldReport(thr, ReportTypeThreadLeak)) in ThreadFinalize()
99 OutputReport(thr, rep); in ThreadFinalize()
104 int ThreadCount(ThreadState *thr) { in ThreadCount() argument
116 Tid ThreadCreate(ThreadState *thr, uptr pc, uptr uid, bool detached) { in ThreadCreate() argument
120 if (thr) { in ThreadCreate()
121 parent = thr->tid; in ThreadCreate()
122 arg.stack = CurrentStackId(thr, pc); in ThreadCreate()
123 if (!thr->ignore_sync) { in ThreadCreate()
124 SlotLocker locker(thr); in ThreadCreate()
125 thr->clock.ReleaseStore(&arg.sync); in ThreadCreate()
127 IncrementEpoch(thr); in ThreadCreate()
145 ThreadState *thr; member
152 void ThreadStart(ThreadState *thr, Tid tid, tid_t os_id, in ThreadStart() argument
154 ctx->thread_registry.StartThread(tid, os_id, thread_type, thr); in ThreadStart()
155 if (!thr->ignore_sync) { in ThreadStart()
156 SlotAttachAndLock(thr); in ThreadStart()
157 if (thr->tctx->sync_epoch == ctx->global_epoch) in ThreadStart()
158 thr->clock.Acquire(thr->tctx->sync); in ThreadStart()
159 SlotUnlock(thr); in ThreadStart()
161 Free(thr->tctx->sync); in ThreadStart()
172 thr->stk_addr = stk_addr; in ThreadStart()
173 thr->stk_size = stk_size; in ThreadStart()
174 thr->tls_addr = tls_addr; in ThreadStart()
175 thr->tls_size = tls_size; in ThreadStart()
179 thr->ignore_interceptors++; in ThreadStart()
180 ThreadIgnoreBegin(thr, 0); in ThreadStart()
181 ThreadIgnoreSyncBegin(thr, 0); in ThreadStart()
193 MemoryRangeImitateWrite(thr, pc, stk_addr, stk_size); in ThreadStart()
197 ImitateTlsWrite(thr, tls_addr, tls_size); in ThreadStart()
203 thr = static_cast<ThreadState *>(arg); in OnStarted()
205 new (thr) ThreadState(tid); in OnStarted()
207 thr->dd_lt = ctx->dd->CreateLogicalThread(tid); in OnStarted()
208 thr->tctx = this; in OnStarted()
210 thr->is_inited = true; in OnStarted()
214 void ThreadFinish(ThreadState *thr) { in ThreadFinish() argument
215 DPrintf("#%d: ThreadFinish\n", thr->tid); in ThreadFinish()
216 ThreadCheckIgnore(thr); in ThreadFinish()
217 if (thr->stk_addr && thr->stk_size) in ThreadFinish()
218 DontNeedShadowFor(thr->stk_addr, thr->stk_size); in ThreadFinish()
219 if (thr->tls_addr && thr->tls_size) in ThreadFinish()
220 DontNeedShadowFor(thr->tls_addr, thr->tls_size); in ThreadFinish()
221 thr->is_dead = true; in ThreadFinish()
223 thr->is_inited = false; in ThreadFinish()
224 thr->ignore_interceptors++; in ThreadFinish()
225 PlatformCleanUpThreadState(thr); in ThreadFinish()
227 if (!thr->ignore_sync) { in ThreadFinish()
228 SlotLocker locker(thr); in ThreadFinish()
232 if (!thr->tctx->detached) { in ThreadFinish()
233 thr->clock.ReleaseStore(&thr->tctx->sync); in ThreadFinish()
234 thr->tctx->sync_epoch = ctx->global_epoch; in ThreadFinish()
235 IncrementEpoch(thr); in ThreadFinish()
239 UnmapOrDie(thr->shadow_stack, kShadowStackSize * sizeof(uptr)); in ThreadFinish()
241 Free(thr->shadow_stack); in ThreadFinish()
243 thr->shadow_stack = nullptr; in ThreadFinish()
244 thr->shadow_stack_pos = nullptr; in ThreadFinish()
245 thr->shadow_stack_end = nullptr; in ThreadFinish()
247 ctx->dd->DestroyLogicalThread(thr->dd_lt); in ThreadFinish()
248 SlotDetach(thr); in ThreadFinish()
249 ctx->thread_registry.FinishThread(thr->tid); in ThreadFinish()
250 thr->~ThreadState(); in ThreadFinish()
273 trace.final_pos = (Event *)atomic_load_relaxed(&thr->trace_pos); in OnFinished()
274 atomic_store_relaxed(&thr->trace_pos, 0); in OnFinished()
275 thr->tctx = nullptr; in OnFinished()
276 thr = nullptr; in OnFinished()
284 Tid ThreadConsumeTid(ThreadState *thr, uptr pc, uptr uid) { in ThreadConsumeTid() argument
293 void ThreadJoin(ThreadState *thr, uptr pc, Tid tid) { in ThreadJoin() argument
295 DPrintf("#%d: ThreadJoin tid=%d\n", thr->tid, tid); in ThreadJoin()
298 if (!thr->ignore_sync) { in ThreadJoin()
299 SlotLocker locker(thr); in ThreadJoin()
301 thr->clock.Acquire(arg.sync); in ThreadJoin()
316 void ThreadDetach(ThreadState *thr, uptr pc, Tid tid) { in ThreadDetach() argument
318 ctx->thread_registry.DetachThread(tid, thr); in ThreadDetach()
323 void ThreadNotJoined(ThreadState *thr, uptr pc, Tid tid, uptr uid) { in ThreadNotJoined() argument
328 void ThreadSetName(ThreadState *thr, const char *name) { in ThreadSetName() argument
329 ctx->thread_registry.SetThreadName(thr->tid, name); in ThreadSetName()
340 ThreadState *FiberCreate(ThreadState *thr, uptr pc, unsigned flags) { in FiberCreate() argument
344 Tid tid = ThreadCreate(thr, pc, 0, true); in FiberCreate()
345 FiberSwitchImpl(thr, fiber); in FiberCreate()
347 FiberSwitchImpl(fiber, thr); in FiberCreate()
351 void FiberDestroy(ThreadState *thr, uptr pc, ThreadState *fiber) { in FiberDestroy() argument
352 FiberSwitchImpl(thr, fiber); in FiberDestroy()
354 FiberSwitchImpl(fiber, thr); in FiberDestroy()
358 void FiberSwitch(ThreadState *thr, uptr pc, in FiberSwitch() argument
361 Release(thr, pc, (uptr)fiber); in FiberSwitch()
362 FiberSwitchImpl(thr, fiber); in FiberSwitch()