Tracing: Pipe tracing
Add Pipe tracing, default trace hooks, and documentation. Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
This commit is contained in:
parent
d2e7de522d
commit
fa9e64b304
2 changed files with 152 additions and 2 deletions
|
@ -1192,6 +1192,110 @@
|
|||
*/ /* end of mbox_tracing_apis */
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Pipe Tracing APIs
|
||||
* @defgroup pipe_tracing_apis Pipe Tracing APIs
|
||||
* @ingroup tracing_apis
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Trace initialization of Pipe
|
||||
* @param pipe Pipe object
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_init(pipe)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe cleanup entry
|
||||
* @param pipe Pipe object
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_cleanup_enter(pipe)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe cleanup exit
|
||||
* @param pipe Pipe object
|
||||
* @param ret Return value
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_cleanup_exit(pipe, ret)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe alloc init entry
|
||||
* @param pipe Pipe object
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_alloc_init_enter(pipe)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe alloc init exit
|
||||
* @param pipe Pipe object
|
||||
* @param ret Return value
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_alloc_init_exit(pipe, ret)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe put attempt entry
|
||||
* @param pipe Pipe object
|
||||
* @param timeout Timeout period
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_put_enter(pipe, timeout)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe put attempt blocking
|
||||
* @param pipe Pipe object
|
||||
* @param timeout Timeout period
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_put_blocking(pipe, timeout)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe put attempt outcome
|
||||
* @param pipe Pipe object
|
||||
* @param timeout Timeout period
|
||||
* @param ret Return value
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_put_exit(pipe, timeout, ret)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe get attempt entry
|
||||
* @param pipe Pipe object
|
||||
* @param timeout Timeout period
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_get_enter(pipe, timeout)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe get attempt blocking
|
||||
* @param pipe Pipe object
|
||||
* @param timeout Timeout period
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_get_blocking(pipe, timeout)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe get attempt outcome
|
||||
* @param pipe Pipe object
|
||||
* @param timeout Timeout period
|
||||
* @param ret Return value
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_get_exit(pipe, timeout, ret)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe block put enter
|
||||
* @param pipe Pipe object
|
||||
* @param sem Semaphore object
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_block_put_enter(pipe, sem)
|
||||
|
||||
/**
|
||||
* @brief Trace Pipe block put exit
|
||||
* @param pipe Pipe object
|
||||
* @param sem Semaphore object
|
||||
*/
|
||||
#define sys_port_trace_k_pipe_block_put_exit(pipe, sem)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* end of pipe_tracing_apis */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -106,6 +106,9 @@ void k_pipe_init(struct k_pipe *pipe, unsigned char *buffer, size_t size)
|
|||
pipe->lock = (struct k_spinlock){};
|
||||
z_waitq_init(&pipe->wait_q.writers);
|
||||
z_waitq_init(&pipe->wait_q.readers);
|
||||
|
||||
SYS_PORT_TRACING_OBJ_INIT(k_pipe, pipe);
|
||||
|
||||
SYS_TRACING_OBJ_INIT(k_pipe, pipe);
|
||||
pipe->flags = 0;
|
||||
z_object_init(pipe);
|
||||
|
@ -116,6 +119,8 @@ int z_impl_k_pipe_alloc_init(struct k_pipe *pipe, size_t size)
|
|||
void *buffer;
|
||||
int ret;
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_pipe, alloc_init, pipe);
|
||||
|
||||
if (size != 0U) {
|
||||
buffer = z_thread_malloc(size);
|
||||
if (buffer != NULL) {
|
||||
|
@ -130,6 +135,8 @@ int z_impl_k_pipe_alloc_init(struct k_pipe *pipe, size_t size)
|
|||
ret = 0;
|
||||
}
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, alloc_init, pipe, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -145,8 +152,12 @@ static inline int z_vrfy_k_pipe_alloc_init(struct k_pipe *pipe, size_t size)
|
|||
|
||||
int k_pipe_cleanup(struct k_pipe *pipe)
|
||||
{
|
||||
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_pipe, cleanup, pipe);
|
||||
|
||||
CHECKIF(z_waitq_head(&pipe->wait_q.readers) != NULL ||
|
||||
z_waitq_head(&pipe->wait_q.writers) != NULL) {
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, cleanup, pipe, -EAGAIN);
|
||||
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
|
@ -155,6 +166,9 @@ int k_pipe_cleanup(struct k_pipe *pipe)
|
|||
pipe->buffer = NULL;
|
||||
pipe->flags &= ~K_PIPE_FLAG_ALLOC;
|
||||
}
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, cleanup, pipe, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -409,7 +423,11 @@ int z_pipe_put_internal(struct k_pipe *pipe, struct k_pipe_async *async_desc,
|
|||
ARG_UNUSED(async_desc);
|
||||
#endif
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_pipe, put, pipe, timeout);
|
||||
|
||||
CHECKIF((min_xfer > bytes_to_write) || bytes_written == NULL) {
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, put, pipe, timeout, -EINVAL);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -425,9 +443,14 @@ int z_pipe_put_internal(struct k_pipe *pipe, struct k_pipe_async *async_desc,
|
|||
min_xfer, timeout)) {
|
||||
k_spin_unlock(&pipe->lock, key);
|
||||
*bytes_written = 0;
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, put, pipe, timeout, -EIO);
|
||||
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_pipe, put, pipe, timeout);
|
||||
|
||||
z_sched_lock();
|
||||
k_spin_unlock(&pipe->lock, key);
|
||||
|
||||
|
@ -488,6 +511,9 @@ int z_pipe_put_internal(struct k_pipe *pipe, struct k_pipe_async *async_desc,
|
|||
if (num_bytes_written == bytes_to_write) {
|
||||
*bytes_written = num_bytes_written;
|
||||
k_sched_unlock();
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, put, pipe, timeout, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -496,6 +522,9 @@ int z_pipe_put_internal(struct k_pipe *pipe, struct k_pipe_async *async_desc,
|
|||
&& min_xfer > 0U) {
|
||||
*bytes_written = num_bytes_written;
|
||||
k_sched_unlock();
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, put, pipe, timeout, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -522,8 +551,10 @@ int z_pipe_put_internal(struct k_pipe *pipe, struct k_pipe_async *async_desc,
|
|||
|
||||
*bytes_written = bytes_to_write - pipe_desc.bytes_to_xfer;
|
||||
|
||||
return pipe_return_code(min_xfer, pipe_desc.bytes_to_xfer,
|
||||
int ret = pipe_return_code(min_xfer, pipe_desc.bytes_to_xfer,
|
||||
bytes_to_write);
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, put, pipe, timeout, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int z_impl_k_pipe_get(struct k_pipe *pipe, void *data, size_t bytes_to_read,
|
||||
|
@ -535,7 +566,11 @@ int z_impl_k_pipe_get(struct k_pipe *pipe, void *data, size_t bytes_to_read,
|
|||
size_t num_bytes_read = 0;
|
||||
size_t bytes_copied;
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_pipe, get, pipe, timeout);
|
||||
|
||||
CHECKIF((min_xfer > bytes_to_read) || bytes_read == NULL) {
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, get, pipe, timeout, -EINVAL);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -550,9 +585,14 @@ int z_impl_k_pipe_get(struct k_pipe *pipe, void *data, size_t bytes_to_read,
|
|||
min_xfer, timeout)) {
|
||||
k_spin_unlock(&pipe->lock, key);
|
||||
*bytes_read = 0;
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, get, pipe, timeout, -EIO);
|
||||
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_pipe, get, pipe, timeout);
|
||||
|
||||
z_sched_lock();
|
||||
k_spin_unlock(&pipe->lock, key);
|
||||
|
||||
|
@ -642,6 +682,8 @@ int z_impl_k_pipe_get(struct k_pipe *pipe, void *data, size_t bytes_to_read,
|
|||
|
||||
*bytes_read = num_bytes_read;
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, get, pipe, timeout, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -652,6 +694,8 @@ int z_impl_k_pipe_get(struct k_pipe *pipe, void *data, size_t bytes_to_read,
|
|||
|
||||
*bytes_read = num_bytes_read;
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, get, pipe, timeout, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -675,8 +719,10 @@ int z_impl_k_pipe_get(struct k_pipe *pipe, void *data, size_t bytes_to_read,
|
|||
|
||||
*bytes_read = bytes_to_read - pipe_desc.bytes_to_xfer;
|
||||
|
||||
return pipe_return_code(min_xfer, pipe_desc.bytes_to_xfer,
|
||||
int ret = pipe_return_code(min_xfer, pipe_desc.bytes_to_xfer,
|
||||
bytes_to_read);
|
||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_pipe, get, pipe, timeout, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue