From bdc80ebe16c82fa589ce9c750e66d2f319123b8f Mon Sep 17 00:00:00 2001 From: Bradley Bolen Date: Tue, 3 Aug 2021 11:58:52 -0400 Subject: [PATCH] samples: tracing: Add a sample for tracing_user The user tracing backend allows one to implement weak symbols to perform user specific tracing, e.g gpio toggling or spi transactions. This adds a qemu sample that just does a simple printk for each of the traced functions, but could be changed to do whatever function the user desires. Signed-off-by: Bradley Bolen --- samples/subsys/tracing/CMakeLists.txt | 1 + samples/subsys/tracing/prj_user.conf | 2 ++ samples/subsys/tracing/src/tracing_user.c | 32 +++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 samples/subsys/tracing/prj_user.conf create mode 100644 samples/subsys/tracing/src/tracing_user.c diff --git a/samples/subsys/tracing/CMakeLists.txt b/samples/subsys/tracing/CMakeLists.txt index 79e47acc01b..b42587f68a1 100644 --- a/samples/subsys/tracing/CMakeLists.txt +++ b/samples/subsys/tracing/CMakeLists.txt @@ -10,3 +10,4 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(tracing_tests) target_sources(app PRIVATE src/main.c) +target_sources_ifdef(CONFIG_TRACING_USER app PRIVATE src/tracing_user.c) diff --git a/samples/subsys/tracing/prj_user.conf b/samples/subsys/tracing/prj_user.conf new file mode 100644 index 00000000000..843bd16a8d2 --- /dev/null +++ b/samples/subsys/tracing/prj_user.conf @@ -0,0 +1,2 @@ +CONFIG_TRACING=y +CONFIG_TRACING_USER=y diff --git a/samples/subsys/tracing/src/tracing_user.c b/samples/subsys/tracing/src/tracing_user.c new file mode 100644 index 00000000000..a4a5d000442 --- /dev/null +++ b/samples/subsys/tracing/src/tracing_user.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 Lexmark International, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +void sys_trace_thread_switched_in_user(struct k_thread *thread) +{ + printk("%s: %p\n", __func__, thread); +} + +void sys_trace_thread_switched_out_user(struct k_thread *thread) +{ + printk("%s: %p\n", __func__, thread); +} + +void sys_trace_isr_enter_user(void) +{ + printk("%s\n", __func__); +} + +void sys_trace_isr_exit_user(void) +{ + printk("%s\n", __func__); +} + +void sys_trace_idle_user(void) +{ + printk("%s\n", __func__); +}