Home | History | Annotate | Download | only in rtl

Lines Matching defs:thr

147 static SignalContext *SigCtx(ThreadState *thr) {
148 SignalContext *ctx = (SignalContext*)thr->signal_ctx;
149 if (ctx == 0 && thr->is_alive) {
151 MemoryResetRange(thr, (uptr)&SigCtx, (uptr)ctx, sizeof(*ctx));
152 thr->signal_ctx = ctx;
161 ScopedInterceptor(ThreadState *thr, const char *fname, uptr pc);
169 ScopedInterceptor::ScopedInterceptor(ThreadState *thr, const char *fname,
171 : thr_(thr)
175 Initialize(thr);
176 FuncEntry(thr, pc);
199 ThreadState *thr = cur_thread(); \
201 ScopedInterceptor si(thr, #func, caller_pc); \
212 if (thr->ignore_interceptors || thr->in_ignored_lib) \
220 #define BLOCK_REAL(name) (BlockingCall(thr), REAL(name))
223 explicit BlockingCall(ThreadState *thr)
224 : ctx(SigCtx(thr)) {
245 AfterSleep(thr, pc);
252 AfterSleep(thr, pc);
259 AfterSleep(thr, pc);
272 int atexit(ThreadState *thr, uptr pc, bool is_on_exit,
277 Release(thr, pc, (uptr)this);
285 void exit(ThreadState *thr, uptr pc) {
297 Acquire(thr, pc, (uptr)this);
302 DPrintf("#%d: executing atexit func %p\n", thr->tid, f);
327 return atexit_ctx->atexit(thr, pc, false, (void(*)())f, 0);
334 return atexit_ctx->atexit(thr, pc, true, (void(*)())f, arg);
344 ThreadIgnoreBegin(thr, pc);
346 ThreadIgnoreEnd(thr, pc);
349 return atexit_ctx->atexit(thr, pc, false, (void(*)())f, arg);
353 static void JmpBufGarbageCollect(ThreadState *thr, uptr sp) {
354 for (uptr i = 0; i < thr->jmp_bufs.Size(); i++) {
355 JmpBuf *buf = &thr->jmp_bufs[i];
357 uptr sz = thr->jmp_bufs.Size();
358 thr->jmp_bufs[i] = thr->jmp_bufs[sz - 1];
359 thr->jmp_bufs.PopBack();
365 static void SetJmp(ThreadState *thr, uptr sp, uptr mangled_sp) {
366 if (thr->shadow_stack_pos == 0) // called from libc guts during bootstrap
369 JmpBufGarbageCollect(thr, sp);
371 JmpBuf *buf = thr->jmp_bufs.PushBack();
374 buf->shadow_stack_pos = thr->shadow_stack_pos;
377 static void LongJmp(ThreadState *thr, uptr *env) {
380 for (uptr i = 0; i < thr->jmp_bufs.Size(); i++) {
381 JmpBuf *buf = &thr->jmp_bufs[i];
383 CHECK_GE(thr->shadow_stack_pos, buf->shadow_stack_pos);
385 while (thr->shadow_stack_pos > buf->shadow_stack_pos)
386 FuncExit(thr);
387 JmpBufGarbageCollect(thr, buf->sp - 1); // do not collect buf->sp
461 p = user_alloc(thr, pc, size);
469 return user_alloc(thr, pc, sz, align);
480 p = user_alloc(thr, pc, n * size);
495 p = user_realloc(thr, pc, p, size);
508 user_free(thr, pc, p);
518 user_free(thr, pc, p);
532 p = user_alloc(thr, pc, size); \
567 user_free(thr, pc, ptr);
596 MemoryAccessRange(thr, pc, (uptr)s, len + 1, false);
602 MemoryAccessRange(thr, pc, (uptr)dst, size, true);
608 MemoryAccessRange(thr, pc, (uptr)dst, size, true);
609 MemoryAccessRange(thr, pc, (uptr)src, size, false);
621 MemoryAccessRange(thr, pc, (uptr)s1, len < n ? len + 1 : n, false);
622 MemoryAccessRange(thr, pc, (uptr)s2, len < n ? len + 1 : n, false);
628 MemoryAccessRange(thr, pc, (uptr)dst, n, true);
629 MemoryAccessRange(thr, pc, (uptr)src, n, false);
637 MemoryAccessRange(thr, pc, (uptr)s, len, false);
645 MemoryAccessRange(thr, pc, (uptr)s, len, false);
651 MemoryAccessRange(thr, pc, (uptr)s, internal_strlen(s) + 1, false);
658 MemoryAccessRange(thr, pc, (uptr)dst, srclen + 1, true);
659 MemoryAccessRange(thr, pc, (uptr)src, srclen + 1, false);
666 MemoryAccessRange(thr, pc, (uptr)dst, n, true);
667 MemoryAccessRange(thr, pc, (uptr)src, min(srclen + 1, n), false);
676 MemoryAccessRange(thr, pc, (uptr)s1, len1 + 1, false);
677 MemoryAccessRange(thr, pc, (uptr)s2, len2 + 1, false);
709 FdAccess(thr, pc, fd);
710 MemoryRangeImitateWrite(thr, pc, (uptr)res, sz);
723 FdAccess(thr, pc, fd);
724 MemoryRangeImitateWrite(thr, pc, (uptr)res, sz);
738 return user_alloc(thr, pc, sz, align);
743 return user_alloc(thr, pc, sz, align);
748 return user_alloc(thr, pc, sz, GetPageSizeCached());
754 return user_alloc(thr, pc, sz, GetPageSizeCached());
759 *memptr = user_alloc(thr, pc, sz, align);
772 Acquire(thr, pc, (uptr)g);
782 Release(thr, pc, (uptr)g);
801 ThreadState *thr = cur_thread();
802 ThreadFinish(thr);
803 SignalContext *sctx = thr->signal_ctx;
805 thr->signal_ctx = 0;
824 ThreadState *thr = cur_thread();
835 ThreadStart(thr, tid, GetTid());
876 ThreadIgnoreBegin(thr, pc);
878 ThreadIgnoreEnd(thr, pc);
881 int tid = ThreadCreate(thr, pc, *(uptr*)th, detached);
894 int tid = ThreadTid(thr, pc, (uptr)th);
895 ThreadIgnoreBegin(thr, pc);
897 ThreadIgnoreEnd(thr, pc);
899 ThreadJoin(thr, pc, tid);
906 int tid = ThreadTid(thr, pc, (uptr)th);
909 ThreadDetach(thr, pc, tid);
953 ThreadState *thr;
959 MutexLock(arg->thr, arg->pc, (uptr)arg->m);
965 MemoryAccessRange(thr, pc, (uptr)c, sizeof(uptr), true);
972 MutexUnlock(thr, pc, (uptr)m);
973 MemoryAccessRange(thr, pc, (uptr)c, sizeof(uptr), false);
974 CondMutexUnlockCtx arg = {thr, pc, m};
981 MutexRepair(thr, pc, (uptr)m);
982 MutexLock(thr, pc, (uptr)m);
989 MutexUnlock(thr, pc, (uptr)m);
990 MemoryAccessRange(thr, pc, (uptr)c, sizeof(uptr), false);
991 CondMutexUnlockCtx arg = {thr, pc, m};
998 MutexRepair(thr, pc, (uptr)m);
999 MutexLock(thr, pc, (uptr)m);
1006 MemoryAccessRange(thr, pc, (uptr)c, sizeof(uptr), false);
1013 MemoryAccessRange(thr, pc, (uptr)c, sizeof(uptr), false);
1020 MemoryAccessRange(thr, pc, (uptr)c, sizeof(uptr), true);
1041 MutexCreate(thr, pc, (uptr)m, false, recursive, false);
1050 MutexDestroy(thr, pc, (uptr)m);
1059 MutexRepair(thr, pc, (uptr)m);
1061 MutexLock(thr, pc, (uptr)m, /*rec=*/1, /*try_lock=*/true);
1069 MutexLock(thr, pc, (uptr)m);
1078 MutexCreate(thr, pc, (uptr)m, false, false, false);
1087 MutexDestroy(thr, pc, (uptr)m);
1096 MutexLock(thr, pc, (uptr)m);
1105 MutexLock(thr, pc, (uptr)m, /*rec=*/1, /*try_lock=*/true);
1112 MutexUnlock(thr, pc, (uptr)m);
1121 MutexCreate(thr, pc, (uptr)m, true, false, false);
1130 MutexDestroy(thr, pc, (uptr)m);
1139 MutexReadLock(thr, pc, (uptr)m);
1148 MutexReadLock(thr, pc, (uptr)m, /*try_lock=*/true);
1157 MutexReadLock(thr, pc, (uptr)m);
1166 MutexLock(thr, pc, (uptr)m);
1175 MutexLock(thr, pc, (uptr)m, /*rec=*/1, /*try_lock=*/true);
1184 MutexLock(thr, pc, (uptr)m);
1191 MutexReadOrWriteUnlock(thr, pc, (uptr)m);
1198 MemoryWrite(thr, pc, (uptr)b, kSizeLog1);
1205 MemoryWrite(thr, pc, (uptr)b, kSizeLog1);
1212 Release(thr, pc, (uptr)b);
1213 MemoryRead(thr, pc, (uptr)b, kSizeLog1);
1215 MemoryRead(thr, pc, (uptr)b, kSizeLog1);
1217 Acquire(thr, pc, (uptr)b);
1231 if (!thr->in_ignored_lib)
1232 Release(thr, pc, (uptr)o);
1239 if (!thr->in_ignored_lib)
1240 Acquire(thr, pc, (uptr)o);
1261 Acquire(thr, pc, (uptr)s);
1270 Acquire(thr, pc, (uptr)s);
1279 Acquire(thr, pc, (uptr)s);
1286 Release(thr, pc, (uptr)s);
1295 Acquire(thr, pc, (uptr)s);
1343 FdAccess(thr, pc, fd);
1350 FdAccess(thr, pc, fd);
1357 FdAccess(thr, pc, fd);
1364 FdAccess(thr, pc, fd);
1372 FdFileCreate(thr, pc, fd);
1380 FdFileCreate(thr, pc, fd);
1388 FdFileCreate(thr, pc, fd);
1396 FdFileCreate(thr, pc, fd);
1404 FdDup(thr, pc, oldfd, newfd);
1412 FdDup(thr, pc, oldfd, newfd2);
1420 FdDup(thr, pc, oldfd, newfd2);
1428 FdEventCreate(thr, pc, fd);
1435 FdClose(thr, pc, fd);
1438 FdSignalCreate(thr, pc, fd);
1446 FdInotifyCreate(thr, pc, fd);
1454 FdInotifyCreate(thr, pc, fd);
1462 FdSocketCreate(thr, pc, fd);
1470 FdPipeCreate(thr, pc, fd[0], fd[1]);
1476 FdSocketConnecting(thr, pc, fd);
1479 FdSocketConnect(thr, pc, fd);
1487 FdAccess(thr, pc, fd);
1495 FdAccess(thr, pc, fd);
1503 FdPollCreate(thr, pc, fd);
1511 FdPollCreate(thr, pc, fd);
1518 FdClose(thr, pc, fd);
1525 FdClose(thr, pc, fd);
1536 FdClose(thr, pc, fds[i]);
1545 FdPipeCreate(thr, pc, pipefd[0], pipefd[1]);
1553 FdPipeCreate(thr, pc, pipefd[0], pipefd[1]);
1560 FdAccess(thr, pc, fd);
1561 FdRelease(thr, pc, fd);
1570 FdAccess(thr, pc, fd);
1571 FdRelease(thr, pc, fd);
1580 FdAccess(thr, pc, fd);
1583 FdAcquire(thr, pc, fd);
1590 Release(thr, pc, File2addr(path));
1601 FdFileCreate(thr, pc, fd);
1612 FdFileCreate(thr, pc, fd);
1621 MemoryAccessRange(thr, pc, (uptr)ptr, size * nmemb, true);
1630 MemoryAccessRange(thr, pc, (uptr)p, size * nmemb, false);
1643 MemoryAccessRange(thr, pc, (uptr)s, internal_strlen(s), false);
1649 Release(thr, pc, Dir2addr(path));
1658 Acquire(thr
1665 FdAccess(thr, pc, epfd);
1667 FdAccess(thr, pc, fd);
1669 FdRelease(thr, pc, epfd);
1677 FdAccess(thr, pc, epfd);
1680 FdAcquire(thr, pc, epfd);
1686 static void CallUserSignalHandler(ThreadState *thr, bool sync, bool sigact,
1709 stack.ObtainCurrent(thr, pc);
1714 OutputReport(thr, rep);
1720 void ProcessPendingSignals(ThreadState *thr) {
1721 SignalContext *sctx = SigCtx(thr);
1722 if (sctx == 0 || sctx->pending_signal_count == 0 || thr->in_signal_handler)
1724 thr->in_signal_handler = true;
1736 CallUserSignalHandler(thr, false, signal->sigaction,
1742 CHECK_EQ(thr->in_signal_handler, true);
1743 thr->in_signal_handler = false;
1757 ThreadState *thr = cur_thread();
1758 SignalContext *sctx = SigCtx(thr);
1770 CHECK_EQ(thr->in_signal_handler, false);
1771 thr->in_signal_handler = true;
1775 int const i = thr->ignore_interceptors;
1776 thr->ignore_interceptors = 0;
1777 CallUserSignalHandler(thr, sync, sigact, sig, info, ctx);
1778 thr->ignore_interceptors = i;
1780 CallUserSignalHandler(thr, sync, sigact, sig, info, ctx);
1782 CHECK_EQ(thr->in_signal_handler, true);
1783 thr->in_signal_handler = false;
1848 SignalContext *sctx = SigCtx(thr);
1860 SignalContext *sctx = SigCtx(thr);
1876 SignalContext *sctx = SigCtx(thr);
1902 ThreadIgnoreBegin(thr, pc);
1904 ThreadIgnoreEnd(thr, pc);
1941 ForkBefore(thr, pc);
1945 ForkChildAfter(thr, pc);
1946 FdOnFork(thr, pc);
1949 ForkParentAfter(thr, pc);
1952 ForkParentAfter(thr, pc);
1974 static int OnExit(ThreadState *thr) {
1975 int status = Finalize(thr);
1981 ThreadState *thr;
1986 static void HandleRecvmsg(ThreadState *thr, uptr pc,
1991 FdEventCreate(thr, pc, fds[i]);
2001 MemoryAccessRange(((TsanInterceptorContext *)ctx)->thr, \
2006 MemoryAccessRange(((TsanInterceptorContext *) ctx)->thr, \
2012 TsanInterceptorContext _ctx = {thr, caller_pc, pc}; \
2018 TsanInterceptorContext _ctx = {thr, caller_pc, pc}; \
2023 Acquire(thr, pc, File2addr(path)); \
2026 if (fd >= 0) FdFileCreate(thr, pc, fd); \
2032 if (fd >= 0) FdClose(thr, pc, fd); \
2042 FdAcquire(((TsanInterceptorContext *) ctx)->thr, pc, fd)
2045 FdRelease(((TsanInterceptorContext *) ctx)->thr, pc, fd)
2048 FdAccess(((TsanInterceptorContext *) ctx)->thr, pc, fd)
2051 FdSocketAccept(((TsanInterceptorContext *) ctx)->thr, pc, fd, newfd)
2054 ThreadSetName(((TsanInterceptorContext *) ctx)->thr, name)
2062 OnExit(((TsanInterceptorContext *) ctx)->thr)
2065 MutexLock(((TsanInterceptorContext *)ctx)->thr, \
2069 MutexUnlock(((TsanInterceptorContext *)ctx)->thr, \
2073 MutexRepair(((TsanInterceptorContext *)ctx)->thr, \
2077 HandleRecvmsg(((TsanInterceptorContext *)ctx)->thr, \
2083 ThreadState *thr = cur_thread(); \
2084 if (thr->ignore_interceptors) \
2086 ScopedSyscall scoped_syscall(thr) \
2090 ThreadState *thr;
2092 explicit ScopedSyscall(ThreadState *thr)
2093 : thr(thr) {
2094 Initialize(thr);
2098 ProcessPendingSignals(thr);
2104 MemoryAccessRange(thr, pc, p, s, write);
2109 Acquire(thr, pc, addr);
2116 Release(thr, pc, addr);
2121 FdClose(thr, pc, fd);
2126 FdAcquire(thr, pc, fd);
2133 FdRelease(thr, pc, fd);
2138 ForkBefore(thr, pc);
2145 ForkChildAfter(thr, pc);
2146 FdOnFork(thr, pc);
2149 ForkParentAfter(thr, pc);
2152 ForkParentAfter(thr, pc);
2197 ThreadState *thr = cur_thread();
2199 atexit_ctx->exit(thr, pc);
2200 int status = Finalize(thr);