From 74da4393224b2f64595b32edd219a3a228eb6495 Mon Sep 17 00:00:00 2001 From: Danny Oerndrup Date: Fri, 5 Jul 2019 14:40:44 +0200 Subject: [PATCH] debug: tracing: Rewrite assert on current_thread in CPU stats module The function sys_trace_thread_switched_out asserts in case sys_trace_thread_switched_in was not called first. This is unintended as tracing.h describes that out should be called before in, thus the reverse of what the assert expects. Fix assert on initial thread switch in, where out is called with current_thread being NULL. Signed-off-by: Danny Oerndrup --- subsys/debug/tracing/cpu_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/debug/tracing/cpu_stats.c b/subsys/debug/tracing/cpu_stats.c index 4a73c776288..1bdd7c9cd59 100644 --- a/subsys/debug/tracing/cpu_stats.c +++ b/subsys/debug/tracing/cpu_stats.c @@ -123,7 +123,7 @@ void sys_trace_thread_switched_out(void) int key = irq_lock(); __ASSERT_NO_MSG(nested_interrupts == 0); - __ASSERT_NO_MSG(current_thread == k_current_get()); + __ASSERT_NO_MSG(!current_thread || (current_thread == k_current_get())); cpu_stats_update_counters(); last_cpu_state = CPU_STATE_SCHEDULER;