1# Debug configuration options 2 3# Copyright (c) 2015 Wind River Systems, Inc. 4# SPDX-License-Identifier: Apache-2.0 5 6 7menu "System Monitoring Options" 8 9source "subsys/debug/thread_analyzer/Kconfig" 10 11endmenu 12 13menu "Debugging Options" 14 15config DEBUG 16 bool "Build kernel with debugging enabled" 17 help 18 Build a kernel suitable for debugging. Right now, this option 19 only disables optimization, more debugging variants can be selected 20 from here to allow more debugging. 21 22config GPROF 23 bool "Generate profiling information" 24 depends on ARCH_POSIX 25 help 26 Generate call graph profile data for the application that can be 27 analyzed with gprof 28 29config ASAN 30 bool "Build with address sanitizer" 31 depends on ARCH_POSIX 32 help 33 Builds Zephyr with Address Sanitizer enabled. This is currently 34 only supported by boards based on the posix architecture, and requires a 35 recent-ish compiler with the ``-fsanitize=address`` command line option, 36 and the libasan library. 37 38 Note that at exit leak detection is disabled for 64-bit boards when 39 GCC is used due to potential risk of a deadlock in libasan. 40 This behavior can be changes by adding leak_check_at_exit=1 to the 41 environment variable ASAN_OPTIONS. 42 43config ASAN_RECOVER 44 bool "Continue after sanitizer errors" 45 depends on ASAN 46 default y 47 help 48 The default behavior of compiler sanitizers is to exit after 49 the first error. Set this to y to enable the code to 50 continue, which can be useful if a code base has known 51 unsuppressed errors. You will also need to set 52 "halt_on_error=0" in your ASAN_OPTIONS environment variable 53 at runtime. 54 55config ASAN_NOP_DLCLOSE 56 bool "Override host OS dlclose() with a NOP" 57 default y if HAS_SDL 58 depends on ASAN 59 help 60 Override host OS dlclose() with a NOP. 61 62 This NOP implementation is needed as workaround for a known limitation in 63 LSAN (leak sanitizer) that if dlcose is called before performing the leak 64 check, "<unknown module>" is reported in the stack traces during the leak 65 check and these can not be suppressed, see 66 https://github.com/google/sanitizers/issues/89 for more info. 67 68config UBSAN 69 bool "Build with undefined behavior sanitizer" 70 help 71 Builds Zephyr with Undefined Behavior Sanitizer enabled. This 72 requires a recent-ish compiler with the ``-fsanitize=undefined`` 73 command line option. 74 75choice UBSAN_MODE 76 prompt "Undefined behavior sanitizer mode" 77 depends on UBSAN 78 default UBSAN_LIBRARY 79 80config UBSAN_LIBRARY 81 bool "Call ubsan routines" 82 depends on ARCH_POSIX || PICOLIBC 83 help 84 Call ubsan library routines when undefined behavior is detected 85 at runtime. This provides information about the faulting 86 condition along with the source filename, line number, types and 87 values involved. This is currently only supported by boards 88 based on the posix architecture or when building with picolibc. 89 90config UBSAN_TRAP 91 bool "Call __builtin_trap" 92 help 93 When undefined behavior is detected, invoke __builtin_trap to 94 cause an exception to be raised. This can be used on any target, 95 but the lack of information makes figuring out the triggering 96 code difficult. 97 98endchoice 99 100config MSAN 101 bool "Build with memory sanitizer" 102 depends on ARCH_POSIX 103 help 104 Builds Zephyr with the LLVM MemorySanitizer enabled. Works 105 only on the posix architecture currently, and only with host 106 compilers recent enough to support the feature (currently 107 clang on x86_64 only). It cannot be used in tandem with 108 CONFIG_ASAN due to clang limitations. You must choose one 109 or the other (but can combine it with CONFIG_UBSAN if you 110 like) 111 112config STACK_USAGE 113 bool "Generate stack usage information" 114 help 115 Generate an extra file that specifies the maximum amount of stack used, 116 on a per-function basis. 117 118config STACK_SENTINEL 119 bool "Stack sentinel" 120 select THREAD_STACK_INFO 121 depends on MULTITHREADING 122 depends on !USERSPACE 123 depends on !MPU_STACK_GUARD 124 help 125 Store a magic value at the lowest addresses of a thread's stack. 126 Periodically check that this value is still present and kill the 127 thread gracefully if it isn't. This is currently checked in four 128 places: 129 130 1) Upon any context switch for the outgoing thread 131 2) Any hardware interrupt that doesn't context switch, the check is 132 performed for the interrupted thread 133 3) When a thread returns from its entry point 134 4) When a thread calls k_yield() but doesn't context switch 135 136 This feature doesn't prevent corruption and the system may be 137 in an unusable state. However, given the bizarre behavior associated 138 with stack overflows, knowledge that this is happening is very 139 useful. 140 141 This feature is intended for those systems which lack hardware support 142 for stack overflow protection, or have insufficient system resources 143 to use that hardware support. 144 145config PRINTK 146 bool "Send printk() to console" 147 default y 148 help 149 This option directs printk() debugging output to the supported 150 console device, rather than suppressing the generation 151 of printk() output entirely. Output is sent immediately, without 152 any mutual exclusion or buffering. 153 154config PRINTK_BUFFER_SIZE 155 int "printk() buffer size" 156 depends on PRINTK 157 depends on USERSPACE 158 default 32 159 help 160 If userspace is enabled, printk() calls are buffered so that we do 161 not have to make a system call for every character emitted. Specify 162 the size of this buffer. 163 164config EARLY_CONSOLE 165 bool "Send stdout at the earliest stage possible" 166 help 167 This option will enable stdout as early as possible, for debugging 168 purpose. For instance, in case of STDOUT_CONSOLE being set it will 169 initialize its driver earlier than normal, in order to get the stdout 170 sent through the console at the earliest stage possible. 171 172config ASSERT 173 bool "__ASSERT() macro" 174 default y if TEST 175 help 176 This enables the __ASSERT() macro in the kernel code. If an assertion 177 fails, the policy for what to do is controlled by the implementation 178 of the assert_post_action() function, which by default will trigger 179 a fatal error. 180 181 Disabling this option will cause assertions to compile to nothing, 182 improving performance and system footprint. 183 184if ASSERT 185 186config ASSERT_LEVEL 187 int "__ASSERT() level" 188 default 2 189 range 0 2 190 help 191 This option specifies the assertion level used by the __ASSERT() 192 macro. It can be set to one of three possible values: 193 194 Level 0: off 195 Level 1: on + warning in every file that includes __assert.h 196 Level 2: on + no warning 197 198config SPIN_VALIDATE 199 bool "Spinlock validation" 200 depends on MULTITHREADING 201 depends on MP_MAX_NUM_CPUS <= 4 202 default y if !FLASH || FLASH_SIZE > 32 203 help 204 There's a spinlock validation framework available when asserts are 205 enabled. It adds a relatively hefty overhead (about 3k or so) to 206 kernel code size, don't use on platforms known to be small. 207 208config SPIN_LOCK_TIME_LIMIT 209 int "Spin lock holding time limit in cycles" 210 default 0 211 depends on SPIN_VALIDATE 212 depends on SYSTEM_CLOCK_LOCK_FREE_COUNT 213 help 214 Assert at the time of unlocking the number of system clock cycles 215 the lock has been held is less than the configured value. Requires 216 the timer driver sys_clock_get_cycles_32() be lock free. 217 218endif # ASSERT 219 220config FORCE_NO_ASSERT 221 bool "Force-disable no assertions" 222 help 223 This boolean option disables Zephyr assertion testing even 224 in circumstances (twister) where it is enabled via 225 CFLAGS and not Kconfig. Added solely to be able to work 226 around compiler bugs for specific tests. 227 228config ASSERT_VERBOSE 229 bool "Verbose assertions" 230 default y 231 depends on PRINTK 232 help 233 This option enables printing an assert message with information about 234 the assertion that occurred. This includes printing the location, 235 the conditional expression and additional message specific to the 236 assert. 237 238config ASSERT_NO_FILE_INFO 239 bool "Disable file info for asserts" 240 help 241 This option removes the name and the path of the source file 242 in which the assertion occurred. Enabling this will save 243 target code space, and thus may be necessary for tiny targets. 244 245config ASSERT_NO_COND_INFO 246 bool "Disable condition info for asserts" 247 help 248 This option removes the assert condition from the printed assert 249 message. Enabling this will save target code space, and thus may be 250 necessary for tiny targets. It is recommended to disable condition 251 info before disabling file info since the condition can be found in 252 the source using file info. 253 254config ASSERT_NO_MSG_INFO 255 bool "Disable message for asserts" 256 help 257 This option removes the additional message from the printed assert. 258 Enabling this will save target code space, and thus may be 259 necessary for tiny targets. It is recommended to disable message 260 before disabling file info since the message can be found in the 261 source using file info. 262 263config ASSERT_TEST 264 bool "Assert test mode" 265 help 266 This option enables the assert test mode, which allows the assert 267 post action handler to return (i.e. not abort) when the asserted 268 condition is false. The tests that validate the assert feature may 269 select this option to allow the test to proceed by implementing a 270 custom assert post action hook. 271 272config OVERRIDE_FRAME_POINTER_DEFAULT 273 bool "Override compiler defaults for -fomit-frame-pointer" 274 help 275 Omitting the frame pointer prevents the compiler from putting the stack 276 frame pointer into a register. Saves a few instructions in function 277 prologues/epilogues and frees up a register for general-purpose use, 278 which can provide good performance improvements on register-constrained 279 architectures like x86. On some architectures (including x86) omitting 280 frame pointers impedes debugging as local variables are harder to 281 locate. At -O1 and above gcc will enable -fomit-frame-pointer 282 automatically but only if the architecture does not require if for 283 effective debugging. 284 285 Choose Y if you want to override the default frame pointer behavior 286 of your compiler, otherwise choose N. 287 288config OMIT_FRAME_POINTER 289 bool "Omit frame pointer" 290 depends on !FRAME_POINTER 291 depends on OVERRIDE_FRAME_POINTER_DEFAULT 292 help 293 Choose Y for best performance. On some architectures (including x86) 294 this will favor code size and performance over debuggability. 295 296 Choose N in you wish to retain the frame pointer. This option may 297 be useful if your application uses runtime backtracing and does not 298 support parsing unwind tables. 299 300 If unsure, disable OVERRIDE_FRAME_POINTER_DEFAULT to allow the compiler 301 to adopt sensible defaults for your architecture. 302 303 304# 305# Generic Debugging Options 306# 307config EXCEPTION_STACK_TRACE 308 bool "Attempt to print stack traces upon exceptions" 309 default y 310 depends on ARCH_STACKWALK 311 help 312 If the architecture fatal handling code supports it, attempt to 313 print a stack trace of function memory addresses when an 314 exception is reported. 315 316# 317# Miscellaneous debugging options 318# 319config DEBUG_THREAD_INFO 320 bool "Thread awareness support" 321 depends on !SMP 322 select THREAD_MONITOR 323 select THREAD_NAME 324 help 325 This option exports an array of offsets to kernel structs to allow 326 for debugger RTOS plugins to determine the state of running threads. 327 328rsource "coredump/Kconfig" 329rsource "symtab/Kconfig" 330endmenu 331 332rsource "gdbstub/Kconfig" 333 334config SEGGER_DEBUGMON 335 bool "Use Segger's J-Link debug monitor implementation" 336 depends on CORTEX_M_DEBUG_MONITOR_HOOK 337 help 338 This option will enable Segger's implementation of 339 the debug monitor interrupt, overriding the 340 default z_arm_debug_monitor symbol. 341 342config MIPI_STP_DECODER 343 bool "MIPI STPv2 decoder" 344 depends on !BIG_ENDIAN 345 help 346 Module decodes a stream of STPv2 data. 347 348config CS_TRACE_DEFMT 349 bool "Coresight Trace Deformatter" 350 help 351 Module is decoding data which is formatted using Coresight 352 Trace Formatter, e.g. when data is put into ETR (Embedded Trace Router). 353 354config CPU_LOAD 355 select TRACING 356 depends on CPU_CORTEX_M || RISCV 357 depends on !SMP 358 bool "CPU load measurement" 359 360# Workaround for not being able to have commas in macro arguments 361DT_CHOSEN_Z_CPU_LOAD_COUNTER := zephyr,cpu-load-counter 362 363config CPU_LOAD_USE_COUNTER 364 bool "Use counter" 365 depends on $(dt_chosen_enabled,$(DT_CHOSEN_Z_CPU_LOAD_COUNTER)) 366 default y 367 select COUNTER 368 help 369 Use counter for tracking CPU idle time. 370 371config CPU_LOAD_LOG_PERIODICALLY 372 int "Report period (in milliseconds)" 373 depends on LOG 374 default 0 375 help 376 Specifies how often CPU load shall be logged. 0 means that there is no logging. 377 378module = CPU_LOAD 379module-str = cpu_load 380source "subsys/logging/Kconfig.template.log_config" 381