Skip to contentSkip to conversation

gdb chokes on core from 64-bit kernel (patch)

DISCUSSION Ralf Baechle 2 participants 2 messages Nov 9, 2007 – Nov 15, 2007 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 25 lines · Andrew Sharp

The gdb from debian etch (6.4.90-debian) doesn't like core files produced by 64-bit kernel it seems. I've got this patch which seems to do the job, but I'm unclear on what other implications it might have, if any.

arch/mips/kernel/binfmt_elfo32.c +5 -1
index 993f7ec..58533dc 100644
@@ -54,9 +54,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 
 #include <asm/processor.h>
 #include <linux/module.h>
-#include <linux/elfcore.h>
 #include <linux/compat.h>
 
+void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs);
+#undef ELF_CORE_COPY_REGS
+#define ELF_CORE_COPY_REGS(_dest,_regs) elf32_core_copy_regs(_dest,_regs);
+#include <linux/elfcore.h>
+
 #define elf_prstatus elf_prstatus32
 struct elf_prstatus32
 {

arch/mips/kernel/binfmt_elfo32.c jiffies_to_compat_timeval(unsigned long jiffies, struct comp · line 118

Quoted 9 lines
arch/mips/kernel/binfmt_elfo32.c +0 -3
@@ -109,9 +113,6 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct comp
        value->tv_usec = rem / NSEC_PER_USEC;
 }
 
-#undef ELF_CORE_COPY_REGS
-#define ELF_CORE_COPY_REGS(_dest,_regs) elf32_core_copy_regs(_dest,_regs);
-
 void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs)
 {
        int i;

Looks like it's a larger change than needed.

Quoted 14 lines
include/asm-mips/reg.h +1 -1
index 634b55d..b44b308 100644
@@ -12,7 +12,7 @@
 #ifndef __ASM_MIPS_REG_H
 #define __ASM_MIPS_REG_H
 
-
+#define WANT_COMPAT_REG_H
 #if defined(CONFIG_32BIT) || defined(WANT_COMPAT_REG_H)
 
 #define EF_R0                  6

include/asm-mips/reg.h line 75

Quoted 8 lines
include/asm-mips/reg.h +1 -1
@@ -69,7 +69,7 @@
 
 #endif
 
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) && !defined(WANT_COMPAT_REG_H)
 
 #define EF_R0                   0
 #define EF_R1                   1

This change breaks the native 64-bit and N32 ptrace and core dumpers.

I suggest something more minimal like the below patch. Does that one do the trick for you?

Ralf

 arch/mips/kernel/ptrace32.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
arch/mips/kernel/ptrace32.c +3 -0
index 76818be..44109fb 100644
@@ -14,6 +14,9 @@
  * At this time Linux/MIPS64 only supports syscall tracing, even for 32-bit
  * binaries.
  */
+
+#define WANT_COMPAT_REG_H
+
 #include <linux/compiler.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
#2 lore raw
Quoted 30 lines · On Fri, 9 Nov 2007 09:07:57 +0000 Ralf Baechle <[email protected]> wrote:
Quoted 28 lines · Andrew Sharp

The gdb from debian etch (6.4.90-debian) doesn't like core files produced by 64-bit kernel it seems. I've got this patch which seems to do the job, but I'm unclear on what other implications it might have, if any.

(quoted diff) +0 -0

b/arch/mips/kernel/binfmt_elfo32.c index 993f7ec..58533dc 100644

arch/mips/kernel/binfmt_elfo32.c +3 -1
@@ -54,9 +54,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 
 #include <asm/processor.h>
 #include <linux/module.h>
-#include <linux/elfcore.h>
 #include <linux/compat.h>
 
+void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs);
+#undef ELF_CORE_COPY_REGS
+#define ELF_CORE_COPY_REGS(_dest,_regs)

elf32_core_copy_regs(_dest,_regs); +#include <linux/elfcore.h>

arch/mips/kernel/binfmt_elfo32.c +1 -0
+
 #define elf_prstatus elf_prstatus32
 struct elf_prstatus32
 {
@@ -109,9 +113,6 @@ jiffies_to_compat_timeval(unsigned long
 jiffies, struct comp value->tv_usec = rem / NSEC_PER_USEC;
 }
 
Quoted 8 lines
Quoted 6 lines
arch/mips/kernel/binfmt_elfo32.c +0 -2
-#undef ELF_CORE_COPY_REGS
-#define ELF_CORE_COPY_REGS(_dest,_regs)

elf32_core_copy_regs(_dest,_regs); -
void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs)

 {
        int i;

Looks like it's a larger change than needed.

Which change? Both files?

Quoted 44 lines
Quoted 14 lines
include/asm-mips/reg.h +1 -1
index 634b55d..b44b308 100644
@@ -12,7 +12,7 @@
 #ifndef __ASM_MIPS_REG_H
 #define __ASM_MIPS_REG_H
 
-
+#define WANT_COMPAT_REG_H
 #if defined(CONFIG_32BIT) || defined(WANT_COMPAT_REG_H)
 
 #define EF_R0                  6

include/asm-mips/reg.h line 75

Quoted 8 lines
include/asm-mips/reg.h +1 -1
@@ -69,7 +69,7 @@
 
 #endif
 
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) && !defined(WANT_COMPAT_REG_H)
 
 #define EF_R0                   0
 #define EF_R1                   1

This change breaks the native 64-bit and N32 ptrace and core dumpers.

I suggest something more minimal like the below patch. Does that one do the trick for you?

Ralf

 arch/mips/kernel/ptrace32.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
arch/mips/kernel/ptrace32.c +0 -0
index 76818be..44109fb 100644
@@ -14,6 +14,9 @@
  * At this time Linux/MIPS64 only supports syscall tracing, even for

32-bit
* binaries.
*/

arch/mips/kernel/ptrace32.c line 22

Quoted 6 lines
arch/mips/kernel/ptrace32.c +3 -0
+
+#define WANT_COMPAT_REG_H
+
 #include <linux/compiler.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>

Without the change to reg.h, this change causes a bunch of
warning: "EF_R0" redefined
type messages when compiling ptrace32.c. I tried a combination of mine and yours, well, really mine except I moved the define for WANT_COMPAT_REG_H to ptrace32.c, and that did not produce an comprehensible core file.

Any suggestions?

Cheers,

a