This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 5aa45e328e arch/riscv/ricv_exception.c: Dump the process name at 
exception in user space
5aa45e328e is described below

commit 5aa45e328e792c09875409b28560e67e06fa7f77
Author: Jukka Laitinen <jukka.laiti...@tii.ae>
AuthorDate: Fri Jun 13 12:58:57 2025 +0300

    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 <jukka.laiti...@tii.ae>
---
 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 b15bec514d..05f433f4d0 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;

Reply via email to