arch/risc-v: dump backtrace when killing a task with SIGSEGV

When riscv_fault_handler() kills a user task with SIGSEGV, it previously
produced no stack trace, making the crash hard to diagnose.  Call
sched_dumpstack() on the killed task when SCHED_BACKTRACE is enabled.

Assisted-by: Claude Code:claude-sonnet-5
Signed-off-by: liang.huang <liang.huang@houmo.ai>
This commit is contained in:
liang.huang 2026-07-18 11:38:08 +08:00 committed by Alan C. Assis
parent 7c75dbae2b
commit ed368470d1

View file

@ -119,6 +119,10 @@ static void riscv_fault_handler(uintreg_t cause, void *regs)
_alert("Segmentation fault in %s (PID %d: %s)\n", get_task_name(ptcb),
tcb->pid, get_task_name(tcb));
#ifdef CONFIG_SCHED_BACKTRACE
sched_dumpstack(tcb->pid);
#endif
tcb->flags |= TCB_FLAG_FORCED_CANCEL;
/* Return to _exit function in privileged mode with argument SIGSEGV */