Lines Matching refs:thr

85   ThreadState *thr = cur_thread();  in ScopedGlobalProcessor()  local
86 if (thr->proc()) in ScopedGlobalProcessor()
103 ProcWire(gp->proc, thr); in ScopedGlobalProcessor()
108 ThreadState *thr = cur_thread(); in ~ScopedGlobalProcessor() local
109 if (thr->proc() != gp->proc) in ~ScopedGlobalProcessor()
111 ProcUnwire(gp->proc, thr); in ~ScopedGlobalProcessor()
157 static void SignalUnsafeCall(ThreadState *thr, uptr pc) { in SignalUnsafeCall() argument
158 if (atomic_load_relaxed(&thr->in_signal_handler) == 0 || in SignalUnsafeCall()
159 !ShouldReport(thr, ReportTypeSignalUnsafe)) in SignalUnsafeCall()
162 ObtainCurrentStack(thr, pc, &stack); in SignalUnsafeCall()
168 OutputReport(thr, rep); in SignalUnsafeCall()
172 void *user_alloc_internal(ThreadState *thr, uptr pc, uptr sz, uptr align, in user_alloc_internal() argument
180 GET_STACK_TRACE_FATAL(thr, pc); in user_alloc_internal()
186 GET_STACK_TRACE_FATAL(thr, pc); in user_alloc_internal()
189 void *p = allocator()->Allocate(&thr->proc()->alloc_cache, sz, align); in user_alloc_internal()
194 GET_STACK_TRACE_FATAL(thr, pc); in user_alloc_internal()
198 OnUserAlloc(thr, pc, (uptr)p, sz, true); in user_alloc_internal()
200 SignalUnsafeCall(thr, pc); in user_alloc_internal()
204 void user_free(ThreadState *thr, uptr pc, void *p, bool signal) { in user_free() argument
207 OnUserFree(thr, pc, (uptr)p, true); in user_free()
208 allocator()->Deallocate(&thr->proc()->alloc_cache, p); in user_free()
210 SignalUnsafeCall(thr, pc); in user_free()
213 void *user_alloc(ThreadState *thr, uptr pc, uptr sz) { in user_alloc() argument
214 return SetErrnoOnNull(user_alloc_internal(thr, pc, sz, kDefaultAlignment)); in user_alloc()
217 void *user_calloc(ThreadState *thr, uptr pc, uptr size, uptr n) { in user_calloc() argument
221 GET_STACK_TRACE_FATAL(thr, pc); in user_calloc()
224 void *p = user_alloc_internal(thr, pc, n * size); in user_calloc()
230 void *user_reallocarray(ThreadState *thr, uptr pc, void *p, uptr size, uptr n) { in user_reallocarray() argument
234 GET_STACK_TRACE_FATAL(thr, pc); in user_reallocarray()
237 return user_realloc(thr, pc, p, size * n); in user_reallocarray()
240 void OnUserAlloc(ThreadState *thr, uptr pc, uptr p, uptr sz, bool write) { in OnUserAlloc() argument
241 DPrintf("#%d: alloc(%zu) = 0x%zx\n", thr->tid, sz, p); in OnUserAlloc()
242 ctx->metamap.AllocBlock(thr, pc, p, sz); in OnUserAlloc()
243 if (write && thr->ignore_reads_and_writes == 0 && thr->is_inited) in OnUserAlloc()
244 MemoryRangeImitateWrite(thr, pc, (uptr)p, sz); in OnUserAlloc()
246 MemoryResetRange(thr, pc, (uptr)p, sz); in OnUserAlloc()
249 void OnUserFree(ThreadState *thr, uptr pc, uptr p, bool write) { in OnUserFree() argument
251 uptr sz = ctx->metamap.FreeBlock(thr->proc(), p); in OnUserFree()
252 DPrintf("#%d: free(0x%zx, %zu)\n", thr->tid, p, sz); in OnUserFree()
253 if (write && thr->ignore_reads_and_writes == 0 && thr->is_inited) in OnUserFree()
254 MemoryRangeFreed(thr, pc, (uptr)p, sz); in OnUserFree()
257 void *user_realloc(ThreadState *thr, uptr pc, void *p, uptr sz) { in user_realloc() argument
261 return SetErrnoOnNull(user_alloc_internal(thr, pc, sz)); in user_realloc()
263 user_free(thr, pc, p); in user_realloc()
266 void *new_p = user_alloc_internal(thr, pc, sz); in user_realloc()
270 user_free(thr, pc, p); in user_realloc()
275 void *user_memalign(ThreadState *thr, uptr pc, uptr align, uptr sz) { in user_memalign() argument
280 GET_STACK_TRACE_FATAL(thr, pc); in user_memalign()
283 return SetErrnoOnNull(user_alloc_internal(thr, pc, sz, align)); in user_memalign()
286 int user_posix_memalign(ThreadState *thr, uptr pc, void **memptr, uptr align, in user_posix_memalign() argument
291 GET_STACK_TRACE_FATAL(thr, pc); in user_posix_memalign()
294 void *ptr = user_alloc_internal(thr, pc, sz, align); in user_posix_memalign()
303 void *user_aligned_alloc(ThreadState *thr, uptr pc, uptr align, uptr sz) { in user_aligned_alloc() argument
308 GET_STACK_TRACE_FATAL(thr, pc); in user_aligned_alloc()
311 return SetErrnoOnNull(user_alloc_internal(thr, pc, sz, align)); in user_aligned_alloc()
314 void *user_valloc(ThreadState *thr, uptr pc, uptr sz) { in user_valloc() argument
315 return SetErrnoOnNull(user_alloc_internal(thr, pc, sz, GetPageSizeCached())); in user_valloc()
318 void *user_pvalloc(ThreadState *thr, uptr pc, uptr sz) { in user_pvalloc() argument
324 GET_STACK_TRACE_FATAL(thr, pc); in user_pvalloc()
329 return SetErrnoOnNull(user_alloc_internal(thr, pc, sz, PageSize)); in user_pvalloc()
344 ThreadState *thr = cur_thread(); in invoke_malloc_hook() local
345 if (ctx == 0 || !ctx->initialized || thr->ignore_interceptors) in invoke_malloc_hook()
351 ThreadState *thr = cur_thread(); in invoke_free_hook() local
352 if (ctx == 0 || !ctx->initialized || thr->ignore_interceptors) in invoke_free_hook()
358 ThreadState *thr = cur_thread(); in Alloc() local
359 if (thr->nomalloc) { in Alloc()
360 thr->nomalloc = 0; // CHECK calls internal_malloc(). in Alloc()
364 return InternalAlloc(sz, &thr->proc()->internal_alloc_cache); in Alloc()
368 ThreadState *thr = cur_thread(); in FreeImpl() local
369 if (thr->nomalloc) { in FreeImpl()
370 thr->nomalloc = 0; // CHECK calls internal_malloc(). in FreeImpl()
374 InternalFree(p, &thr->proc()->internal_alloc_cache); in FreeImpl()
415 ThreadState *thr = cur_thread(); in __tsan_on_thread_idle() local
416 thr->clock.ResetCached(&thr->proc()->clock_cache); in __tsan_on_thread_idle()
417 thr->last_sleep_clock.ResetCached(&thr->proc()->clock_cache); in __tsan_on_thread_idle()
418 allocator()->SwallowCache(&thr->proc()->alloc_cache); in __tsan_on_thread_idle()
419 internal_allocator()->SwallowCache(&thr->proc()->internal_alloc_cache); in __tsan_on_thread_idle()
420 ctx->metamap.OnProcIdle(thr->proc()); in __tsan_on_thread_idle()