Commit graph

54 commits

Author SHA1 Message Date
Johan Hedberg
a7f3875134 debug: Fix BOOT_TIME_MEASUREMENT dependencies
The boot time measurement can also run with the HPET timer so there's
no reason to restrict it to APIC.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-05-19 17:25:36 +02:00
Alexey Brodkin
bf981135a0 OpenOCD: Make incompatible with SMP
In case of SMP (i.e. multiple execution units processing
the same list of tasks) we cannot use the same data structures for
getting data about active tasks as with just one processor (UP).

So until explicit support of SMP is added make sure we don't allow
to select both OPENOCD & SMP simultaneously.

Moreover starting from
commit a203d21962 ("kernel: remove legacy fields in _kernel")
this will lead to build-time error if MP_NUM_CPUS > 1.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2020-05-10 16:18:27 +02:00
Joakim Andersson
27ef15b8f5 debug: thread_analyzer: Implement thread analyzer
Thread analyzer is simple module that helps in printing thread
information, like stacks usage statistics.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
Signed-off-by: Bartosz Gentkowski <bartosz.gentkowski@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-28 09:11:13 -04:00
Ulf Magnusson
eddd98f811 kconfig: Replace some single-symbol 'if's with 'depends on'
I think people might be reading differences into 'if' and 'depends on'
that aren't there, like maybe 'if' being needed to "hide" a symbol,
while 'depends on' just adds a dependency.

There are no differences between 'if' and 'depends on'. 'if' is just a
shorthand for 'depends on'. They work the same when it comes to creating
implicit menus too.

The way symbols get "hidden" is through their dependencies not being
satisfied ('if'/'depends on' get copied up as a dependency on the
prompt).

Since 'if' and 'depends on' are the same, an 'if' with just a single
symbol in it can be replaced with a 'depends on'. IMO, it's best to
avoid 'if' there as a style choice too, because it confuses people into
thinking there's deep Kconfig magic going on that requires 'if'.

Going for 'depends on' can also remove some nested 'if's, which
generates nicer symbol information and docs, because nested 'if's really
are so simple/dumb that they just add the dependencies from both 'if's
to all symbols within.

Replace a bunch of single-symbol 'if's with 'depends on' to despam the
Kconfig files a bit and make it clearer how things work. Also do some
other minor related dependency refactoring.

The replacement isn't complete. Will fix up the rest later. Splitting it
a bit to make it more manageable.

(Everything above is true for choices, menus, and comments as well.)

Detected by tweaking the Kconfiglib parsing code. It's impossible to
detect after parsing, because 'if' turns into 'depends on'.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-08 08:32:42 -05:00
Anas Nashif
fad8701748 tracing: cleanup and split segger/rtt configuration options
Move rtt configuration options to drivers/debug and split the
systemview configuration.

drivers/debug will service for this class of drivers that are enabled in
debug mode only and provide a hardware interface to the system.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-02-07 15:58:05 -05:00
Anas Nashif
41abcc57c1 tracing: move tracing under subsys/
Tracing subsystem is growing and although related to debugging, it does
deserve to belong into its own subsystem.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-02-07 15:58:05 -05:00
Wentong Wu
4f4b8ef4ea tracing: add TRACING_TEST Kconfig option
Add Kconfig option TRACING_TEST which can be used to
customize tracing packet format (currently supporting
string format and data format) for testing purpose.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-02-05 23:54:26 -05:00
Wentong Wu
aa5d45d7cc tracing: add TRACING_ISR Kconfig
Add TRACING_ISR Kconfig to help high latency backend working well.

Currently the ISR tracing hook function is put at the begining and
ending of ISR wrapper, when there is ISR needed in the tracing path
(especially tracing backend), it will cause tracing buffer easily
be exhausted if async tracing method enabled. Also it will increase
system latency if all the ISRs are traced. So add TRACING_ISR to
enable/disable ISR tracing here. Later a filter out mechanism based
on irq number will be added.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-02-05 23:54:26 -05:00
Wentong Wu
10a669ea87 tracing: ctf: adapt ctf implementation to tracing infrastructure
Adapt ctf implementation to tracing infrastructure.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-02-05 23:54:26 -05:00
Wentong Wu
8ccc04de6a tracing: add infrastructure for collection of tracing data
First, this commit adds user interface in tracing_format.h which
can trace both string format and data format packet.

Second, it adds method both for asynchronous and synchronous way.
For asynchronous method, tracing packet will be buffered in tracing
buffer first, tracing thread will output the stream data with the
help of tracing backend when tracing thread get scheduled.

Third, it adds UART and USB tracing backend for asynchronous
tracing method, and adds POSIX tracing backend for synchronous
tracing way.

Also it can receive command from host to dynamically enable and
disable tracing to have host capture tracing data conveniently.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-02-05 23:54:26 -05:00
Joakim Andersson
4af5815bf4 assert: Add option to disable assertion messages
Add option to disable the assertion message, this makes all __ASSERT
behave as __ASSERT_NO_MSG instead.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Joakim Andersson
7a433325f5 assert: Add verbose option to assertion messages
Add verbose option which would control if the assertion mechanism prints
any information at all. With this disabled they application will have to
use the stack-frame to locate the assertion location.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Joakim Andersson
94d331b2eb assert: Add option to disable condition from assertion message
Add Kconfig option to disable the conditional expression in the assert
that failed. This would save code space, and file and line provides
better information than the conditional expression in case where
the same expression would be asserted upon.

For example __ASSERT_NO_MSG(buf) wouldn't make much sense in
configuration where CONFIG_ASSERT_NO_FILE_INFO was enabled.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Danny Oerndrup
c9d78401cc spinlock: Make SPIN_VALIDATE a Kconfig option.
SPIN_VALIDATE is, as it was previously, enabled per default when having
less than 4 CPUs and either having no flash or a flash size greater than
32kB.

Small targets, which needs to have asserts enabled, can chose to have
the spinlock validation enabled or not and thereby decide whether the
overhead added is acceptable or not.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-12-20 19:51:16 -05:00
Jan Van Winkel
3da873a0c0 debug: asan: Added leak suppression for SDL2 & X11
Added leak suppression, by implementing __lsan_default_suppressions
function, for SDL2 and X11 library which are used by the SDL display
driver.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-12-09 16:38:48 -05:00
Jan Van Winkel
4286cb830f debug: Disable "at exit" LSAN leak check
Disable "at exit" memory leak check by LSAN if building for a 64-bit
target with GCC. This is need to fix a potential deadlock in GCCs
libasan implementation.

Fixes #20122

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-11-05 09:46:02 -08:00
Ulf Magnusson
bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Danny Oerndrup
b8add4aa0b kconfig: assert: Introduce kconfig option ASSERT_NO_FILE_INFO
Default behavior is to include __FILE__ info with all of the Zephyr
assert macros, __ASSERT, __ASSERT_NO_MSG and __ASSERT_LOC. Setting the
ASSERT_NO_FILE_INFO kconfig option, replaces the __FILE__ with an
empty string, thus removing the file information from the asserts.

The intention here is to allow for code space limited devices to run
with asserts enabled.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-10-14 09:07:29 -05:00
Jan Van Winkel
23a866b828 cmake: toolchain abstraction for undefined behaviour sanitizer
Added toolchain abstraction for undefined behaviour sanitizer

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-10-07 15:00:20 +02:00
Andrew Boie
4ce988ab43 doc: provide error handling documentation
We don't really have docs on how fatal errors are induced
or handled. Provide some documentation that covers:

- Assertions (runtime and build)
- Kernel panic and oops conditions
- Stack overflows
- Other exceptions
- Exception handling policy

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-09-23 23:45:08 +02:00
Charles E. Youse
3036faf88a tests/benchmarks: fix BOOT_TIME_MEASUREMENT
The boot time measurement sample was giving bogus values on x86: an
assumption was made that the system timer is in sync with the CPU TSC,
which is not the case on most x86 boards.

Boot time measurements are no longer permitted unless the timer source
is the local APIC. To avoid issues of TSC scaling, the startup datum
has been forced to 0, which is in line with the ARM implementation
(which is the only other platform which supports this feature).

Cleanups along the way:

As the datum is now assumed zero, some variables are removed and
calculations simplified. The global variables involved in boot time
measurements are moved to the kernel.h header rather than being
redeclared in every place they are referenced. Since none of the
measurements actually use 64-bit precision, the samples are reduced
to 32-bit quantities.

In addition, this feature has been enabled in long mode.

Fixes: #19144

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-09-21 16:43:26 -07:00
Charles E. Youse
efcecea6aa subsys/debug: eliminate PEFORMANCE_METRICS and CPU_CLOCK_FREQ_MHZ
Neither of these options is actually used; CPU_CLOCK_FREQ_MHZ appears
to have been part of x86 BOOT_TIME_MEASUREMENT at some point, and
PERFORMANCE_METRICS is the stillborn cousin of EXECUTION_BENCHMARKS.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-09-21 16:43:26 -07:00
David B. Kinder
6000a6205a doc: prepare for improving doc API linking
Linking to API material requires knowing the pecularities of how
doxygen, sphinx, and breathe work. In an attempt to hide some of this
we're preparing the current docs to allow use of configuration defaults
that will let us more simply use a default role that will hunt for a
reference target in the various domains that are available by using a
default "role" of "all".  This will let us use the simple notation
`functionname` or `typename` without fully specifying the reference as
:c:func:`functionname`.

This patch cleans up exising docs that were (incorrectly) using single
backtics where double backtics should have been used, and also found
some typos (such as a space between the role name and the reference,
such as :file: `filename`, and a missing colon such as
c:func:`functionname`)

This is a start to address issue #14313

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-03-15 05:47:19 +01:00
Ulf Magnusson
53376394b7 kconfig: Remove blank lines at the beginning/end of files
Maybe this is some "just in case" thing that got copied around. There's
no need to have a blank line at the beginning or end of Kconfig files.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-13 07:29:42 -05:00
François Delawarde
74f9901b8d debug: Place Kconfig tracing options in debug submenu
Fix Kconfig options placed incorrectly in top level menu.

Signed-off-by: François Delawarde <fnde@oticon.com>
2019-02-14 10:29:06 -05:00
François Delawarde
4fac841869 debug: CTF Tracing with POSIX backend
This commit implements a CTF-backend for Zephyr's tracing API.
The CTF-backend itself is split in a middle-layer and a bottom-layer.
- Middle-layer decides the payload in event transactions,
- Bottom-layer implements the IO transport.

A simple POSIX bottom-layer is provided so far.

Signed-off-by: François Delawarde <fnde@oticon.com>
2019-02-01 08:56:02 -05:00
Anas Nashif
5f371e038f debug: move segger configs to subsys/debug
We have dependency on this module in code which is part of Zephyr. When
this module is split out of the tree we need to be able to build. Move
this Kconfig part to be part of zephyr and keep the external code in
ext/ with plan to split it out on the future.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-22 07:45:22 -05:00
David B. Kinder
06d78354ae doc: regular misspelling scan
Fix misspellings in documentation (.rst, Kconfig help text, and .h
doxygen API comments), missed during regular reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-12-26 13:27:14 -05:00
Marek Pieta
788210816d debug: tracing: Add CPU stats module
Change adds CPU stats module for tracing hooks. Module provides
information about percent of CPU usage based on tracing hooks
for threads switching in and out, interrupts enters and exits.
cpu_stats only distinguishes between idle thread, non idle
thread and scheduler.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2018-11-30 11:01:32 -08:00
Andy Ross
923e1b60e7 misc/printk: Make the default char_out routine weak
Architecture init code and/or HAL layers often have a working
"putchar" routine available long before the Zephyr driver layer is
initialized.

Make the default printk() output a weak symbol, so it can be
overridden on these platforms.

Also remove the kconfig depedency on CONSOLE_HAS_DRIVER, as this is a
non-driver mechanism.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-11-14 19:08:27 -05:00
Anas Nashif
86ad37a533 kconfig: distribute misc/Kconfig option where they belong
Move misc/Kconfig options to where they belong. misc/Kconfig was used as
a catch-all, but we are now able to put things in a better place.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-12 08:01:15 -05:00
Maureen Helm
1b2ca67f78 debug: openocd: Add thread name to openocd offsets
Adds the thread name to the openocd offsets array so openocd and pyocd
can show thread names in the debugger.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-10-31 12:05:11 -04:00
Anas Nashif
483910ab4b systemview: add support natively using tracing hooks
Add needed hooks as a subsystem that can be enabled in any application.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-08-21 05:45:47 -07:00
Ulf Magnusson
1073882998 subsys: kconfig: Remove 'default n' properties and clean up a bit
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.

Remove some 'default ""' properties on string symbols too.

Also make definitions more consistent by converting some

  config FOO
  	<type>
  	prompt "foo"

definitions to a shorter form:

  config FOO
  	<type> "foo"

This shorthand works for int/hex/string symbols too, not just for bool
symbols.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-12 23:13:22 -04:00
Leandro Pereira
91220ba640 boards: native_posix: Add option to build with Address Sanitizer
Address Sanitizer helps finding issues related to memory: buffer
overflows, usage of uninitialized memory, etc.  This is available in
both Clang and GCC for a while, and, since the POSIX port is only
meant for testing, this will help find issues.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-07-03 17:06:25 -04:00
Andrew Boie
bc40f9340d debug: enable assertions for all tests
This keeps biting us; sanitycheck turns on assertions by
default for tests, but standalone builds, or builds done
for other test infrastructure do not. Put all builds in
the same state.

Specific tests (such as benchmarks) can override this with
CONFIG_FORCE_NO_ASSERT.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-24 15:12:56 -07:00
Andy Gross
abf77ef753 subsys: debug: Fix stack sentinel dependencies
This patch restricts the stack sentinel to only be allowed if the
USERSPACE configuration option is not set.  The stack sentinel feature
is redundant if used in conjunction with the USERSPACE, due to the
protection mechanisms in place for stacks.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-05-10 14:16:46 -07:00
Leandro Pereira
2f5659d4d2 arch: x86: Unwind the stack on fatal errors
Prints up to 8 stack frames, with the following format:
  RETURN_ADDR(ARGUMENTS)

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-03-16 14:12:15 -07:00
Andy Ross
6eef2f1485 misc: Add a FORCE_NO_ASSERT kconfig directive
The mbedtls test is hitting a compiler bug where two subtests will
soft fail on qemu_xtensa when assertions are enabled.  This is despite
the fact that:

+ The failure is entirely internal to the mbedtls suite.
+ The mbedtls code does not use zephyr asserts
+ The mbedtls code does not call into zephyr code that might assert.
+ The behavior persists even when an irq_lock() is held across the
  entire test, ruling out any asserts in interrupt/exception context.
+ And EVEN WHEN the mbedtls library blobs are bytewise identical
  between assert and non-assert cases.

The bug seems to be a layout thing where the mbedtls code behavior
differently based on code address and/or link-time optimizations
(xtensa has a few).

Unfortunately sanitycheck enables assertions by setting CFLAGS
directly and not via kconfig, so we can't fix this by turning the
feature off in an app right now.  This patch adds a simple "override"
flag that can be set by apps like this that hit bugs.

Again, note that zephyr assertions are not used nor needed by this one
test.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-02-16 10:44:29 -05:00
Anas Nashif
ff42bdd0a0 debug: remove option GDB_INFO
This feature is X86 only and is not used or being tested. It is legacy
feature and no one can prove it actually works. Remove it until we have
proper documentation and samples and multi architecture support.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-12 13:58:28 -08:00
Paul Sokolovsky
84e3d3e7e8 libc: Kconfig: Move STDOUT_CONSOLE from subsys/debug
This option is clearly not related to debugging, but affects libc
features.

Fixes: #5566

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-11 12:47:10 -05:00
Anas Nashif
429c2a4d9d kconfig: fix help syntax and add spaces
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-13 17:43:28 -06:00
Anas Nashif
f46c0c2472 kconfig: remove deprecated DEBUG_TRACING_KERNEL_OBJECTS
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-09 08:48:51 -06:00
Anas Nashif
a254359c1a kconfig: stack_usage: remove extra space
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-09 08:48:51 -06:00
Anas Nashif
1092a25978 kconfig: move GDB_INFO kconfig to subsys/debug
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-27 22:15:30 -05:00
Andrew Boie
756f907274 misc: userspace support for printk()
To avoid making a system call for every character emitted, there is now
a small line buffer if userspace is enabled. The interface to the kernel
is a new system call which takes a sized buffer of console data.

If userspace is not enabled this works like before.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-11 09:23:57 -07:00
Andrew Boie
0f669132a0 kernel: remove gdb_server
This is unmaintained and currently has no known users. It was
added to support a Wind River project. If in the future we need it
again, we should re-introduce it with an exception-based mechanism
for catching out-of-bounds memory queries from the debugger.

The mem_safe subsystem is also removed, it is only used by the
GDB server. If its functionality is needed in the future, it
shoudl be replaced with an exception-based mechanism.

The _image_{ram, rom, text}_{start, end} linker variables have
been left in place, they will be re-purposed and expanded to
support memory protection.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-19 14:29:40 -04:00
Andrew Boie
5dcb279df8 debug: add stack sentinel feature
This places a sentinel value at the lowest 4 bytes of a stack
memory region and checks it at various intervals, including when
servicing interrupts or context switching.

This is implemented on all arches except ARC, which supports stack
bounds checking directly in hardware.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-13 15:14:41 -04:00
Leandro Pereira
86b0260e97 kconfig: Move debugging-related options from misc/ to subsys/debug/
This should fix the grouping for debugging options appearing in the
main "menuconfig" menu.

Change-Id: I7ddf3a6f3d025bf82ba63099b30e47a40d7c3187
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-04-28 23:41:16 +00:00
Anas Nashif
919b3f0878 kconfig: fixed Kconfig name in comments
Change-Id: Ia22e9df4b9d836635aef1d4b59efec8ce58815d6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-10 16:07:09 +00:00