Skip to content

Commit b4e8a18

Browse files
committed
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>
1 parent 028c1f6 commit b4e8a18

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎arch/cris/Kconfig.debug‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ config DEBUG_NMI_OOPS
3232
If the system locks up without any debug information you can say Y
3333
here to make it possible to dump an OOPS with an external NMI.
3434

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+
3541
endmenu

‎arch/cris/mm/fault.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/mm.h>
88
#include <linux/interrupt.h>
99
#include <linux/module.h>
10+
#include <linux/wait.h>
1011
#include <asm/uaccess.h>
1112

1213
extern int find_fixup_code(struct pt_regs *);
@@ -190,14 +191,20 @@ do_page_fault(unsigned long address, struct pt_regs *regs,
190191
/* User mode accesses just cause a SIGSEGV */
191192

192193
if (user_mode(regs)) {
194+
printk(KERN_NOTICE "%s (pid %d) segfaults for page "
195+
"address %08lx at pc %08lx\n",
196+
tsk->comm, tsk->pid,
197+
address, instruction_pointer(regs));
198+
#ifdef CONFIG_NO_SEGFAULT_TERMINATION
199+
DECLARE_WAIT_QUEUE_HEAD(wq);
200+
wait_event_interruptible(wq, 0 == 1);
201+
#else
193202
info.si_signo = SIGSEGV;
194203
info.si_errno = 0;
195204
/* info.si_code has been set above */
196205
info.si_addr = (void *)address;
197206
force_sig_info(SIGSEGV, &info, tsk);
198-
printk(KERN_NOTICE "%s (pid %d) segfaults for page "
199-
"address %08lx at pc %08lx\n",
200-
tsk->comm, tsk->pid, address, instruction_pointer(regs));
207+
#endif
201208
return;
202209
}
203210

0 commit comments

Comments
 (0)