Lines Matching defs:thr

24 ThreadContext::ThreadContext(Tid tid) : ThreadContextBase(tid), thr(), sync() {}
74 static void ThreadCheckIgnore(ThreadState *thr) {
77 if (thr->ignore_reads_and_writes)
78 ReportIgnoresEnabled(thr->tctx, &thr->mop_ignore_set);
79 if (thr->ignore_sync)
80 ReportIgnoresEnabled(thr->tctx, &thr->sync_ignore_set);
83 static void ThreadCheckIgnore(ThreadState *thr) {}
86 void ThreadFinalize(ThreadState *thr) {
87 ThreadCheckIgnore(thr);
89 if (!ShouldReport(thr, ReportTypeThreadLeak))
99 OutputReport(thr, rep);
104 int ThreadCount(ThreadState *thr) {
116 Tid ThreadCreate(ThreadState *thr, uptr pc, uptr uid, bool detached) {
120 if (thr) {
121 parent = thr->tid;
122 arg.stack = CurrentStackId(thr, pc);
123 if (!thr->ignore_sync) {
124 SlotLocker locker(thr);
125 thr->clock.ReleaseStore(&arg.sync);
127 IncrementEpoch(thr);
145 ThreadState *thr;
152 void ThreadStart(ThreadState *thr, Tid tid, tid_t os_id,
154 ctx->thread_registry.StartThread(tid, os_id, thread_type, thr);
155 if (!thr->ignore_sync) {
156 SlotAttachAndLock(thr);
157 if (thr->tctx->sync_epoch == ctx->global_epoch)
158 thr->clock.Acquire(thr->tctx->sync);
159 SlotUnlock(thr);
161 Free(thr->tctx->sync);
164 thr->is_inited = true;
178 thr->stk_addr = stk_addr;
179 thr->stk_size = stk_size;
180 thr->tls_addr = tls_addr;
181 thr->tls_size = tls_size;
185 thr->ignore_interceptors++;
186 ThreadIgnoreBegin(thr, 0);
187 ThreadIgnoreSyncBegin(thr, 0);
199 MemoryRangeImitateWrite(thr, pc, stk_addr, stk_size);
203 ImitateTlsWrite(thr, tls_addr, tls_size);
210 thr = new (arg) ThreadState(tid);
212 thr->dd_lt = ctx->dd->CreateLogicalThread(tid);
213 thr->tctx = this;
216 void ThreadFinish(ThreadState *thr) {
217 DPrintf("#%d: ThreadFinish\n", thr->tid);
218 ThreadCheckIgnore(thr);
219 if (thr->stk_addr && thr->stk_size)
220 DontNeedShadowFor(thr->stk_addr, thr->stk_size);
221 if (thr->tls_addr && thr->tls_size)
222 DontNeedShadowFor(thr->tls_addr, thr->tls_size);
223 thr->is_dead = true;
225 thr->is_inited = false;
226 thr->ignore_interceptors++;
227 PlatformCleanUpThreadState(thr);
229 if (!thr->ignore_sync) {
230 SlotLocker locker(thr);
234 if (!thr->tctx->detached) {
235 thr->clock.ReleaseStore(&thr->tctx->sync);
236 thr->tctx->sync_epoch = ctx->global_epoch;
237 IncrementEpoch(thr);
241 UnmapOrDie(thr->shadow_stack, kShadowStackSize * sizeof(uptr));
243 Free(thr->shadow_stack);
245 thr->shadow_stack = nullptr;
246 thr->shadow_stack_pos = nullptr;
247 thr->shadow_stack_end = nullptr;
249 ctx->dd->DestroyLogicalThread(thr->dd_lt);
250 SlotDetach(thr);
251 ctx->thread_registry.FinishThread(thr->tid);
252 thr->~ThreadState();
275 trace.final_pos = (Event *)atomic_load_relaxed(&thr->trace_pos);
276 atomic_store_relaxed(&thr->trace_pos, 0);
277 thr->tctx = nullptr;
278 thr = nullptr;
286 Tid ThreadConsumeTid(ThreadState *thr, uptr pc, uptr uid) {
295 void ThreadJoin(ThreadState *thr, uptr pc, Tid tid) {
297 DPrintf("#%d: ThreadJoin tid=%d\n", thr->tid, tid);
300 if (!thr->ignore_sync) {
301 SlotLocker locker(thr);
303 thr->clock.Acquire(arg.sync);
318 void ThreadDetach(ThreadState *thr, uptr pc, Tid tid) {
320 ctx->thread_registry.DetachThread(tid, thr);
325 void ThreadNotJoined(ThreadState *thr, uptr pc, Tid tid, uptr uid) {
330 void ThreadSetName(ThreadState *thr, const char *name) {
331 ctx->thread_registry.SetThreadName(thr->tid, name);
342 ThreadState *FiberCreate(ThreadState *thr, uptr pc, unsigned flags) {
346 Tid tid = ThreadCreate(thr, pc, 0, true);
347 FiberSwitchImpl(thr, fiber);
349 FiberSwitchImpl(fiber, thr);
353 void FiberDestroy(ThreadState *thr, uptr pc, ThreadState *fiber) {
354 FiberSwitchImpl(thr, fiber);
356 FiberSwitchImpl(fiber, thr);
360 void FiberSwitch(ThreadState *thr, uptr pc,
363 Release(thr, pc, (uptr)fiber);
364 FiberSwitchImpl(thr, fiber);