Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

CRIS: Add config for pausing a seg-faulting process

Put it on a wait queue, so we can attach gdb to the process
to debug it instead of just killing it.

Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>

+16 -3
+6
arch/cris/Kconfig.debug
··· 32 32 If the system locks up without any debug information you can say Y 33 33 here to make it possible to dump an OOPS with an external NMI. 34 34 35 + config NO_SEGFAULT_TERMINATION 36 + bool "Keep segfaulting processes" 37 + help 38 + Place segfaulting user mode processes on a wait queue instead of 39 + delivering a terminating SIGSEGV to allow debugging with gdb. 40 + 35 41 endmenu
+10 -3
arch/cris/mm/fault.c
··· 7 7 #include <linux/mm.h> 8 8 #include <linux/interrupt.h> 9 9 #include <linux/module.h> 10 + #include <linux/wait.h> 10 11 #include <asm/uaccess.h> 11 12 12 13 extern int find_fixup_code(struct pt_regs *); ··· 191 190 /* User mode accesses just cause a SIGSEGV */ 192 191 193 192 if (user_mode(regs)) { 193 + printk(KERN_NOTICE "%s (pid %d) segfaults for page " 194 + "address %08lx at pc %08lx\n", 195 + tsk->comm, tsk->pid, 196 + address, instruction_pointer(regs)); 197 + #ifdef CONFIG_NO_SEGFAULT_TERMINATION 198 + DECLARE_WAIT_QUEUE_HEAD(wq); 199 + wait_event_interruptible(wq, 0 == 1); 200 + #else 194 201 info.si_signo = SIGSEGV; 195 202 info.si_errno = 0; 196 203 /* info.si_code has been set above */ 197 204 info.si_addr = (void *)address; 198 205 force_sig_info(SIGSEGV, &info, tsk); 199 - printk(KERN_NOTICE "%s (pid %d) segfaults for page " 200 - "address %08lx at pc %08lx\n", 201 - tsk->comm, tsk->pid, address, instruction_pointer(regs)); 206 + #endif 202 207 return; 203 208 } 204 209