From 5aa45e328e792c09875409b28560e67e06fa7f77 Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Fri, 13 Jun 2025 12:58:57 +0300 Subject: [PATCH] arch/riscv/ricv_exception.c: Dump the process name at exception in user space This helps in debugging loaded elf files in CONFIG_BUILD_KERNEL. If a user space exception occurs, one would beed the process name in order to debug the correct process/elf file. Only dumping the pid and name of the crashed task/thread doesn't help, since different processes may have helper threads with the same name. Signed-off-by: Jukka Laitinen --- arch/risc-v/src/common/riscv_exception.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/risc-v/src/common/riscv_exception.c b/arch/risc-v/src/common/riscv_exception.c index b15bec514de..05f433f4d03 100644 --- a/arch/risc-v/src/common/riscv_exception.c +++ b/arch/risc-v/src/common/riscv_exception.c @@ -106,7 +106,9 @@ int riscv_exception(int mcause, void *regs, void *args) if (((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL) && ((tcb->flags & TCB_FLAG_SYSCALL) == false)) { - _alert("Segmentation fault in PID %d: %s\n", + struct tcb_s *ptcb = nxsched_get_tcb(tcb->group->tg_pid); + + _alert("Segmentation fault in %s (PID %d: %s)\n", get_task_name(ptcb), tcb->pid, get_task_name(tcb)); tcb->flags |= TCB_FLAG_FORCED_CANCEL;