Lines Matching refs:thr
25 : ThreadContextBase(tid), thr(), sync(), epoch0(), epoch1() {} in ThreadContext()
78 static void ThreadCheckIgnore(ThreadState *thr) { in ThreadCheckIgnore() argument
81 if (thr->ignore_reads_and_writes) in ThreadCheckIgnore()
82 ReportIgnoresEnabled(thr->tctx, &thr->mop_ignore_set); in ThreadCheckIgnore()
83 if (thr->ignore_sync) in ThreadCheckIgnore()
84 ReportIgnoresEnabled(thr->tctx, &thr->sync_ignore_set); in ThreadCheckIgnore()
87 static void ThreadCheckIgnore(ThreadState *thr) {} in ThreadCheckIgnore() argument
90 void ThreadFinalize(ThreadState *thr) { in ThreadFinalize() argument
91 ThreadCheckIgnore(thr); in ThreadFinalize()
93 if (!ShouldReport(thr, ReportTypeThreadLeak)) in ThreadFinalize()
103 OutputReport(thr, rep); in ThreadFinalize()
108 int ThreadCount(ThreadState *thr) { in ThreadCount() argument
115 ThreadState *thr; member
119 Tid ThreadCreate(ThreadState *thr, uptr pc, uptr uid, bool detached) { in ThreadCreate() argument
120 OnCreatedArgs args = { thr, pc }; in ThreadCreate()
121 u32 parent_tid = thr ? thr->tid : kInvalidTid; // No parent for GCD workers. in ThreadCreate()
128 thr = 0; in OnCreated()
132 if (!args->thr) // GCD workers don't have a parent thread. in OnCreated()
134 args->thr->fast_state.IncrementEpoch(); in OnCreated()
136 TraceAddEvent(args->thr, args->thr->fast_state, EventTypeMop, 0); in OnCreated()
137 ReleaseImpl(args->thr, 0, &sync); in OnCreated()
138 creation_stack_id = CurrentStackId(args->thr, args->pc); in OnCreated()
144 ThreadState *thr; member
151 void ThreadStart(ThreadState *thr, Tid tid, tid_t os_id, in ThreadStart() argument
164 OnStartedArgs args = { thr, stk_addr, stk_size, tls_addr, tls_size }; in ThreadStart()
167 while (!thr->tctx->trace.parts.Empty()) thr->tctx->trace.parts.PopBack(); in ThreadStart()
171 thr->ignore_interceptors++; in ThreadStart()
172 ThreadIgnoreBegin(thr, 0); in ThreadStart()
173 ThreadIgnoreSyncBegin(thr, 0); in ThreadStart()
185 MemoryRangeImitateWrite(thr, pc, stk_addr, stk_size); in ThreadStart()
189 ImitateTlsWrite(thr, tls_addr, tls_size); in ThreadStart()
196 thr = args->thr; in OnStarted()
201 new (thr) in OnStarted()
205 thr->dd_lt = ctx->dd->CreateLogicalThread(unique_id); in OnStarted()
206 thr->fast_state.SetHistorySize(flags()->history_size); in OnStarted()
209 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0); in OnStarted()
211 thr->fast_synch_epoch = epoch0; in OnStarted()
212 AcquireImpl(thr, 0, &sync); in OnStarted()
213 sync.Reset(&thr->proc()->clock_cache); in OnStarted()
214 thr->tctx = this; in OnStarted()
215 thr->is_inited = true; in OnStarted()
223 void ThreadFinish(ThreadState *thr) { in ThreadFinish() argument
224 ThreadCheckIgnore(thr); in ThreadFinish()
225 if (thr->stk_addr && thr->stk_size) in ThreadFinish()
226 DontNeedShadowFor(thr->stk_addr, thr->stk_size); in ThreadFinish()
227 if (thr->tls_addr && thr->tls_size) in ThreadFinish()
228 DontNeedShadowFor(thr->tls_addr, thr->tls_size); in ThreadFinish()
229 thr->is_dead = true; in ThreadFinish()
230 thr->is_inited = false; in ThreadFinish()
232 thr->ignore_interceptors++; in ThreadFinish()
234 ctx->thread_registry.FinishThread(thr->tid); in ThreadFinish()
239 thr->fast_state.IncrementEpoch(); in OnFinished()
241 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0); in OnFinished()
242 ReleaseImpl(thr, 0, &sync); in OnFinished()
244 epoch1 = thr->fast_state.epoch(); in OnFinished()
247 UnmapOrDie(thr->shadow_stack, kShadowStackSize * sizeof(uptr)); in OnFinished()
249 Free(thr->shadow_stack); in OnFinished()
251 thr->shadow_stack = nullptr; in OnFinished()
252 thr->shadow_stack_pos = nullptr; in OnFinished()
253 thr->shadow_stack_end = nullptr; in OnFinished()
256 ctx->dd->DestroyLogicalThread(thr->dd_lt); in OnFinished()
257 thr->clock.ResetCached(&thr->proc()->clock_cache); in OnFinished()
259 thr->last_sleep_clock.ResetCached(&thr->proc()->clock_cache); in OnFinished()
262 PlatformCleanUpThreadState(thr); in OnFinished()
264 thr->~ThreadState(); in OnFinished()
265 thr = 0; in OnFinished()
273 Tid ThreadConsumeTid(ThreadState *thr, uptr pc, uptr uid) { in ThreadConsumeTid() argument
277 void ThreadJoin(ThreadState *thr, uptr pc, Tid tid) { in ThreadJoin() argument
280 DPrintf("#%d: ThreadJoin tid=%d\n", thr->tid, tid); in ThreadJoin()
281 ctx->thread_registry.JoinThread(tid, thr); in ThreadJoin()
292 void ThreadDetach(ThreadState *thr, uptr pc, Tid tid) { in ThreadDetach() argument
295 ctx->thread_registry.DetachThread(tid, thr); in ThreadDetach()
303 void ThreadNotJoined(ThreadState *thr, uptr pc, Tid tid, uptr uid) { in ThreadNotJoined() argument
309 void ThreadSetName(ThreadState *thr, const char *name) { in ThreadSetName() argument
310 ctx->thread_registry.SetThreadName(thr->tid, name); in ThreadSetName()
321 ThreadState *FiberCreate(ThreadState *thr, uptr pc, unsigned flags) { in FiberCreate() argument
325 Tid tid = ThreadCreate(thr, pc, 0, true); in FiberCreate()
326 FiberSwitchImpl(thr, fiber); in FiberCreate()
328 FiberSwitchImpl(fiber, thr); in FiberCreate()
332 void FiberDestroy(ThreadState *thr, uptr pc, ThreadState *fiber) { in FiberDestroy() argument
333 FiberSwitchImpl(thr, fiber); in FiberDestroy()
335 FiberSwitchImpl(fiber, thr); in FiberDestroy()
339 void FiberSwitch(ThreadState *thr, uptr pc, in FiberSwitch() argument
342 Release(thr, pc, (uptr)fiber); in FiberSwitch()
343 FiberSwitchImpl(thr, fiber); in FiberSwitch()