Commit graph

191 commits

Author SHA1 Message Date
Anas Nashif
d849ab1263 tracing: fix various style issues
run clang-format and fix various checkpatch issues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
fc4db3dd1d tracing: ctf: do not use signal as an argument
Violates coding guideline rule 21.2

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
21e44ea8d4 tracing: systemview: add tracing for mail boxes
Add missing hooks for mail boxes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
a6dee79282 tracing: systemview: add tracing for events
Add missing hooks for events.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
59a3fe86d3 tracing: systemview: add tracing for stacks
Add missing hooks for stack objects.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
539308f336 tracing: systemview: add tracing for message queues
Add missing hooks for message queues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
63582601f2 tracing: ctf: add event support
Add hooks for events.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
61dd33445e tracing: ctf: add mbox support
Add hooks for mail boxes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
1823d4cf18 tracing: ctf: thread extended
Add more thread related tracing functions.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
906db71942 tracing: ctf: add poll
Add hooks for poll object.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
ba453c1337 tracing: ctf: add work queues
Add hooks for work queues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
e23d663b85 tracing: ctf: add condition variables
Add hooks for condition variables.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
26fa18ef2d tracing: ctf: add tracing for message queues
Add hooks for message queues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
9e99699167 tracing: ctf: add tracing for memory slabs
Add hooks for memory slabs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
7b1e72474c tracing: ctf: add missing return value for mutex_unlock
Add missing return for mutex_unlock.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Anas Nashif
afef4b6a17 tracing: add semihosting backend
Using semihosting on supported architectures (arm, xtensa, riscv) it now
possible to generate tracing giles easily and without being restricted
by size.
Using qemu for example, it is now possible to generate the tracing file
simply by running:

 west build -p -b mps2/an385 tests/kernel/msgq/msgq_api/ \
 	-t run --snippet semihost-tracing

This will generate a tracing file in the build/ directory which can be
viewed with babeltrace.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00
Måns Ansgariusson
ebe128e61f subsys/tracing: Remove retired k_pipe references in SYSVIEW config
Due to the k_pipe rework, references to k_pipe in the SYSVIEW configuration
are now obsolete. This commit removes these references.

Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
2025-10-10 12:55:37 -04:00
Måns Ansgariusson
98917a022b tracing: Remove retired k_pipe tracing api
The old k_pipe api was retired in #95408, the tracing hooks should be
removed as well.

Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
2025-10-08 08:44:11 +02:00
Alberto Escolar Piedras
37ff1b254f tracing: ctf: Fix arguments socket tracing functions
Zephyr's socklen_t was changed in
c546c1cad1
to be uint32_t instea of size_t.
Let's fix accordingly the prototypes which expect it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-10-06 20:00:20 +03:00
Daniel Leung
4ef1163e39 samples: tracing: fix missing k_event funcs for UART test
With the UART transport test (sample.tracing.transport.uart),
it would fail on qemu_x86_64 complaining about missing
k_event tracing functions. So add them to fix the compilation
error.

Fixes #96818

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-10-03 21:19:57 -04:00
Alberto Escolar Piedras
896bdce53a subsys/tracing/tracing_backend_posix: Set file to be closed on exec
If the process does an exec() (or fork, or..) all descriptors are kept
open by default, unless O_CLOEXEC is set when opening them.
This is usefull for stdin/out/err so that new process is connected to
them, but it is very rare for it to be usefull for any other descriptor.

In general this leads to descriptors being kept open unnecessarily,
which either will block other process from getting them (for example
if the child survives the parent but it does something else).
Or for a "leak" which unnecessarily uses descriptors and memory in the
child process.

Let's ensure we do not leak it for this component as we do not need it.

Note glibc fopen supports the "e" modifier as an extension to pass
O_CLOEXEC to the open syscall.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-10-02 22:00:02 +02:00
Kristoffer Skøien
2faf1aa86d tracing: Added board qualifier to SEGGER SystemView
Added CONFIG_BOARD_QUALIFIERS as target core to SEGGER SystemView config

Signed-off-by: Kristoffer Skøien <kristoffer.skoien@nordicsemi.no>
2025-09-09 17:28:10 +02:00
Anas Nashif
f5d7081710 kernel: do not include ksched.h in subsys/soc code
Do not directly include and use APIs from ksched.h outside of the
kernel. For now do this using more suitable (ipi.h and
kernel_internal.h) internal APIs until more cleanup is done.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-09-09 11:45:06 +02:00
Daniel DeGrasse
c7e60346a0 tracing: ctf: take IRQ lock before generating timestamp
CTF tracing relies on all packet timestamps being increasing- if a
timestamp of a later packet is less than the prior packet, the CTF
parser assumes the timestamp field has overflowed and adds to the
overall timestamp to account for this.

When taking a timestamp for a CTF packet, it was possible for an interrupt
to occur before the packet was submitted to the tracing core framework
but after the timestamp was generated. The interrupt itself would
generate a tracing event with a later timestamp then the packet in
question, leading to the packets being recorded out of order.

To resolve this, take an IRQ lock before generating the timestamp and
release it after submitting the packet to the tracing core.

Signed-off-by: Daniel DeGrasse <ddegrasse@tenstorrent.com>
2025-09-08 15:54:35 -04:00
WenBin Zhang
d28602adaf tracing: systemview: Add isr name for Segger-sysview
With symtab enabled, the isr name is collected by symbol table

Signed-off-by: WenBin Zhang <freey7955@gmail.com>
2025-08-13 22:12:01 -04:00
Anas Nashif
6c85528cbe tracing: ctf: fix arguments for timer_status_sync
In the metadata, found that timer_status_sync_pending was missing the
timeout parameter. Noticed when tracing tests/kernel/common.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-08-01 19:38:40 +01:00
Anas Nashif
d794732087 tracing: ctf: add missing k_sleep events
In a096b34835 which introduced tracing of k_sleep, the events in the
metadata file were missed causing issues when running with babeltrace.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-08-01 19:38:40 +01:00
WenBin Zhang
d01edb10e1 tracing: Fix k_mem_slab_free tracing systemview
Fix k_mem_slabe_free tracing error.

Signed-off-by: WenBin Zhang <freey7955@gmail.com>
2025-07-31 10:53:30 +01:00
Anas Nashif
a096b34835 tracing: ctf: trace k_sleep()
Trace sleep events in CTF:

[19:00:00.181375400] (+0.000044700) k_sleep_enter: ...
..
[19:00:00.290203800] (+0.000031500) k_sleep_exit: ...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-07-25 23:29:14 +02:00
Alexander Paschoaletto
8c03410af0 tracing: msgq: adding dedicated tracing for k_msgq_put_front
This commit adds the tracing macros and functions related
specifically to the k_msgq_put_front API.

Signed-off-by: Alexander Paschoaletto <axelpinheiro@gmail.com>
2025-07-25 08:16:58 -04:00
Alberto Escolar Piedras
af750b2b41 subsys/tracing/backend_posix: Remove NATIVE_APPLICATION support
It is not possible to build anymore in that mode, so we do not
need to support it in this driver cmake files.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-07-19 09:38:15 +02:00
Krzysztof Sychla
dcdc7d315e tracing: Allow disabling idle traces
This change allows for enabling/disabling the idle traces by setting the
CONFIG_TRACING_IDLE config.

Signed-off-by: Krzysztof Sychla <ksychla@antmicro.com>
2025-06-27 08:59:32 -10:00
Koen Van Herck
6ccd228d62 subsys/tracing: do not select (RTT_)CONSOLE in SEGGER_SYSTEMVIEW
Tracing using Segger's SystemView works fine without enabling RTT_CONSOLE
(or CONSOLE, in general).
SEGGER_SYSTEMVIEW was automatically selecting RTT_CONSOLE, which prevents
applications from using another console backend (e.g. UART_CONSOLE).

Signed-off-by: Koen Van Herck <koen.v.herck@gmail.com>
2025-06-24 20:04:07 -10:00
The Nguyen
f51a89268f tracing: fix build error on USB backend
This commit to fix build error due to a wrong syntax in case USBD
highspeed was enabled

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
2025-06-18 10:54:32 +02:00
Filip Kokosinski
15b73eda7d subsys/tracing: select backend name in Kconfig
This commit allows tracing backend name selection through Kconfig.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2025-06-17 16:05:59 +02:00
Filip Kokosinski
ef20311522 subsys/tracing: add names to Kconfig choice symbols
This commit adds names to Kconfig choice sysmbols. This allows for their
selection from Kconfig, e.g.:

    choice TRACING_FORMAT_CHOICE
    	default TRACING_TEST if CONFIG_FOO
	default TRACING_CTF if CONFIG_BAR
    endchoice

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2025-06-17 16:05:29 +02:00
Johann Fischer
1174308df8 tracing: port USB backend to the new USB device stack
Port USB backend to the new USB device stack.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-06-17 16:03:44 +02:00
Nicolas Pitre
9da06456f2 kernel: kheap: decouple simple alloc from aligned_alloc
When k_heap_alloc() is expressed in terms of k_heap_aligned_alloc()
it invokes a longer aligned allocation code path with an extra runtime
overhead even though no alignment is necessary.

Let's reference and invoke the aligned allocation code path only when an
actual aligned allocation is requested. This opens the possibility for
the linker to garbage-collect the aligning code otherwise.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2025-04-01 22:13:04 +02:00
Krzysztof Chruściński
4cbafc6bd4 tracing: Add sys_trace_idle_exit call
Add new tracing API which is called when core is exiting from idle.
Current implementation is using it to track CPU load. Implementation
in tracing_none is now weak so it can be used if given backend does
not support new API call.

When CONFIG_CPU_LOAD is enabled then sys_trace_idle also calls a
hook which stores the timing information when CPU entered idle.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-03-12 14:03:48 +00:00
Måns Ansgariusson
efcc734b79 tracing: k_pipe: Add tracing support for reworked k_pipe API
Add tracing support for the reworked k_pipe API.

Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
2025-01-17 19:43:44 +01:00
Simone Orru
354a47cfcf tracing: sysview: Clang-format tracing_sysview_ids.h
Run clang-format over the tracing_sysview_ids.h.

Signed-off-by: Simone Orru <simone.orru@secomind.com>
2024-12-30 17:32:03 +01:00
Simone Orru
f53aa42b8b tracing: Add calloc
Add the calloc tracing functions.

Signed-off-by: Simone Orru <simone.orru@secomind.com>
2024-12-30 17:32:03 +01:00
Måns Ansgariusson
7545e8d582 tracing: kernel: Add support for stopping workqueues
Adds tracing support for stopping workqueues.

Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
2024-12-12 11:07:39 +01:00
Alexander Lay
d356403664 samples: tracing: update sample app for gpio tracing
Implement a sample app to perform basic GPIO tracing.

Signed-off-by: Alexander Lay <alexanderlay@tenstorrent.com>
Signed-off-by: Yang Xu <yangxu@tenstorrent.com>
2024-12-04 14:12:58 -05:00
Alexander Lay
8f2dd90088 tracing: add gpio tracing support
If GPIO tracing is enabled, then the system will track
various GPIO pin events.

Signed-off-by: Alexander Lay <alexanderlay@tenstorrent.com>
Signed-off-by: Yang Xu <yangxu@tenstorrent.com>
2024-12-04 14:12:58 -05:00
Daniel DeGrasse
66577a9d23 tracing: add named event trace
Add support for a "named event" trace. This trace is intentionally not
used by the system. The purpose of this trace is to allow driver or
application developers to quickly add tracing for events for debug
purposes, and to provide an example of how tracing subsystems can be
extended with additional trace identifiers.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-10-17 10:46:52 -04:00
Jukka Rissanen
8134673309 tracing: segger-sysview: Fix compilation issues with networking
The networking tracing function definitions were missing for sysview.

Fixes #79805

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-10-17 09:43:33 +02:00
Bruce Rosier
24414e3c39 subsystem: tracing: test: fix k_pipe_put_* functions
k_pipe_put_* functions should take const void* data
    instead of void* data. This can lead to warnings at the
    the -Werror=discarded-qualifiers compiler flag, because the
    the input will be const void* and the parameter will be void*.
    Fix it by replacing void* data with “const void* data”.

Signed-off-by: Bruce Rosier <brucerosier9@gmail.com>
2024-10-16 16:36:11 +01:00
Chris Friedt
881dc1fa7a net: sockets: move poll implementation to zvfs
Move the implementation of zsock_poll to zvfs_poll. This allows
other types of file descriptors to also make use of poll()
functionality even when the network subsystem is not enabled.

Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-10-14 13:01:51 +02:00
Maureen Helm
d022d315d2 tracing: Fix sysview for soc families not subdivided into series
Fixes the systemview tracing backend for soc families, such as max32,
that don't subdivide into soc series and therefore don't define
CONFIG_SOC_SERIES. Use CONFIG_SOC_FAMILY instead in the system
description since it should always be defined.

Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2024-10-06 20:51:27 +01:00