Skip to content

Is it possible to get stack trace for a specified thread? #135

Answered by jeremy-rifkin
kihana asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, this isn't something the library currently supports. I've looked at trying to support tracing other threads but it's pretty tricky in terms of portability, robustness, and interface.

If you want to try to hack something together for your own purposes, you might be able to do so by using the stackwalk64 implementation at https://github.com/jeremy-rifkin/cpptrace/blob/main/src/unwind/unwind_with_dbghelp.cpp and replacing the HANDLE thread = GetCurrentThread(); line with a handle to a specific thread. I think you'll need to call SuspendThread on the thread you're tracing first. From this you can create a raw_trace and cpptrace can resolve that.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kihana
Comment options

Answer selected by kihana
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants