diff --git a/subsys/tracing/ctf/ctf_top.c b/subsys/tracing/ctf/ctf_top.c index 753c1693111..23fc6a41cfa 100644 --- a/subsys/tracing/ctf/ctf_top.c +++ b/subsys/tracing/ctf/ctf_top.c @@ -77,6 +77,21 @@ void sys_trace_k_thread_priority_set(struct k_thread *thread) thread->base.prio, name); } +void sys_trace_k_thread_sleep_enter(k_timeout_t timeout) +{ + ctf_top_thread_sleep_enter( + k_ticks_to_us_floor32((uint32_t)timeout.ticks) + ); +} + +void sys_trace_k_thread_sleep_exit(k_timeout_t timeout, int ret) +{ + ctf_top_thread_sleep_exit( + k_ticks_to_us_floor32((uint32_t)timeout.ticks), + (uint32_t)ret + ); +} + void sys_trace_k_thread_create(struct k_thread *thread, size_t stack_size, int prio) { ctf_bounded_string_t name = { "unknown" }; diff --git a/subsys/tracing/ctf/ctf_top.h b/subsys/tracing/ctf/ctf_top.h index 725602d41a9..43d11774ef9 100644 --- a/subsys/tracing/ctf/ctf_top.h +++ b/subsys/tracing/ctf/ctf_top.h @@ -186,6 +186,8 @@ typedef enum { CTF_EVENT_GPIO_GET_PENDING_INT_EXIT = 0x7C, CTF_EVENT_GPIO_FIRE_CALLBACKS_ENTER = 0x7D, CTF_EVENT_GPIO_FIRE_CALLBACK = 0x7E, + CTF_EVENT_THREAD_SLEEP_ENTER = 0x7F, + CTF_EVENT_THREAD_SLEEP_EXIT = 0x80, } ctf_event_t; typedef struct { @@ -213,6 +215,16 @@ static inline void ctf_top_thread_priority_set(uint32_t thread_id, int8_t prio, thread_id, name, prio); } +static inline void ctf_top_thread_sleep_enter(uint32_t timeout) +{ + CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SLEEP_ENTER), timeout); +} + +static inline void ctf_top_thread_sleep_exit(uint32_t timeout, int32_t ret) +{ + CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SLEEP_EXIT), timeout, ret); +} + static inline void ctf_top_thread_create(uint32_t thread_id, int8_t prio, ctf_bounded_string_t name) { diff --git a/subsys/tracing/ctf/tracing_ctf.h b/subsys/tracing/ctf/tracing_ctf.h index 35104679a18..94eb6b1bcfd 100644 --- a/subsys/tracing/ctf/tracing_ctf.h +++ b/subsys/tracing/ctf/tracing_ctf.h @@ -31,8 +31,12 @@ extern "C" { #define sys_port_trace_k_thread_join_enter(thread, timeout) #define sys_port_trace_k_thread_join_blocking(thread, timeout) #define sys_port_trace_k_thread_join_exit(thread, timeout, ret) -#define sys_port_trace_k_thread_sleep_enter(timeout) -#define sys_port_trace_k_thread_sleep_exit(timeout, ret) + +#define sys_port_trace_k_thread_sleep_enter(timeout) \ + sys_trace_k_thread_sleep_enter(timeout) +#define sys_port_trace_k_thread_sleep_exit(timeout, ret) \ + sys_trace_k_thread_sleep_exit(timeout, ret) + #define sys_port_trace_k_thread_msleep_enter(ms) #define sys_port_trace_k_thread_msleep_exit(ms, ret) #define sys_port_trace_k_thread_usleep_enter(us)