Mstdlib-1.24.0
Addon for event and I/O tracing

Typedefs

typedef enum M_io_trace_type M_io_trace_type_t
 
typedef void(* M_io_trace_cb_t) (void *cb_arg, M_io_trace_type_t type, M_event_type_t event_type, const unsigned char *data, size_t data_len)
 
typedef void *(* M_io_trace_cb_dup_t) (void *cb_arg)
 
typedef void(* M_io_trace_cb_free_t) (void *cb_arg)
 

Enumerations

enum  M_io_trace_type {
  M_IO_TRACE_TYPE_READ = 1 ,
  M_IO_TRACE_TYPE_WRITE = 2 ,
  M_IO_TRACE_TYPE_EVENT = 3
}
 

Functions

M_io_error_t M_io_add_trace (M_io_t *io, size_t *layer_id, M_io_trace_cb_t callback, void *cb_arg, M_io_trace_cb_dup_t cb_dup, M_io_trace_cb_free_t cb_free)
 
void * M_io_trace_get_callback_arg (M_io_t *io, size_t layer_id)
 
M_bool M_io_trace_set_callback_arg (M_io_t *io, size_t layer_id, void *cb_arg)
 

Detailed Description

Event and I/O tracing addon

Allows data to be traced as it flows through the trace layer. For example communication over serial with an external device could have a trace layer that logs read and write commands.

This can be very useful when combined with the M_log logging module.

Typedef Documentation

◆ M_io_trace_type_t

◆ M_io_trace_cb_t

typedef void(* M_io_trace_cb_t) (void *cb_arg, M_io_trace_type_t type, M_event_type_t event_type, const unsigned char *data, size_t data_len)

Definition for a function callback that is called every time a traceable event is triggered by the event subsystem.

Parameters
[in]cb_argUser-specified callback argument registered when the trace was added to the event handle.
[in]typeThe type of type that has been triggered, see M_io_trace_type_t.
[in]event_typeThe type of event that has been triggered, see M_event_type_t.
[in]dataData that is passing though this trace layer.
[in]data_lenLength of data.

◆ M_io_trace_cb_dup_t

typedef void *(* M_io_trace_cb_dup_t) (void *cb_arg)

Definition for a function that duplicates a callback argument.

An io that has an accept event such as net can have connection specific arguments. The trace layer will be duplicated from the server to the new io client connection. This allows the cb_arg to be duplicated as well.

Parameters
[in]cb_argCallback argument of the type provided to M_io_add_trace.

◆ M_io_trace_cb_free_t

typedef void(* M_io_trace_cb_free_t) (void *cb_arg)

Definition for a function that destroys a user provided callback data associated with the trace.

Parameters
[in]cb_argCallback argument of the type provided to M_io_add_trace.

Enumeration Type Documentation

◆ M_io_trace_type

Trace even type.

Enumerator
M_IO_TRACE_TYPE_READ 
M_IO_TRACE_TYPE_WRITE 
M_IO_TRACE_TYPE_EVENT 

Function Documentation

◆ M_io_add_trace()

M_io_error_t M_io_add_trace ( M_io_t io,
size_t *  layer_id,
M_io_trace_cb_t  callback,
void *  cb_arg,
M_io_trace_cb_dup_t  cb_dup,
M_io_trace_cb_free_t  cb_free 
)

Add a trace layer

Parameters
[in]ioio object.
[out]layer_idLayer id this is added at.
[in]callbackFunction called when the trace is triggered.
[in]cb_argArgument passed to callback.
[in]cb_dupFunction to duplicate cb_arg if needed. Optional and can be NULL if not used.
[in]cb_freeFunction to destroy cb_arg when the io object id destroyed. Optional and can be NULL if not used.
Returns
Result.

◆ M_io_trace_get_callback_arg()

void * M_io_trace_get_callback_arg ( M_io_t io,
size_t  layer_id 
)

Get the callback arg for a trace layer.

Parameters
[in]ioio object.
[in]layer_idLayer id.
Returns
Argument on success or NULL on error. NULL is success if a cb_arg was not set.

◆ M_io_trace_set_callback_arg()

M_bool M_io_trace_set_callback_arg ( M_io_t io,
size_t  layer_id,
void *  cb_arg 
)

Set the callback arg for the trace layer.

Parameters
[in]ioio object.
[in]layer_idLayer id.
[in]cb_argArgument passed to callback.
Returns
M_TRUE on success, otherwise M_FALSE on error.