Lines Matching refs:thr
25 : ThreadContextBase(tid), thr(), sync(), epoch0(), epoch1() {}
78 static void ThreadCheckIgnore(ThreadState *thr) {
81 if (thr->ignore_reads_and_writes)
82 ReportIgnoresEnabled(thr->tctx, &thr->mop_ignore_set);
83 if (thr->ignore_sync)
84 ReportIgnoresEnabled(thr->tctx, &thr->sync_ignore_set);
87 static void ThreadCheckIgnore(ThreadState *thr) {}
90 void ThreadFinalize(ThreadState *thr) {
91 ThreadCheckIgnore(thr);
93 if (!ShouldReport(thr, ReportTypeThreadLeak))
103 OutputReport(thr, rep);
108 int ThreadCount(ThreadState *thr) {
115 ThreadState *thr;
119 Tid ThreadCreate(ThreadState *thr, uptr pc, uptr uid, bool detached) {
120 OnCreatedArgs args = { thr, pc };
121 u32 parent_tid = thr ? thr->tid : kInvalidTid; // No parent for GCD workers.
128 thr = 0;
132 if (!args->thr) // GCD workers don't have a parent thread.
134 args->thr->fast_state.IncrementEpoch();
136 TraceAddEvent(args->thr, args->thr->fast_state, EventTypeMop, 0);
137 ReleaseImpl(args->thr, 0, &sync);
138 creation_stack_id = CurrentStackId(args->thr, args->pc);
144 ThreadState *thr;
151 void ThreadStart(ThreadState *thr, Tid tid, tid_t os_id,
164 OnStartedArgs args = { thr, stk_addr, stk_size, tls_addr, tls_size };
167 while (!thr->tctx->trace.parts.Empty()) thr->tctx->trace.parts.PopBack();
171 thr->ignore_interceptors++;
172 ThreadIgnoreBegin(thr, 0);
173 ThreadIgnoreSyncBegin(thr, 0);
185 MemoryRangeImitateWrite(thr, pc, stk_addr, stk_size);
189 ImitateTlsWrite(thr, tls_addr, tls_size);
196 thr = args->thr;
201 new (thr)
205 thr->dd_lt = ctx->dd->CreateLogicalThread(unique_id);
206 thr->fast_state.SetHistorySize(flags()->history_size);
209 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0);
211 thr->fast_synch_epoch = epoch0;
212 AcquireImpl(thr, 0, &sync);
213 sync.Reset(&thr->proc()->clock_cache);
214 thr->tctx = this;
215 thr->is_inited = true;
223 void ThreadFinish(ThreadState *thr) {
224 ThreadCheckIgnore(thr);
225 if (thr->stk_addr && thr->stk_size)
226 DontNeedShadowFor(thr->stk_addr, thr->stk_size);
227 if (thr->tls_addr && thr->tls_size)
228 DontNeedShadowFor(thr->tls_addr, thr->tls_size);
229 thr->is_dead = true;
230 ctx->thread_registry.FinishThread(thr->tid);
235 Free(thr->shadow_stack);
236 thr->shadow_stack_pos = nullptr;
237 thr->shadow_stack_end = nullptr;
240 thr->fast_state.IncrementEpoch();
242 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0);
243 ReleaseImpl(thr, 0, &sync);
245 epoch1 = thr->fast_state.epoch();
248 ctx->dd->DestroyLogicalThread(thr->dd_lt);
249 thr->clock.ResetCached(&thr->proc()->clock_cache);
251 thr->last_sleep_clock.ResetCached(&thr->proc()->clock_cache);
254 PlatformCleanUpThreadState(thr);
256 thr->~ThreadState();
257 thr = 0;
282 Tid ThreadConsumeTid(ThreadState *thr, uptr pc, uptr uid) {
286 DPrintf("#%d: ThreadTid uid=%zu tid=%d\n", thr->tid, uid, tid);
290 void ThreadJoin(ThreadState *thr, uptr pc, Tid tid) {
293 DPrintf("#%d: ThreadJoin tid=%d\n", thr->tid, tid);
294 ctx->thread_registry.JoinThread(tid, thr);
305 void ThreadDetach(ThreadState *thr, uptr pc, Tid tid) {
308 ctx->thread_registry.DetachThread(tid, thr);
316 void ThreadNotJoined(ThreadState *thr, uptr pc, Tid tid, uptr uid) {
322 void ThreadSetName(ThreadState *thr, const char *name) {
323 ctx->thread_registry.SetThreadName(thr->tid, name);
334 ThreadState *FiberCreate(ThreadState *thr, uptr pc, unsigned flags) {
338 Tid tid = ThreadCreate(thr, pc, 0, true);
339 FiberSwitchImpl(thr, fiber);
341 FiberSwitchImpl(fiber, thr);
345 void FiberDestroy(ThreadState *thr, uptr pc, ThreadState *fiber) {
346 FiberSwitchImpl(thr, fiber);
348 FiberSwitchImpl(fiber, thr);
352 void FiberSwitch(ThreadState *thr, uptr pc,
355 Release(thr, pc, (uptr)fiber);
356 FiberSwitchImpl(thr, fiber);