Skip to contentSkip to conversation

gdb backtrace with core files [PATCH]

DISCUSSION Brian Kuschak 1 participant 1 message Apr 13, 2005 MIPS

lore
Share & tools
lore
#0 lore raw

Ok, based on some off-list discussion, here is a patch which fixes the non-ABI-compilant linux-mips coredump for 2.4.25. This needs to be merged into the 2.4 tree, but is already present in 2.6.

Tested with standard gdb-6.3. Backtracing and register contents are correct now.

Regards,
Brian

Quoted 20 lines · --- Greg Weeks
Quoted 6 lines · Brian Kuschak

Greg,

Is your GDB hosted on MIPS or another machine? Are those patches freely available? If so, can you

OK, I checked.

Most of what's in our patches should be in gdb HEAD. We're currently at
6.2.1 and don't want to take the time to move to head. If you're
interested and no one objects I can post them to the mips list. There
are 37 patches totaling 285K. Not all are mips related and gdb isn't
totally working for me yet.

Quoted 2 lines

Greg Weeks

__________________________________
Yahoo! Mail Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
http://mobile.yahoo.com/learn/mail

arch/mips/kernel/process.c +23 -0
diff -urN --exclude=.svn linux.svn/arch/mips/kernel/process.c linux/arch/mips/kernel/process.c
@@ -128,6 +128,29 @@
 	return 1;
 }
 
+/* bk - backported from 2.6.  coredump was not abi compliant. */
+void dump_regs(elf_greg_t *gp, struct pt_regs *regs)
+{
+	int i;
+
+	for (i = 0; i < EF_REG0; i++)
+		gp[i] = 0;
+	gp[EF_REG0] = 0;
+	for (i = 1; i <= 31; i++)
+		gp[EF_REG0 + i] = regs->regs[i];
+	gp[EF_REG26] = 0;
+	gp[EF_REG27] = 0;
+	gp[EF_LO] = regs->lo;
+	gp[EF_HI] = regs->hi;
+	gp[EF_CP0_EPC] = regs->cp0_epc;
+	gp[EF_CP0_BADVADDR] = regs->cp0_badvaddr;
+	gp[EF_CP0_STATUS] = regs->cp0_status;
+	gp[EF_CP0_CAUSE] = regs->cp0_cause;
+#ifdef EF_UNUSED0
+	gp[EF_UNUSED0] = 0;
+#endif
+}
+
 /*
  * Create a kernel thread
  */
include/asm-mips/elf.h +11 -3
diff -urN --exclude=.svn linux.svn/include/asm-mips/elf.h linux/include/asm-mips/elf.h
@@ -66,9 +66,17 @@
 #define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE	PAGE_SIZE
 
-#define ELF_CORE_COPY_REGS(_dest,_regs)				\
-	memcpy((char *) &_dest, (char *) _regs,			\
-	       sizeof(struct pt_regs));
+/* bk - backport changes from 2.6 to make coredump ABI-compilant */
+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)
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this cpu supports.  This could be done in userspace,
include/asm-mips/reg.h +3 -0
diff -urN --exclude=.svn linux.svn/include/asm-mips/reg.h linux/include/asm-mips/reg.h
@@ -45,6 +45,9 @@
 /*
  * k0/k1 unsaved
  */
+#define EF_REG26		32
+#define EF_REG27		33
+
 #define EF_REG28		34
 #define EF_REG29		35
 #define EF_REG30		36