12/13/2011 3:16 AM
Re: TraceEvent API - dynamic filter question
I have an additional question about the TraceEvent API.
As I mentioned in the initial post, I am developing a way to get accurate timing data for some threads in the system,
for this I am using dynamic filtering on thread_running events and I use the PID/TID part of the event and ClockCycles()
calls to measure thread timings.
I have had this implementation working as part of a process that contains a lot of business intelligence, but I am
moving it to a dedicated process that only counts thread timings.
I am now unable to start the trace in my process (TraceEvent(_NTO_TRACE_START) returns -1, errno is ECANCELED). I am
probably missing some specific TraceEvent() calls, so far I am only doing this:
// get kernel IO privileges
ThreadCtl(_NTO_TCTL_IO, 0) - success
// static filter on just THRUNNING events
TraceEvent(_NTO_TRACE_ADDEVENT, _NTO_TRACE_THREAD, _NTO_TRACE_THRUNNING) - success
// my dynamic filter callback
TraceEvent(_NTO_TRACE_ADDEVENTHANDLER, _NTO_TRACE_THREAD, _NTO_TRACE_THRUNNING, traceEventCallback, &m_eventData) -
// start the trace
TraceEvent(_NTO_TRACE_START) - fails
In particular, I do not allocate/deallocate kernel buffers: should I be doing this? It was working without it in my
previous implementation with the exact same function calls, but for some reason it does not work anymore in a separate