Is it possible to get stack trace for a specified thread? #135
-
Hi, I have the following case: my program loads dynamic libraries. These Dlls are written by other users. My program exports procedures from these Dlls and runs them in separate threads. Sometimes these threads can freeze because of a mistake in Dll (e.g. a user wrote an infinite loop in Dll). I can see which thread is frozen. But also it would be nice to get a stack trace for this thread to localize the problem. Because Dll often contains quite complex logic and it's difficult to find the problematic place without any diagnostic. Is it possible to do it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 |
Beta Was this translation helpful? Give feedback.
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 araw_trace
and cpptrace can resolve that.