I am trying to write my own sampling based profiler for windows. It needs to be very low overhead and provide instruction level profiling granularity. I believe these are some of the things it must do in order to work:
- Register an interrupt that will be generated by each CPU’s local APIC timer.
- Use an ISR that will determine the RIP of the thread that was interrupted, and the PID of that thread (maybe even through a DPC).
- Communicate that information to a user mode client program.
Here are my main questions:
-
Is this possible to do under KMDF? If so, would you be able to point me to an example?
-
If it is possible, then do I need to modify the interrupt descriptor table of each CPU directly? If so then is that even possible on 64-bit windows? If not then how else will I be able to register an interrupt service routine that gets called immediately after the interrupt occurs such that the interrupted thread’s stack contains the RIP in a fixed location? From what I understand, using the standard WdfInterruptCreate() technique results in windows traversing a list of ISRs before calling the one you registered when servicing the interrupt, which I can imagine will modify the stack such that the interrupted RIP will be impossible to find. If this is not an issue and the WdfInterruptCreate() technique should be used, how can I obtain the interrupt vector that I should register with the local APIC timer as well?
Thanks,
David