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