1# Copyright (c) 2020 Intel Corporation.
2# SPDX-License-Identifier: Apache-2.0
3
4menuconfig DEBUG_COREDUMP
5	bool "Core Dump"
6	depends on ARCH_SUPPORTS_COREDUMP
7	help
8	  Enable core dump so it can be used for offline debugging.
9
10if DEBUG_COREDUMP
11
12choice DEBUG_COREDUMP_BACKEND
13	prompt "Coredump backend"
14	default DEBUG_COREDUMP_BACKEND_LOGGING
15
16config DEBUG_COREDUMP_BACKEND_LOGGING
17	bool "Use Logging subsystem for coredump"
18	select LOG
19	help
20	  Core dump is done via logging subsystem.
21
22config DEBUG_COREDUMP_BACKEND_FLASH_PARTITION
23	bool "Use flash partition for coredump"
24	depends on FLASH
25	select FLASH_MAP
26	select STREAM_FLASH
27	help
28	  Core dump is saved to a flash partition with DTS alias
29	  "coredump-partition".
30
31config DEBUG_COREDUMP_BACKEND_IN_MEMORY
32	bool "Use memory to store the coredump"
33	help
34	  Core dump (or part of it) is saved in a dedicated area in
35	  memory. Such memory is protected at boot time so it could be
36	  read after a warm reboot. This is obviously NOT a valid solution
37	  when a full hardware reboot cycle occurs (on/off etc..) where
38	  the RAM will most likely loose its data.
39	  See DEBUG_COREDUMP_BACKEND_IN_MEMORY_SIZE on how much space to
40	  reserve.
41
42config DEBUG_COREDUMP_BACKEND_INTEL_ADSP_MEM_WINDOW
43	bool "Use memory window for coredump on Intel ADSP"
44	depends on DT_HAS_INTEL_ADSP_MEM_WINDOW_ENABLED
45	help
46	  Core dump is done via memory window slot[1].
47	  It is Intel ADSP memory region shared with xtensa DSP.
48	  Window 2 slot [1] is reserved for debugging information.
49
50config DEBUG_COREDUMP_BACKEND_OTHER
51	bool "Backend subsystem for coredump defined out of tree"
52	help
53	  Core dump is done via custom mechanism defined out of tree
54
55endchoice
56
57choice DEBUG_COREDUMP_MEMORY_DUMP
58	prompt "Memory dump"
59	default DEBUG_COREDUMP_MEMORY_DUMP_LINKER_RAM
60
61config DEBUG_COREDUMP_MEMORY_DUMP_MIN
62	bool "Minimal"
63	select THREAD_STACK_INFO
64	help
65	  Only dumps the bare minimum memory content.
66	  For example, the thread struct and stack of
67	  the exception thread will be dumped.
68
69	  Don't use this unless you want absolutely
70	  minimum core dump.
71
72config DEBUG_COREDUMP_MEMORY_DUMP_THREADS
73	bool "Threads"
74	depends on !SMP
75	depends on ARCH_SUPPORTS_COREDUMP_THREADS
76	select THREAD_STACK_INFO
77	select DEBUG_THREAD_INFO
78	select DEBUG_COREDUMP_THREADS_METADATA
79	help
80	  Dumps the thread struct and stack of all
81	  threads and all data required to debug threads.
82
83config DEBUG_COREDUMP_MEMORY_DUMP_LINKER_RAM
84	bool "RAM defined by linker section"
85	help
86	  Dumps the memory region between _image_ram_start[]
87	  and _image_ram_end[]. This includes at least data,
88	  noinit, and BSS sections.
89
90	  This is the default.
91
92endchoice
93
94if DEBUG_COREDUMP_BACKEND_FLASH_PARTITION
95
96config DEBUG_COREDUMP_FLASH_CHUNK_SIZE
97	int "Chunk size for flash write operations"
98	default 64
99	help
100	  Larger values can speed up writing due to fewer write operations
101	  being performed in total, but consume more memory.
102
103
104endif # DEBUG_COREDUMP_BACKEND_FLASH_PARTITION
105
106config DEBUG_COREDUMP_SHELL
107	bool "Coredump shell"
108	depends on SHELL
109	help
110	  This shell provides access to coredump and its backends.
111
112config DEBUG_COREDUMP_THREADS_METADATA
113	bool "Threads metadata"
114	depends on !SMP
115	depends on ARCH_SUPPORTS_COREDUMP_THREADS
116	select DEBUG_THREAD_INFO
117	help
118	  Core dump will contain the threads metadata section containing
119	  any necessary data to enable debugging threads
120
121config DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK
122	bool "Dump privilege stack of user threads"
123	default y
124	depends on ARCH_SUPPORTS_COREDUMP_PRIV_STACKS
125	depends on USERSPACE
126	help
127	  Dump the privilege stack of user threads.
128
129	  Say n to conserve space on coredump backend or if you will never
130	  need to look into the privilege stacks.
131
132config DEBUG_COREDUMP_BACKEND_IN_MEMORY_SIZE
133	int "In-memory coredump size"
134	default 128
135	depends on DEBUG_COREDUMP_BACKEND_IN_MEMORY
136	help
137	  Sets the dedicated memory area where a coredump can be stored
138	  and accessed after a warm reboot. It has to be able to hold at
139	  least the info dumped by arch_coredump_info_dump().
140	  Extra memory region will silently be ignored if there isn't
141	  enough space.
142
143module = DEBUG_COREDUMP
144module-str = coredump
145source "subsys/logging/Kconfig.template.log_config"
146
147config DEBUG_COREDUMP_THREAD_STACK_TOP
148	bool "Dump top of stack only"
149	default y if DEBUG_COREDUMP_MEMORY_DUMP_MIN
150	depends on DEBUG_COREDUMP_MEMORY_DUMP_MIN || \
151		   DEBUG_COREDUMP_MEMORY_DUMP_THREADS
152	depends on ARCH_SUPPORTS_COREDUMP_STACK_PTR
153	help
154	  This option enables dumping only the top portion of each thread's
155	  stack, rather than the entire stack region. The top of the stack is
156	  defined as the area from the stack pointer to the stack end, but the
157	  size of this region can additionally be constrained using the
158	  DEBUG_COREDUMP_THREAD_STACK_TOP_LIMIT option.
159
160config DEBUG_COREDUMP_THREAD_STACK_TOP_LIMIT
161	int "Stack top size limit"
162	default -1
163	depends on DEBUG_COREDUMP_THREAD_STACK_TOP
164	help
165	  See the description of the DEBUG_COREDUMP_THREAD_STACK_TOP option.
166	  The value -1 indicates that there is no limit, meaning that the stack
167	  is dumped till the end of its region.
168
169
170endif # DEBUG_COREDUMP
171