| 106 | WallClock::Mode WallClock::_mode; |
| 107 | |
| 108 | ThreadState WallClock::getThreadState(void* ucontext) { |
| 109 | StackFrame frame(ucontext); |
| 110 | uintptr_t pc = frame.pc(); |
| 111 | |
| 112 | // Consider a thread sleeping, if it has been interrupted in the middle of syscall execution, |
| 113 | // either when PC points to the syscall instruction, or if syscall has just returned with EINTR |
| 114 | if (StackFrame::isSyscall((instruction_t*)pc)) { |
| 115 | return THREAD_SLEEPING; |
| 116 | } |
| 117 | |
| 118 | // Make sure the previous instruction address is readable |
| 119 | uintptr_t prev_pc = pc - SYSCALL_SIZE; |
| 120 | if ((pc & 0xfff) >= SYSCALL_SIZE || Profiler::instance()->findLibraryByAddress((instruction_t*)prev_pc) != NULL) { |
| 121 | if (StackFrame::isSyscall((instruction_t*)prev_pc) && frame.checkInterruptedSyscall()) { |
| 122 | return THREAD_SLEEPING; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | return THREAD_RUNNING; |
| 127 | } |
| 128 | |
| 129 | void WallClock::signalHandler(int signo, siginfo_t* siginfo, void* ucontext) { |
| 130 | if (_mode == WALL_BATCH) { |
nothing calls this directly
no test coverage detected