Commit Graph

67 Commits

Author SHA1 Message Date
Lixin Guo d39410a217 tests: subsys: fixed the samples/tracing code can not generate coverage
Add some tracing functions to fix that the samples/tracing code
cannot generate coverage by twister.

Fixed #38323

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-09-08 10:28:10 -04:00
Nicholas Lowell cc8ab95760 tracing: Add user-definable tracing interface
Create a new tracing option TRACING_USER that allows
the user to define certain user_sys_trace_... functions
to perform whatever work desired for tracing when
tasks are swiched in/out, during isr enter/exit, and when
cpu is idle.

This infrastructure can be useful for plugging into
locally defined tracing tools or any user-specific
debugging environment.

Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
2021-09-02 06:54:35 -04:00
Flavio Ceolin 3c0e7ade99 tracing: Add k_work_queue_init info
Add tracing information for k_work_queue_init

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-08-25 22:07:04 -04:00
Fabio Baltieri f88a420d69 toolchain: migrate iterable sections calls to the external API
This migrates all the current iterable section usages to the external
API, dropping the "Z_" prefix:

Z_ITERABLE_SECTION_ROM
Z_ITERABLE_SECTION_ROM_GC_ALLOWED
Z_ITERABLE_SECTION_RAM
Z_ITERABLE_SECTION_RAM_GC_ALLOWED
Z_STRUCT_SECTION_ITERABLE
Z_STRUCT_SECTION_ITERABLE_ALTERNATE
Z_STRUCT_SECTION_FOREACH

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2021-08-12 17:47:04 -04:00
Johann Fischer ae074e81d4 usb: remove Kconfig option CONFIG_USB
The USB configuration option is actually a global switch
to enable USB drivers in general, but currently only
the device controller drivers are meant.

USB device controller drivers also have USB_DEVICE_DRIVER option.
Thus the option USB is actually redundant and can be replaced
by the self-explanatory option USB_DEVICE_DRIVER.
The name USB itself is not unique and should not be used as an
configuration option.

With these changes the option USB_DEVICE_DRIVER generally
enables USB device controller drivers. The option USB_DEVICE_STACK
enables USB device support. It is sufficient to enable only option
USB_DEVICE_STACK because it selects USB_DEVICE_DRIVER.

CONFIG_USB Kconfig option is temporary added to subsys/usb/Kconfig.
This is necessary to pass CI and will be removed again
when the USB configuration has been adapted in modules.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:00:12 -04:00
Johann Fischer 6408d40fd6 usb: use new USB framework header
Replace all macros and types with the new ones from
usb/usb_ch9.h header.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 13:20:07 +02:00
Torbjörn Leksell 22071d613c Tracing: TRACING_NONE Compilation Fix
Fixed several compilation errors that resulted from selecting
TRACING without specifying a tracing system (Tracerecorder,
CTF, Systemview). In this case (TRACING_NONE), some default trace hooks
(in tracing.h) were incorrectly named resulting in compilation errors.
The legacy sys_trace_isr_enter, sys_trace_isr_exit, and sys_trace_idle
also caused problems since these were only given as defines, resulting
in undefined reference errors since they are required by the assembly
files calling these. To solve this issue I've added a stub file
"tracing_none.c" (only compiled if TRACING_NONE) and declared the
functions in tracing.h if no tracing system is selected.

Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
2021-05-27 14:39:40 -05:00
Anas Nashif 108129cf7d tracing: fix conflict with RTT locking
Make custom RTT locking configurable and select it where it is needed.
When using RTT for tracing we want to use the default locking.

Update both segger and tracerecorder modules to support that.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-25 07:36:38 -05:00
Anas Nashif acee43a176 tracing: fix indentation of config entries
Fix indentation.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-25 07:36:38 -05:00
Anas Nashif cd9421a45e tracing: systemview: display return value of APIs
In systemview, display return value correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 18:45:57 -04:00
Anas Nashif 3b82c388f6 pm: trace pm_device_enable/disable
Trace both pm_device_enable and pm_device_disable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 18:45:57 -04:00
Anas Nashif eccda68418 power: trace power events
Trace PM transition sequence and events.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 18:45:57 -04:00
Anas Nashif b865c85ef4 tracing: fix test format
Add missing defines causing build errors in some scenarios.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 18:45:57 -04:00
Anas Nashif 7c582f4b7c tracing: systemview: rework IDs and make them match APIs
New version of Systemview has Zephyr API description that did not match
what we had, align with what the tools provides and expand hooks to
support additional APIs. We now cover most kernel APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-11 12:59:03 -05:00
Anas Nashif 72c830c3ee tracing: test format: print more details
Print timeouts and other details.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-11 12:59:03 -05:00
Anas Nashif fe14c23852 tracing: move test format into its own directory
Minor cleanup keep format location uniform.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-11 12:59:03 -05:00
Anas Nashif 6a8148f384 tracing: systemview: cleanup headers
Cleanup systemview headers and move sysview hooks into sysview_config.c

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-08 17:06:24 -04:00
Anas Nashif 1af037f477 modules: enable percepio tracerecorder for tracing
Add support for percepio tracealyzer.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Anas Nashif f477bac818 tracing: support new macros with systemview
Use new macros with systemview and rework hooks adding support for new
trace points.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Anas Nashif a35bb82539 tracing: Use new macros with CTF based tracing
Use new tracing macros to generate tracing output in CTF format.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Anas Nashif 270be80caa tracing: add empty test macros
Add support for new tracing macros in test backend. Move header from
sample into the subsystem and make it available for general testing with
any application.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Torbjörn Leksell 16bbb8ef34 Tracing: Trace hook support macros
Adds generic trace hook macros for inserting trace hook for
function entry, exit, blocking, and object initialization
with a variable number of arguments (objects, return values,
etc.). Utilizing macro concatenation these macros produce
trace hooks of a similar format to the old trace system
with SYS_TRACING_OBJ_FUNC(k_thread, switched_in) being
turned into sys_trace_k_thread_switched_in() by the
preprocessor. Although these macros still rely on the manual
definition of each unique trace hook in tracing.h, the benefit
of not directly calling those is that we can enable/disable
trace hooks based on object type (k_thread, k_sem, etc.)
through the preprocessor while providing the ability of adding
type specific runtime trace processing similar to
SYS_TRACING_OBJ_INIT.

Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Jan Müller 10ee29e947 tracing: Add ISR numbers to SystemView for Cortex-M
The sysview module does not set an interrupt number when recording ISRs
using SEGGER SystemView. Added ISR numbers for Cortex-M based chips.

Signed-off-by: Jan Müller <jan.mueller@nordicsemi.no>
2021-05-04 10:17:23 -05:00
Anas Nashif bc747e7167 tracing: remove cpu_stats in favor of thread runtime stats
Removing CONFIG_TRACING_CPU_STATS in favor of
CONFIG_THREAD_RUNTIME_STATS which provides per thread stats. The same
functionality is also available when Thread analyzer is enabled with the
runtime stats enabled.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-16 15:31:24 -04:00
Julien Massot 80402f7f8b tracing: add RAM backend
If Zephyr is running on a coprocessor we might lack I/O
such as uart or usb to output tracing datas but we might
have gigabytes of RAM available.

This patch allows to output trace datas to a ram buffer, which then
may be retrieved using gdb.

e.g:
(gdb) dump binary memory channel0_0 <ram_tracing_start> \
<ram_tracing_end>

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-03-06 07:33:59 -05:00
Rubin Gerritsen bc6d16e422 systemview: Use common function to get sysview thread name
Use a common function to get the thread name.
There was no necessity in keeping sys_trace_thread_info() inline,

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2020-11-21 08:29:26 -05:00
Rubin Gerritsen 7a9da57cd8 systemview: Use thread name when available
This may make it easier to debug.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2020-11-21 08:29:26 -05:00
Rubin Gerritsen 5d121a95e9 systemview: SystemView tracing requires THREAD_MONITOR
Otherwise it will not be able to send its thread list.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2020-11-21 08:29:26 -05:00
Maureen Helm 57b756b442 debug: tracing: Add Segger RTT and SystemView linker section options
Enables optionally placing Segger RTT and SystemView data in the DTCM
linker section instead of the default data section. This is needed on
SoCs in the i.MX RT series that use cacheable external SDRAM to store
data.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-11-20 12:54:09 -06:00
Peter Bigot 017bca3920 tracing: switch to cbprintf as basis for printf functionality
Replace use of z_prf with cbprintf.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-13 06:38:01 -05:00
Daniel Leung 11e6b43090 tracing: roll thread switch in/out into thread stats functions
Since the tracing of thread being switched in/out has the same
instrumentation points, we can roll the tracing function calls
into the one for thread stats gathering functions.
This avoids duplicating code to call another function.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-11-11 23:55:49 -05:00
Mattia Fiumara 8244590fb8 tracing: add feature for analysing post-mortem
This adds a Kconfig option for enabling post-mortem mode of SystemView.
This is useful for crashes that occur after a longer period of time.

Signed-off-by: Mattia Fiumara <mattia.fiumara@bgrid.com>
2020-10-07 10:10:48 -04:00
Anas Nashif e01a4df3fb tracing: handle null thread names with systemview
Default to autogenerated thread name in case no name was assigned.

Fixes #27592

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-09-20 21:27:55 -04:00
Anas Nashif 53cc54516d tracing: fix empty thread name
Report thread names as 'unknown' when we can't determine thread name
from kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-09-20 21:27:55 -04:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Anas Nashif 390537bf68 tracing: trace mutex/semaphore using dedicated calls
Instead of using generic trace calls, use dedicated functions for
tracing sempahores and mutexes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-24 13:21:12 +02:00
Anas Nashif ffe032e757 tracing: ctf: capture thread names in ctf payload
Add thread name to the payload where applicable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-24 13:21:12 +02:00
Anas Nashif 8f9b087e41 tracing: convert ctf timestamp to ns
We have been using cycles instead of time units.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-24 13:21:12 +02:00
Anas Nashif 5c31d00a6a tracing: trace k_sleep
Trace when k_sleep is called.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-24 13:21:12 +02:00
Anas Nashif 6e3d1fbd3c tracing: make uart backend sync capable
This works just fine, no need to make this backend async only.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-24 13:21:12 +02:00
Anas Nashif f5d606ef72 Kconfig: cleanup subsystems
Sort entries alphabetically and cleanup top level menu for each
subsystem. Move stats subsystem Kconfig from debug into its own Kconfig.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-24 10:24:30 +02:00
Emil Obalski 3758a3d4f9 samples: tracing: Enable USB by the application
usb_enable() must be called by the application.
The application may want to register usb_dc_status_callback
and trace usb status codes (usb_dc_status_code).

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-08-13 11:49:47 +02:00
Emil Obalski 1d7505cd7a tracing: Check if init funciton is present.
Tracing backed is not checking if the chosen backed specifies
the init function and is asuming its always present which could
not be true.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-08-13 11:49:47 +02:00
Torsten Rasmussen bb3946666f cmake: fix include directories to work with out-of-tree arch
Include directories for ${ARCH} is not specified correctly.
Several places in Zephyr, the include directories are specified as:
${ZEPHYR_BASE}/arch/${ARCH}/include
the correct line is:
${ARCH_DIR}/${ARCH}/include
to correctly support out of tree archs.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-05 08:06:07 -04:00
Tomasz Bursztyka 7d1af02410 uart: Fix uart_irq_callback_set usage
It was already using uart_irq_callback_user_data_set below, now it also
uses uart_irq_callback_user_data_t as callback type, so let's normalize
the callbacks.

Fixes #26923

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:43:12 +02:00
Daniel Leung d3d2730166 tracing: uart: rename global variable named dev
MISRA-C Rule 5.3 states that identifiers in inner scope should
not hide identifiers in outer scope.

There is a global variable named "dev" to store which UART
device is being used the tracing backend. This name collides
with the parameter of same name in the ISR function. So rename
the global variable.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-07-25 21:26:15 -04:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Joel Westerberg b2da4e24cb tracing: cpu_stats: add missing macro
add missing macro K_MSEC() for CONFIG_TRACING_CPU_STATS_INTERVAL

Signed-off-by: Joel Westerberg <joel@teenage.engineering>
2020-05-21 11:01:50 +02:00
Martí Bolívar 6e8775ff84 devicetree: remove DT_HAS_NODE_STATUS_OKAY
Several reviewers agreed that DT_HAS_NODE_STATUS_OKAY(...) was an
undesirable API for the following reasons:

- it's inconsistent with the rest of the DT_NODE_HAS_FOO names
- DT_NODE_HAS_FOO_BAR_BAZ(node) was agreed upon as a shorthand
  for macros which are equivalent to
  DT_NODE_HAS_FOO(node) && DT_NODE_HAS_BAR(node) &&
- DT_NODE_HAS_BAZ(node), and DT_HAS_NODE_STATUS_OKAY is an odd duck
- DT_NODE_HAS_STATUS(..., okay) was viewed as more readable anyway
- it is seen as a somewhat aesthetically challenged name

Replace all users with DT_NODE_HAS_STATUS(..., okay), which is
semantically equivalent.

This is mostly done with sed, but a few remaining cases were done by
hand, along with whitespace, docs, and comment changes. These special
cases include the Nordic SOC static assert files.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 18:24:42 +02:00
Kumar Gala fdd85d5ad7 dts: Rename DT_HAS_NODE macro to DT_HAS_NODE_STATUS_OKAY
Rename DT_HAS_NODE to DT_HAS_NODE_STATUS_OKAY so the semantics are
clear.  As going forward DT_HAS_NODE will report if a NODE exists
regardless of its status.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-06 05:25:41 -05:00