Skip to content

Commit 827a4f7

Browse files
mrkhldnkartben
authored andcommitted
coredump: xtensa: Add support for ARCH_SUPPORTS_COREDUMP_STACK_PTR
Select ARCH_SUPPORTS_COREDUMP_STACK_PTR on xtensa, and provide an implementation for the arch_coredump_stack_ptr_get function. Signed-off-by: Mark Holden <[email protected]>
1 parent ceb567a commit 827a4f7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

arch/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ config XTENSA
135135
select ARCH_HAS_DIRECTED_IPIS
136136
select THREAD_STACK_INFO
137137
select ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET if USERSPACE
138+
select ARCH_SUPPORTS_COREDUMP_STACK_PTR if !SMP
138139
help
139140
Xtensa architecture
140141

arch/xtensa/core/coredump.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ struct xtensa_arch_block {
9292
*/
9393
static struct xtensa_arch_block arch_blk;
9494

95+
#if defined(CONFIG_DEBUG_COREDUMP_THREAD_STACK_TOP)
96+
static uint32_t xtensa_coredump_fault_sp;
97+
#endif
98+
9599
void arch_coredump_info_dump(const struct arch_esf *esf)
96100
{
97101
struct coredump_arch_hdr_t hdr = {
@@ -127,6 +131,9 @@ void arch_coredump_info_dump(const struct arch_esf *esf)
127131

128132
/* Set in top-level CMakeLists.txt for use with Xtensa coredump */
129133
arch_blk.toolchain = XTENSA_TOOLCHAIN_VARIANT;
134+
#if defined(CONFIG_DEBUG_COREDUMP_THREAD_STACK_TOP)
135+
xtensa_coredump_fault_sp = (uint32_t)esf;
136+
#endif
130137

131138
__asm__ volatile("rsr.exccause %0" : "=r"(arch_blk.r.exccause));
132139

@@ -205,3 +212,10 @@ void arch_coredump_priv_stack_dump(struct k_thread *thread)
205212
coredump_memory_dump(start_addr, end_addr);
206213
}
207214
#endif /* CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK */
215+
216+
#if defined(CONFIG_DEBUG_COREDUMP_THREAD_STACK_TOP)
217+
uintptr_t arch_coredump_stack_ptr_get(const struct k_thread *thread)
218+
{
219+
return (thread == _current) ? xtensa_coredump_fault_sp : (uintptr_t)thread->switch_handle;
220+
}
221+
#endif /* CONFIG_DEBUG_COREDUMP_THREAD_STACK_TOP */

0 commit comments

Comments
 (0)