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.
◆ M_io_trace_type_t
◆ M_io_trace_cb_t
Definition for a function callback that is called every time a traceable event is triggered by the event subsystem.
- Parameters
-
[in] | cb_arg | User-specified callback argument registered when the trace was added to the event handle. |
[in] | type | The type of type that has been triggered, see M_io_trace_type_t. |
[in] | event_type | The type of event that has been triggered, see M_event_type_t. |
[in] | data | Data that is passing though this trace layer. |
[in] | data_len | Length 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_arg | Callback 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_arg | Callback argument of the type provided to M_io_add_trace. |
◆ M_io_trace_type
Trace even type.
Enumerator |
---|
M_IO_TRACE_TYPE_READ | |
M_IO_TRACE_TYPE_WRITE | |
M_IO_TRACE_TYPE_EVENT | |
◆ M_io_add_trace()
Add a trace layer
- Parameters
-
[in] | io | io object. |
[out] | layer_id | Layer id this is added at. |
[in] | callback | Function called when the trace is triggered. |
[in] | cb_arg | Argument passed to callback. |
[in] | cb_dup | Function to duplicate cb_arg if needed. Optional and can be NULL if not used. |
[in] | cb_free | Function 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] | io | io object. |
[in] | layer_id | Layer 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] | io | io object. |
[in] | layer_id | Layer id. |
[in] | cb_arg | Argument passed to callback. |
- Returns
- M_TRUE on success, otherwise M_FALSE on error.