In certain configurations there could be a warning due to potential
use of uninitialized variable. Add initialization.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
In OpenRISC 1000, the stack pointer is stored in the r1 register. This
patch stores the offset of this value within in the thread structure into
the thread info offsets.
Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
The espressif toolchain variant (ZEPHYR_TOOLCHAIN_VARIANT=espressif)
has not been used for years. Espressif targets are now built using the
Zephyr SDK, which bundles the required Xtensa and RISC-V toolchains.
Remove the cmake/toolchain/espressif/ directory containing generic.cmake,
target.cmake, and Kconfig files that implemented this variant. Also
clean up references in the coredump xtensa gdb stubs, removing the
ESPRESSIF toolchain enum value and related handling code.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Replaces usage of these deprecated macros with ones that support
fixed and mapped partition compatibles. Also includes an update to
hal_espressif which also (rightly or wrongly) has zephyr specific
code in it
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fix error-checking bug in Zephyr `coredump_shell.c` for
`coredump_cmd(COREDUMP_CMD_COPY_STORED_DUMP, ...)`. The function
returns the number of bytes copied (≥ 0) on success and a negative
errno on failure, but the existing checks used `ret != 0` which
incorrectly treated a successful non-zero byte count as an error.
This bug prevented the coredump printing shell commands from working.
signed-off-by: Glenn Andrews <andrewsglenn@meta.com>
`THREAD_RUNTIME_STATS` is not a requirement for the thread analyzer to
operate, merely useful. Switch the control to `configdefault` to leave
it enabled by default, while allowing both applications to disable the
option with `CONFIG_THREAD_RUNTIME_STATS=n` and for alternate defaults
to be specified elsewhere.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Add calls to sys_trace_idle_exit before leaving idle state
to track CPU load.
Extend CPU_LOAD to CPU_AARCH32_CORTEX_R and CPU_AARCH32_CORTEX_A, thus
we can support CPU_LOAD for all CPU_CORTEX.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
When USE_SWITCH=y, the thread struct is now mostly degenerate. Only
the two words for ICI/IT state tracking are required. Eliminate all
the extra fields when not needed and save a bunch of SRAM.
Note a handful of spots in coredump/debug that need a location for the
new stack pointer (stored as the switch handle now) are also updated.
Signed-off-by: Andy Ross <andyross@google.com>
Run the user provided callback for the ISR stacks, instead of ignoring
the callback and printing the summary.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Fix IAR compiler error Pe1153 caused by mismatched alias type between
_kernel_openocd_offsets and _kernel_thread_info_offsets.
The alias now uses [] to match the array type. No functional change.
Signed-off-by: Thinh Le Cong <thinh.le.xr@bp.renesas.com>
Remove duplicated #include directives within the same
preprocessor scope across the Zephyr tree.
Duplicates inside different #ifdef branches are preserved
as they may be intentional.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Currently all drivers which uses a slot from the debug window have fragile
hardwired slot 'mapping', they are locked to use specific slots even if
there are free slots available for them to take.
The new API hides the management of the slots and descriptors and users
can ask, release or even seize slots that they want to use.
Add a new debug slot manager API and a new default no config option to
allow selection between the hardwired or dynamic debug slot management.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Extend the functionality to limit the number of stack bytes
included in the core dump by allowing the limit to be
different for the current thread and remaining threads.
This is useful because it is more likely that we need more
call frames of the thread that was running when the
exception occurred than of the other threads in order to
analyze the exception.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Similar to logging and shell, allow application to override and
extend the ASSERT macros globally. This enables intercepting log strings
at the macro level for things like string tokenizations.
Signed-off-by: Kevin Zeng <zengk@google.com>
This updates the thread analyzer to optionally leverage the kernel's
thread runtime stack safety infrastructure to act upon threads whose
unused stack space has fallen below their configured thresholds.
By default, the thread analyzer merely reports what it has found.
However, a developer can override this behavior with a custom handler
using thread_analyzer_stack_safety_handler_set().
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Use THREAD_ANALYZER_LONG_FRAME_PER_INTERVAL config to reset
longest frame value to zero after printing so that longest frame
now represents longest frame for the most recent interval. The
longest overall frame is often at startup and this modification
allows one to observe subsequent long frames.
Signed-off-by: Jay Lawlor <jlawlor@amperecomputing.com>
Signed-off-by: Dan Kalowsky <dkalowsky@amperecomputing.com>
- Add calls to sys_trace_idle_exit before leaving idle state
to track CPU load
- Extend CPU_LOAD to CPU_CORTEX_A in Kconfig
Signed-off-by: Hoang Nguyen <hoang.nguyen.jx@bp.renesas.com>
Signed-off-by: Nhut Nguyen <nhut.nguyen.kc@renesas.com>
Compilation fails with an "index outside of array bounds" error:
In function 'find_memory_region',
inlined from 'gdb_mem_can_read' at \
zephyr/subsys/debug/gdbstub/gdbstub.c:93:7:
zephyr/subsys/debug/gdbstub/gdbstub.c:65:21: warning: array subscript \
idx is outside array bounds of 'const struct gdb_mem_region[0]' \
[-Warray-bounds]
65 | r = &gdb_mem_region_array[idx];
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
zephyr/subsys/debug/gdbstub/gdbstub.c: In function 'gdb_mem_can_read':
zephyr/subsys/debug/gdbstub/gdbstub.c:42:36: note: while referencing \
'gdb_mem_region_array'
42 | __weak const struct gdb_mem_region gdb_mem_region_array[0];
|
Use a single element array to fix the problem.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Utilize a code spell-checking tool to scan for and correct spelling errors
in `Kconfig` files within the `soc` and `subsys` directory.
Additionally, incorporates a fix recommended by the reviewer.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Use 64 bit values for accumulating idle time and measurement window
as it was possible to get overflow if window was long enough.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This architecture is missing lots of support bits. Stub out this piece so
we can get more things building.
Signed-off-by: Keith Packard <keithp@keithp.com>
- Added a CPU load callback with threshold
- Changed cpu_load to use k_timer instead of k_work
Signed-off-by: Kristoffer Rist Skøien <kristoffer.skoien@nordicsemi.no>
GDB can now also be built without UART support, e.g. on Xtensa it can
use a memory window backend. Update the Kconfig dependency to avoid
build failures.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Add a Kconfig option to be able to postpone entering the GDB stub
until an external trigger.
Signed-off-by: Noah Klayman <noah.klayman@intel.com>
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This is an X86 specific option and should not appear as generic debug
option.
Fixeszephyrproject-rtos/zephyr#52929
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This adds an architecture-specific post processing after memory
writes. This introduction is due to GDB's behavior regarding
breakpoints in code. GDB may choose to write break instructions
instead of using hardware breakpoints to interrupt code
execution (e.g. for manual breakpoint or stepping through code).
There is no separate GDB packet type for this. So we need to
make an assumption that a memory write may be to setup break
instructions. Different architectures may have their own unique
ways of dealing with instruction cache in this situation. So we
defer to the architecture code to handle this.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
When both PRINTK and ASSERT are disabled, the firmware image will still
contain a symbol for assert_print function which increases the memory
footprint by 14 bytes. In this case the function doesn't do anything and
so these 14 bytes are not useful.
This change also reduces the memory footprint elsewhere such as in the
bluetooth subsystem which implements BT_ASSERT_VERBOSE. Now it will be
nop. On nRF52832 this is on the order of 300 - 400 bytes when configured
for peripheral only (just as an example).
Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
Do not override the last known value in backend_ctx.error with the result
of flushing.
Any previous error would be cleared and the coredump would appear to have
succeeded.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add Kconfig option to dump only a portion of stack from the
current stack pointer to the stack end. This is enough to
let gdb reconstruct the stack trace and can significantly
reduce the dump size. This is crucial if the core dump needs
to be sent over radio.
Additionally, add another option to set the limit for the
dumped stack portion.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
GCC and Clang support the undefined behavior sanitizer in any
configuration, the only restriction is that if you want to get nice
messages printed, then you need the ubsan library routines which are only
present for posix architecture or when using picolibc.
This patch adds three new compiler properties:
* sanitizer_undefined. Enables the undefined behavior sanitizer.
* sanitizer_undefined_library. Calls ubsan library routines on fault.
* sanitizer_undefined_trap. Invokes __builtin_trap() on fault.
Overhead for using the trapping sanitizer is fairly low and should be
considered for use in CI once all of the undefined behavior faults in
Zephyr are fixed.
Signed-off-by: Keith Packard <keithp@keithp.com>
By default the thread priority is still the lowest application thread
priority. Allow the priority to be increase by specifying both, the
`override` option as well as the desired `priority`. This pattern was taken
from the shell thread.
Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
Only meant to be used on platforms that would not wipe the RAM on reboot.
This won't work if the platform is halted and restarted as RAM is
volatile, obviously. A relevant fatal error handler needs to be provided
to reboot.
Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
This might come in handy for other coredump backends too, not only flash
one. Obviously: changing the logic to use the coredump generic API instead
of the flash backend's internal functions.
Adding a better output, following how the coredump is actually created:
parsing and printing headers, and their respective content.
Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
dt_chosen_enabled argument was incorrect and it was always returning
n so option could not be used.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Add sys_trace_idle_exit to RISCV cpu_idle functions and allow
enabling CPU_LOAD module for RISCV and disable it for SMP.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Add module which can measure CPU idle time. Idle time is measured in
the pre/post CPU idle hooks but they are not provided by this module.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
const is ignored on the function return type. A warning is reported with
-Wignored-qualifers. Remove the ignored const.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Decoder was casting uint8_t pointers to uint64_t pointers which could
result in double word instruction which does not support unaligned
access on Cortex-M. Issue was revealed when -O3 optimization was
used instead of -Os. In size optimized version, compiler was
using word load and store instructions which support unaligned
access and issue was not visible.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>