Currently i use the dbghelp library to walk through the stack of some process' thread (using GetThreadContext() and StackWalk64()) and collect only the return addresses each frame contains.
However, the overhead of doing so is too big for the systems demands - overall time is apx. 5 msec per stack walk (with 10-15 frames). This time includes the GetThreadContext() and the loop which calls StackWalk64() to get all the frames.
Anyhow, I must find a way to do it much much faster. Anyone has any idea how can i do that?
Edit:
Does anyone know of the ETW (Event Tracing for Windows) mechanism?
If so, how can I trace all the context switches that happened in a certain period of time? Is there an event provider that publishes an event on each context switch?