aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/traps.c
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2010-05-20 22:04:26 -0400
committerJason Wessel <jason.wessel@windriver.com>2010-05-20 22:04:26 -0400
commit5dd11d5d47d248850c58292513f0e164ba98b01e (patch)
treefd3c5f27dd40d6a483483de3644ca060a5cafd75 /arch/mips/kernel/traps.c
parentba797b28131b1f1367b662936ea370239d603cff (diff)
mips,kgdb: kdb low level trap catch and stack trace
The only way the debugger can handle a trap in inside rcu_lock, notify_die, or atomic_notifier_call_chain without a recursive fault is to have a low level "first opportunity handler" do_trap_or_bp() handler. Generally this will be something the vast majority of folks will not need, but for those who need it, it is added as a kernel .config option called KGDB_LOW_LEVEL_TRAP. Also added was a die notification for oops such that kdb can catch an oops for analysis. There appeared to be no obvious way to pass the struct pt_regs from the original exception back to the stack back tracer, so a special case was added to show_stack() for when kdb is active because you generally desire to generally look at the back trace of the original exception. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/traps.c')
-rw-r--r--arch/mips/kernel/traps.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index d612c6dcb746..950bde8813fc 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -26,6 +26,7 @@
26#include <linux/kgdb.h> 26#include <linux/kgdb.h>
27#include <linux/kdebug.h> 27#include <linux/kdebug.h>
28#include <linux/notifier.h> 28#include <linux/notifier.h>
29#include <linux/kdb.h>
29 30
30#include <asm/bootinfo.h> 31#include <asm/bootinfo.h>
31#include <asm/branch.h> 32#include <asm/branch.h>
@@ -185,6 +186,11 @@ void show_stack(struct task_struct *task, unsigned long *sp)
185 regs.regs[29] = task->thread.reg29; 186 regs.regs[29] = task->thread.reg29;
186 regs.regs[31] = 0; 187 regs.regs[31] = 0;
187 regs.cp0_epc = task->thread.reg31; 188 regs.cp0_epc = task->thread.reg31;
189#ifdef CONFIG_KGDB_KDB
190 } else if (atomic_read(&kgdb_active) != -1 &&
191 kdb_current_regs) {
192 memcpy(&regs, kdb_current_regs, sizeof(regs));
193#endif /* CONFIG_KGDB_KDB */
188 } else { 194 } else {
189 prepare_frametrace(&regs); 195 prepare_frametrace(&regs);
190 } 196 }
@@ -360,6 +366,8 @@ void __noreturn die(const char * str, struct pt_regs * regs)
360 unsigned long dvpret = dvpe(); 366 unsigned long dvpret = dvpe();
361#endif /* CONFIG_MIPS_MT_SMTC */ 367#endif /* CONFIG_MIPS_MT_SMTC */
362 368
369 notify_die(DIE_OOPS, str, (struct pt_regs *)regs, SIGSEGV, 0, 0);
370
363 console_verbose(); 371 console_verbose();
364 spin_lock_irq(&die_lock); 372 spin_lock_irq(&die_lock);
365 bust_spinlocks(1); 373 bust_spinlocks(1);
@@ -704,6 +712,11 @@ static void do_trap_or_bp(struct pt_regs *regs, unsigned int code,
704 siginfo_t info; 712 siginfo_t info;
705 char b[40]; 713 char b[40];
706 714
715#ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
716 if (kgdb_ll_trap(DIE_TRAP, str, regs, code, 0, 0) == NOTIFY_STOP)
717 return;
718#endif /* CONFIG_KGDB_LOW_LEVEL_TRAP */
719
707 if (notify_die(DIE_TRAP, str, regs, code, 0, 0) == NOTIFY_STOP) 720 if (notify_die(DIE_TRAP, str, regs, code, 0, 0) == NOTIFY_STOP)
708 return; 721 return;
709 722