traceparser_cs()

Attach a callback to a trace event

Synopsis:

#include <sys/traceparser.h>

int traceparser_cs ( 
   struct traceparser_state * stateptr, 
   void * userdata,
   tracep_callb_func_t funcptr, 
   unsigned class, 
   unsigned event );

Arguments:

stateptr
A pointer to an opaque data structure that contains the parser's state information, obtained by calling traceparser_init().
userdata
A pointer to arbitrary user data that you want to be passed to the callback function when it's executed.
funcptr
A pointer to the callback function that you want to register. For more information, see Callback function,” below.
class
The class of trace events that you want to invoke the callback function for. For information about the supported classes, see Classes and events in the “Events and the Kernel” chapter of the System Analysis Toolkit User's Guide.
event
The specific trace event that you want to invoke the callback function for. This event must be a member of the given class. For information about the classes and trace events, see Classes and events in the “Events and the Kernel” chapter of the System Analysis Toolkit User's Guide.

In QNX Neutrino 7.0 or later, you can OR the event number with _NTO_TRACE_KERCALL64. In this case, the callback is invoked only for kernel events that include 64-bit data types. You might also want to attach a callback for the event without _NTO_TRACE_KERCALL64.

Library:

libtraceparser

Use the -l traceparser option to qcc to link against this library.

Description:

The traceparser_cs() function attaches the callback function specified by the pointer funcptr, to one particular event, from one particular class. You'll use this function if you're creating your own utility for parsing trace data (as an alternative to traceprinter).

Callback function

The synopsis of the callback function is defined by the tracep_callb_func_t data type as follows:

int my_callback( struct traceparser_state* statepointer,
                 void *userdata,
                 unsigned header,
                 unsigned timestamp,
                 unsigned *darray,
                 unsigned darray_count)

The arguments are:

stateptr
A pointer to the parser's state information, obtained by calling traceparser_init().
userdata
A pointer to arbitrary user data that you want to pass to the callback function.
header
The header of the event. For information about some macros for extracting information from this member, see _NTO_TRACE_GET*().
timestamp
The lower 32 bits of the timestamp for the event.
darray
An array of type unsigned that holds the data associated with the event. For more information, see the Current Trace Events and Data appendix of the System Analysis Toolkit (SAT) User's Guide.
darray_count
The number of entries in the darray array.

The callback should return 0 to indicate success, and -1 to indicate failure.

Returns:

0
Success.
-1
Failure; errno is set. See also traceparser_get_info() for further details.

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread No