This patch fixes pt_regs data for the sleeping thread to be seen by kgdb
and introduces fixup code as a macro to be used when stack trace is obtained.
Dmitry
diff -ur linux/arch/mips/kernel/kgdb.c linux/arch/mips/kernel/kgdb.c
--- linux/arch/mips/kernel/kgdb.c 2009-05-09 14:40:12.000000000 +0400
+++ linux/arch/mips/kernel/kgdb.c 2009-05-09 15:19:33.000000000 +0400
@@ -37,6 +37,7 @@
#include <asm/gdb-stub.h>
#include <asm/cacheflush.h>
#include <asm/kdebug.h>
+#include <asm/stacktrace.h>
static struct hard_trap_info {
unsigned char tt; /* Trap type code for MIPS R3xxx and R4xxx */
@@ -210,11 +211,13 @@
void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct
*p)
{
int reg;
- struct thread_info *ti = p->thread_info;
- unsigned long ksp = (unsigned long)ti + THREAD_SIZE - 32;
- struct pt_regs *regs = (struct pt_regs *)ksp - 1;
+ struct pt_regs area, *regs;
gdb_reg_t *ptr = (gdb_reg_t*)gdb_regs;
+ regs = &area;
+ *regs = *task_pt_regs(p);
+ prepare_regs(area, p);
+
for (reg = 0; reg < 16; reg++)
*(ptr++) = regs->regs[reg];
diff -ur linux/arch/mips/kernel/stacktrace.c linux/arch/mips/kernel/stacktrace.c
--- linux/arch/mips/kernel/stacktrace.c 2007-04-26 07:08:32.000000000 +0400
+++ linux/arch/mips/kernel/stacktrace.c 2009-05-09 15:20:05.000000000 +0400
@@ -71,11 +71,9 @@
WARN_ON(trace->nr_entries || !trace->max_entries);
- if (task && task != current) {
- regs->regs[29] = task->thread.reg29;
- regs->regs[31] = 0;
- regs->cp0_epc = task->thread.reg31;
- } else {
+ if (task && task != current)
+ prepare_regs(dummyregs, task);
+ else {
if (!task)
task = current;
prepare_frametrace(regs);
diff -ur linux/arch/mips/kernel/traps.c linux/arch/mips/kernel/traps.c
--- linux/arch/mips/kernel/traps.c 2009-05-09 14:40:12.000000000 +0400
+++ linux/arch/mips/kernel/traps.c 2009-05-09 15:19:12.000000000 +0400
@@ -199,13 +199,10 @@
regs.regs[31] = 0;
regs.cp0_epc = 0;
} else {
- if (task && task != current) {
- regs.regs[29] = task->thread.reg29;
- regs.regs[31] = 0;
- regs.cp0_epc = task->thread.reg31;
- } else {
+ if (task && task != current)
+ prepare_regs(regs, task);
+ else
prepare_frametrace(®s);
- }
}
show_stacktrace(task, ®s);
}
diff -ur linux/include/asm-mips/stacktrace.h linux/include/asm-mips/stacktrace.h
--- linux/include/asm-mips/stacktrace.h 2007-04-26 07:08:32.000000000 +0400
+++ linux/include/asm-mips/stacktrace.h 2009-05-09 15:25:05.000000000 +0400
@@ -41,4 +41,11 @@
: : "memory");
}
+/* The same as above, but for sleeping thread. */
+#define prepare_regs(ptregs,tsk) do { \
+ ptregs.regs[29] = tsk->thread.reg29; \
+ ptregs.regs[31] = 0; \
+ ptregs.cp0_epc = tsk->thread.reg31; \
+ } while (0)
+
#endif /* _ASM_STACKTRACE_H */
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Kgdb-bugreport mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport