Subject: multi-threaded core dump

From: Atsushi Nemoto <[email-masked]>
Date: Mon, 14 Mar 2005 15:58:40 +0900 (JST)

It seems linux-mips does not produce correct register dumps in core
file for multi-threaded programs.  This patch tries to fix it.  Could
you review it?  Thank you.

diff -ur linux-mips/arch/mips/kernel/process.c linux/arch/mips/kernel/process.c
--- linux-mips/arch/mips/kernel/process.c	2005-03-04 10:19:33.000000000 +0900
+++ linux/arch/mips/kernel/process.c	2005-03-14 15:51:43.592837356 +0900
@@ -167,6 +167,14 @@
 #endif
 }
 
+int dump_task_regs (struct task_struct *tsk, elf_gregset_t *regs)
+{
+	struct thread_info *ti = tsk->thread_info;
+	long ksp = (unsigned long)ti + THREAD_SIZE - 32;
+	dump_regs(&(*regs)[0], (struct pt_regs *) ksp - 1);
+	return 1;
+}
+
 int dump_task_fpu (struct task_struct *t, elf_fpregset_t *fpr)
 {
 	memcpy(fpr, &t->thread.fpu, sizeof(current->thread.fpu));
diff -ur linux-mips/include/asm-mips/elf.h linux/include/asm-mips/elf.h
--- linux-mips/include/asm-mips/elf.h	2005-03-04 10:19:35.000000000 +0900
+++ linux/include/asm-mips/elf.h	2005-03-14 15:52:22.000046107 +0900
@@ -225,10 +225,12 @@
 #endif /* CONFIG_MIPS64 */
 
 extern void dump_regs(elf_greg_t *, struct pt_regs *regs);
+extern int dump_task_regs (struct task_struct *, elf_gregset_t *);
 extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *);
 
 #define ELF_CORE_COPY_REGS(elf_regs, regs)			\
 	dump_regs((elf_greg_t *)&(elf_regs), regs);
+#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs)			\
 	dump_task_fpu(tsk, elf_fpregs)
 
---
Atsushi Nemoto

---

From: Ralf Baechle <[email-masked]>
Date: Mon, 14 Mar 2005 10:18:28 +0000

> you review it?  Thank you.

Thanks,  applied.

  Ralf