MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / getThreadState

Method getThreadState

src/wallClock.cpp:108–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106WallClock::Mode WallClock::_mode;
107
108ThreadState 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
129void WallClock::signalHandler(int signo, siginfo_t* siginfo, void* ucontext) {
130 if (_mode == WALL_BATCH) {

Callers

nothing calls this directly

Calls 2

findLibraryByAddressMethod · 0.80

Tested by

no test coverage detected