Tracing: Timer tracing
Add Timer tracing, default tracing hooks, and documentation.
Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
diff --git a/include/tracing/tracing.h b/include/tracing/tracing.h
index 9cb36fb..f9ebf15 100644
--- a/include/tracing/tracing.h
+++ b/include/tracing/tracing.h
@@ -1465,6 +1465,58 @@
*/ /* end of mslab_tracing_apis */
+
+
+/**
+ * @brief Timer Tracing APIs
+ * @defgroup timer_tracing_apis Timer Tracing APIs
+ * @ingroup tracing_apis
+ * @{
+ */
+
+/**
+ * @brief Trace initialization of Timer
+ * @param timer Timer object
+ */
+#define sys_port_trace_k_timer_init(timer)
+
+/**
+ * @brief Trace Timer start
+ * @param timer Timer object
+ */
+#define sys_port_trace_k_timer_start(timer)
+
+/**
+ * @brief Trace Timer stop
+ * @param timer Timer object
+ */
+#define sys_port_trace_k_timer_stop(timer)
+
+/**
+ * @brief Trace Timer status sync entry
+ * @param timer Timer object
+ */
+#define sys_port_trace_k_timer_status_sync_enter(timer)
+
+/**
+ * @brief Trace Timer Status sync blocking
+ * @param timer Timer object
+ * @param timeout Timeout period
+ */
+#define sys_port_trace_k_timer_status_sync_blocking(timer, timeout)
+
+/**
+ * @brief Trace Time Status sync outcome
+ * @param timer Timer object
+ * @param result Return value
+ */
+#define sys_port_trace_k_timer_status_sync_exit(timer, result)
+
+/**
+ * @}
+ */ /* end of timer_tracing_apis */
+
+
/**
* @}
*/
diff --git a/kernel/timer.c b/kernel/timer.c
index a5c93d5..b8faea1 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -105,6 +105,9 @@
}
z_init_timeout(&timer->timeout);
+
+ SYS_PORT_TRACING_OBJ_INIT(k_timer, timer);
+
SYS_TRACING_OBJ_INIT(k_timer, timer);
timer->user_data = NULL;
@@ -116,6 +119,8 @@
void z_impl_k_timer_start(struct k_timer *timer, k_timeout_t duration,
k_timeout_t period)
{
+ SYS_PORT_TRACING_OBJ_FUNC(k_timer, start, timer);
+
if (K_TIMEOUT_EQ(duration, K_FOREVER)) {
return;
}
@@ -162,6 +167,8 @@
void z_impl_k_timer_stop(struct k_timer *timer)
{
+ SYS_PORT_TRACING_OBJ_FUNC(k_timer, stop, timer);
+
int inactive = z_abort_timeout(&timer->timeout) != 0;
if (inactive) {
@@ -214,6 +221,7 @@
uint32_t z_impl_k_timer_status_sync(struct k_timer *timer)
{
__ASSERT(!arch_is_in_isr(), "");
+ SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_timer, status_sync, timer);
if (!IS_ENABLED(CONFIG_MULTITHREADING)) {
uint32_t result;
@@ -243,6 +251,8 @@
if (result == 0U) {
if (!z_is_inactive_timeout(&timer->timeout)) {
+ SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_timer, status_sync, timer, K_FOREVER);
+
/* wait for timer to expire or stop */
(void)z_pend_curr(&lock, key, &timer->wait_q, K_FOREVER);
@@ -259,6 +269,11 @@
timer->status = 0U;
k_spin_unlock(&lock, key);
+ /**
+ * @note New tracing hook
+ */
+ SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_timer, status_sync, timer, result);
+
return result;
}