Lines Matching refs:tid

71 static bool pid_contains_tid(int pid_proc_fd, pid_t tid) {  in pid_contains_tid()  argument
73 std::string task_path = StringPrintf("task/%d", tid); in pid_contains_tid()
87 static bool ptrace_seize_thread(int pid_proc_fd, pid_t tid, std::string* error, int flags = 0) { in ptrace_seize_thread() argument
88 if (ptrace(PTRACE_SEIZE, tid, 0, flags) != 0) { in ptrace_seize_thread()
91 pid_t tracer_pid = get_tracer(tid); in ptrace_seize_thread()
93 *error = StringPrintf("failed to attach to thread %d, already traced by %d (%s)", tid, in ptrace_seize_thread()
99 *error = StringPrintf("failed to attach to thread %d: %s", tid, strerror(errno)); in ptrace_seize_thread()
104 if (!pid_contains_tid(pid_proc_fd, tid)) { in ptrace_seize_thread()
105 if (ptrace(PTRACE_DETACH, tid, 0, 0) != 0) { in ptrace_seize_thread()
106 PLOG(WARNING) << "failed to detach from thread " << tid; in ptrace_seize_thread()
108 *error = StringPrintf("thread %d is not in process", tid); in ptrace_seize_thread()
115 static bool wait_for_stop(pid_t tid, int* received_signal) { in wait_for_stop() argument
118 pid_t result = waitpid(tid, &status, __WALL); in wait_for_stop()
119 if (result != tid) { in wait_for_stop()
120 PLOG(ERROR) << "waitpid failed on " << tid << " while detaching"; in wait_for_stop()
136 static bool ptrace_interrupt(pid_t tid, int* received_signal) { in ptrace_interrupt() argument
137 if (ptrace(PTRACE_INTERRUPT, tid, 0, 0) == 0) { in ptrace_interrupt()
138 return wait_for_stop(tid, received_signal); in ptrace_interrupt()
141 PLOG(ERROR) << "failed to interrupt " << tid << " to detach"; in ptrace_interrupt()
505 info.tid = thread; in main()
585 for (const auto& [tid, thread] : thread_info) { in main()
589 if (tgkill(target_process, tid, SIGSTOP) != 0) { in main()
590 PLOG(WARNING) << "failed to send SIGSTOP to " << tid; in main()
594 LOG(DEBUG) << "detaching from thread " << tid; in main()
595 if (ptrace(PTRACE_DETACH, tid, 0, resume_signal) != 0) { in main()
596 PLOG(ERROR) << "failed to detach from thread " << tid; in main()