ThreadStackTarget
The frames of another thread's stack, read while it runs.
In the namespace platform::diagnostics. Declared in src/libs/libplatform/platform/ThreadStack.hpp.
Detailed description
A watchdog that sees a thread stop answering wants to know where that thread is. ThreadStackTarget names a thread: make it on that thread with currentThread(), then call capture() from any other thread.
Windows: the thread is suspended, walked with dbghelp's StackWalk64 and resumed. Each frame is the module, the offset in it, and the symbol when dbghelp has one.
POSIX: the thread gets a real-time signal (SIGUSR2 where the system has no real-time signals), and the handler records the return addresses with backtrace() into a static array. capture() waits for the handler at most waitMs, then names each frame outside the handler with dladdr() and abi::__cxa_demangle(). A function that the module does not export has no name there: the frame keeps its module and offset, which `llvm-symbolizer –obj=<module> <offset>` or `addr2line -f -C -e <module> <offset>` resolves. Linux sends the signal with tgkill() to the thread's kernel id, so a thread that has ended gives "(the thread has ended)", never a signal to another thread. Android has no backtrace() before API level 33, so capture() says it cannot.
One capture runs at a time in the process; a second caller waits.
The text has one line per frame, ` #<n> <module>+0x<offset> <symbol>`, as GuiHeartbeat's stall report printed it before the sampler moved here.