As mentioned above, you can use
TraceEvent()
to manage the
instrumented kernel's buffers, but it's probably easier to run
tracelogger in daemon mode and let it look after the buffers.
Nevertheless, here's a summary of how to do it with TraceEvent():
Note:
In order to allocate or free the trace buffers, your application must have the
PROCMGR_AID_TRACE ability enabled.
For more information, see the entry
procmgr_ability()
in the QNX Neutrino
C Library Reference.
- To allocate the buffers, use the _NTO_TRACE_ALLOCBUFFER
command, specifying the number of buffers and a pointer to a location
where TraceEvent() can store the physical address of
the beginning of the circular linked list of allocated trace buffers:
TraceEvent(_NTO_TRACE_ALLOCBUFFER, uint bufnum, void** linkliststart);
Allocated trace buffers can store 1024 simple trace events.
- To free the buffers, use the _NTO_TRACE_DEALLOCBUFFER
command.
It doesn't take any additional arguments:
TraceEvent(_NTO_TRACE_DEALLOCBUFFER);
All events stored in the trace buffers are lost.
- To flush the buffer, regardless of the number of trace events it
contains, use the _NTO_TRACE_FLUSHBUFFER command:
TraceEvent(_NTO_TRACE_FLUSHBUFFER);
- To get the number of simple trace events that are currently stored in
the trace buffer, use the _NTO_TRACE_QUERYEVENTS
command:
num_events = TraceEvent(_NTO_TRACE_QUERYEVENTS);