Subject: show_stack, show_trace does not work for other process

From: Atsushi Nemoto <[email-masked]>
Date: Fri, 10 Dec 2004 14:12:26 +0900 (JST)

On kernel 2.6, SysRq-T (show_task()) can not show correct stack dump
because show_stack() ignores an 'task' argument.  Here is a patch.  I
fixed show_trace too.

--- linux-mips/arch/mips/kernel/traps.c	2004-11-29 11:23:20.000000000 +0900
+++ linux/arch/mips/kernel/traps.c	2004-12-10 14:01:09.078969122 +0900
@@ -82,7 +82,12 @@
 	long stackdata;
 	int i;
 
-	sp = sp ? sp : (unsigned long *) &sp;
+	if (!sp) {
+		if (task && task != current)
+			sp = (unsigned long *) task->thread.reg29;
+		else
+			sp = (unsigned long *) &sp;
+	}
 
 	printk("Stack :");
 	i = 0;
@@ -110,8 +115,12 @@
 	const int field = 2 * sizeof(unsigned long);
 	unsigned long addr;
 
-	if (!stack)
-		stack = (unsigned long*)&stack;
+	if (!stack) {
+		if (task && task != current)
+			stack = (unsigned long *) task->thread.reg29;
+		else
+			stack = (unsigned long *) &stack;
+	}
 
 	printk("Call Trace:");
 #ifdef CONFIG_KALLSYMS

---

From: Ralf Baechle <[email-masked]>
Date: Wed, 15 Dec 2004 15:28:17 +0100

> because show_stack() ignores an 'task' argument.  Here is a patch.  I

Thanks,  applied.

  Ralf