linux-cvs-patches
[Top] [All Lists]

CVS Update@linux-mips.org: linux

To: linux-cvs-patches@linux-mips.org
Subject: CVS Update@linux-mips.org: linux
From: ralf@linux-mips.org
Date: Wed, 26 Jan 2005 02:21:12 +0000
Reply-to: linux-mips@linux-mips.org
Sender: linux-cvs-patches-bounce@linux-mips.org
CVSROOT:        /home/cvs
Module name:    linux
Changes by:     ralf@ftp.linux-mips.org 05/01/26 02:21:06

Modified files:
        arch/mips      : Makefile 
        arch/mips/kernel: binfmt_elfo32.c process.c 
        include/asm-mips: elf.h 
Added files:
        include/asm-mips: reg.h 
Removed files:
        arch/mips/kernel: reg.c 

Log message:
        Fix register layout in core dumps.

diff -urN linux/arch/mips/Makefile linux/arch/mips/Makefile
--- linux/arch/mips/Makefile    2004/12/18 01:15:52     1.186
+++ linux/arch/mips/Makefile    2005/01/26 02:21:06     1.187
@@ -752,36 +752,16 @@
         echo "#endif /* _ASM_OFFSET_H */" )
 endef
 
-define filechk_gen-asm-reg.h
-       (set -e; \
-        echo "#ifndef _ASM_REG_H"; \
-        echo "#define _ASM_REG_H"; \
-        echo "/*"; \
-        echo " * DO NOT MODIFY."; \
-        echo " *"; \
-        echo " * This file was generated by arch/$(ARCH)/Makefile"; \
-        echo " *"; \
-        echo " */"; \
-        echo ""; \
-        sed -ne "/^@@@/s///p"; \
-        echo "#endif /* _ASM_REG_H */" )
-endef
-
-prepare: include/asm-$(ARCH)/offset.h \
-        include/asm-$(ARCH)/reg.h
+prepare: include/asm-$(ARCH)/offset.h
 
 arch/$(ARCH)/kernel/offset.s: include/asm include/linux/version.h \
                                   include/config/MARKER
 
 include/asm-$(ARCH)/offset.h: arch/$(ARCH)/kernel/offset.s
        $(call filechk,gen-asm-offset.h)
-include/asm-$(ARCH)/reg.h: arch/$(ARCH)/kernel/reg.s
-       $(call filechk,gen-asm-reg.h)
 
 CLEAN_FILES += include/asm-$(ARCH)/offset.h.tmp \
               include/asm-$(ARCH)/offset.h \
-              include/asm-$(ARCH)/reg.h.tmp \
-              include/asm-$(ARCH)/reg.h \
               vmlinux.32 \
               vmlinux.64 \
               vmlinux.ecoff
diff -urN linux/arch/mips/kernel/binfmt_elfo32.c 
linux/arch/mips/kernel/binfmt_elfo32.c
--- linux/arch/mips/kernel/binfmt_elfo32.c      2005/01/15 01:31:05     1.4
+++ linux/arch/mips/kernel/binfmt_elfo32.c      2005/01/26 02:21:06     1.5
@@ -97,7 +97,7 @@
 #define init_elf_binfmt init_elf32_binfmt
 
 #define jiffies_to_timeval jiffies_to_compat_timeval
-static __inline__ void
+static inline void
 jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
 {
        /*
@@ -112,21 +112,26 @@
 #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 _dest, struct pt_regs *_regs)
+void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs)
 {
        int i;
 
-       memset(_dest, 0, sizeof(elf_gregset_t));
-
-       /* XXXKW the 6 is from EF_REG0 in gdb/gdb/mips-linux-tdep.c, 
include/asm-mips/reg.h */
-       for (i=6; i<38; i++)
-               _dest[i] = (elf_greg_t) _regs->regs[i-6];
-       _dest[i++] = (elf_greg_t) _regs->lo;
-       _dest[i++] = (elf_greg_t) _regs->hi;
-       _dest[i++] = (elf_greg_t) _regs->cp0_epc;
-       _dest[i++] = (elf_greg_t) _regs->cp0_badvaddr;
-       _dest[i++] = (elf_greg_t) _regs->cp0_status;
-       _dest[i++] = (elf_greg_t) _regs->cp0_cause;
+       for (i = 0; i < EF_R0; i++)
+               grp[i] = 0;
+       grp[EF_R0] = 0;
+       for (i = 1; i <= 31; i++)
+               grp[EF_R0 + i] = (elf_greg_t) regs->regs[i];
+       grp[EF_R26] = 0;
+       grp[EF_R27] = 0;
+       grp[EF_LO] = (elf_greg_t) regs->lo;
+       grp[EF_HI] = (elf_greg_t) regs->hi;
+       grp[EF_CP0_EPC] = (elf_greg_t) regs->cp0_epc;
+       grp[EF_CP0_BADVADDR] = (elf_greg_t) regs->cp0_badvaddr;
+       grp[EF_CP0_STATUS] = (elf_greg_t) regs->cp0_status;
+       grp[EF_CP0_CAUSE] = (elf_greg_t) regs->cp0_cause;
+#ifdef EF_UNUSED0
+       grp[EF_UNUSED0] = 0;
+#endif
 }
 
 MODULE_DESCRIPTION("Binary format loader for compatibility with o32 Linux/MIPS 
binaries");
diff -urN linux/arch/mips/kernel/process.c linux/arch/mips/kernel/process.c
--- linux/arch/mips/kernel/process.c    2005/01/07 04:26:49     1.72
+++ linux/arch/mips/kernel/process.c    2005/01/26 02:21:06     1.73
@@ -149,6 +149,36 @@
 int dump_fpu(struct pt_regs *regs, elf_fpregset_t *r)
 {
        memcpy(r, &current->thread.fpu, sizeof(current->thread.fpu));
+
+       return 1;
+}
+
+void dump_regs(elf_greg_t *gp, struct pt_regs *regs)
+{
+       int i;
+
+       for (i = 0; i < EF_R0; i++)
+               gp[i] = 0;
+       gp[EF_R0] = 0;
+       for (i = 1; i <= 31; i++)
+               gp[EF_R0 + i] = regs->regs[i];
+       gp[EF_R26] = 0;
+       gp[EF_R27] = 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
+}
+
+int dump_task_fpu (struct task_struct *t, elf_fpregset_t *fpr)
+{
+       memcpy(fpr, &t->thread.fpu, sizeof(current->thread.fpu));
+
        return 1;
 }
 
diff -urN linux/arch/mips/kernel/reg.c linux/arch/mips/kernel/reg.c
--- linux/arch/mips/kernel/Attic/reg.c  Wed Jan 26 02:21:06 2005        1.1
+++ linux/arch/mips/kernel/Attic/reg.c  1970/01/01 00:00:002002
@@ -1,69 +0,0 @@
-/*
- * offset.c: Calculate pt_regs and task_struct indices.
- *
- * Copyright (C) 1996 David S. Miller
- * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Ralf Baechle
- */
-#include <linux/types.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-
-#include <asm/ptrace.h>
-#include <asm/processor.h>
-
-#define text(t) __asm__("\n@@@" t)
-#define _offset(type, member) ((unsigned long) &(((type *)NULL)->member))
-#define index(string, ptr, member) \
-       __asm__("\n@@@" string "%0" : : "i" (_offset(ptr, member)/sizeof(long)))
-#define size(string, size) \
-       __asm__("\n@@@" string "%0" : : "i" (sizeof(size)))
-#define linefeed text("")
-
-void output_ptreg_defines(void)
-{
-       text("/* MIPS pt_regs indices. */");
-       index("#define EF_R0     ", struct pt_regs, regs[0]);
-       index("#define EF_R1     ", struct pt_regs, regs[1]);
-       index("#define EF_R2     ", struct pt_regs, regs[2]);
-       index("#define EF_R3     ", struct pt_regs, regs[3]);
-       index("#define EF_R4     ", struct pt_regs, regs[4]);
-       index("#define EF_R5     ", struct pt_regs, regs[5]);
-       index("#define EF_R6     ", struct pt_regs, regs[6]);
-       index("#define EF_R7     ", struct pt_regs, regs[7]);
-       index("#define EF_R8     ", struct pt_regs, regs[8]);
-       index("#define EF_R9     ", struct pt_regs, regs[9]);
-       index("#define EF_R10    ", struct pt_regs, regs[10]);
-       index("#define EF_R11    ", struct pt_regs, regs[11]);
-       index("#define EF_R12    ", struct pt_regs, regs[12]);
-       index("#define EF_R13    ", struct pt_regs, regs[13]);
-       index("#define EF_R14    ", struct pt_regs, regs[14]);
-       index("#define EF_R15    ", struct pt_regs, regs[15]);
-       index("#define EF_R16    ", struct pt_regs, regs[16]);
-       index("#define EF_R17    ", struct pt_regs, regs[17]);
-       index("#define EF_R18    ", struct pt_regs, regs[18]);
-       index("#define EF_R19    ", struct pt_regs, regs[19]);
-       index("#define EF_R20    ", struct pt_regs, regs[20]);
-       index("#define EF_R21    ", struct pt_regs, regs[21]);
-       index("#define EF_R22    ", struct pt_regs, regs[22]);
-       index("#define EF_R23    ", struct pt_regs, regs[23]);
-       index("#define EF_R24    ", struct pt_regs, regs[24]);
-       index("#define EF_R25    ", struct pt_regs, regs[25]);
-       index("#define EF_R26    ", struct pt_regs, regs[26]);
-       index("#define EF_R27    ", struct pt_regs, regs[27]);
-       index("#define EF_R28    ", struct pt_regs, regs[28]);
-       index("#define EF_R29    ", struct pt_regs, regs[29]);
-       index("#define EF_R30    ", struct pt_regs, regs[30]);
-       index("#define EF_R31    ", struct pt_regs, regs[31]);
-       linefeed;
-       index("#define EF_LO     ", struct pt_regs, lo);
-       index("#define EF_HI     ", struct pt_regs, hi);
-       linefeed;
-       index("#define EF_EPC    ", struct pt_regs, cp0_epc);
-       index("#define EF_BVADDR ", struct pt_regs, cp0_badvaddr);
-       index("#define EF_STATUS ", struct pt_regs, cp0_status);
-       index("#define EF_CAUSE  ", struct pt_regs, cp0_cause);
-       linefeed;
-       size("#define EF_SIZE   ", struct pt_regs);
-       linefeed;
-}
diff -urN linux/include/asm-mips/reg.h linux/include/asm-mips/reg.h
--- linux/include/asm-mips/reg.h        2003/07/29 03:21:47     1.4
+++ linux/include/asm-mips/reg.h        2005/01/26 02:21:06     1.5
@@ -6,49 +6,53 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1995, 1999 by Ralf Baechle
+ * Copyright (C) 1995, 1999 Ralf Baechle
+ * Copyright (C) 1995, 1999 Silicon Graphics
  */
 #ifndef __ASM_MIPS_REG_H
 #define __ASM_MIPS_REG_H
 
-/*
- * This defines/structures correspond to the register layout on stack -
- * if the order here is changed, it needs to be updated in
- * include/asm-mips/stackframe.h
- */
-#define EF_REG0                        6
-#define EF_REG1                        7
-#define EF_REG2                        8
-#define EF_REG3                        9
-#define EF_REG4                        10
-#define EF_REG5                        11
-#define EF_REG6                        12
-#define EF_REG7                        13
-#define EF_REG8                        14
-#define EF_REG9                        15
-#define EF_REG10               16
-#define EF_REG11               17
-#define EF_REG12               18
-#define EF_REG13               19
-#define EF_REG14               20
-#define EF_REG15               21
-#define EF_REG16               22
-#define EF_REG17               23
-#define EF_REG18               24
-#define EF_REG19               25
-#define EF_REG20               26
-#define EF_REG21               27
-#define EF_REG22               28
-#define EF_REG23               29
-#define EF_REG24               30
-#define EF_REG25               31
+#include <linux/config.h>
+
+#if defined(CONFIG_MIPS32) || defined(WANT_COMPAT_REG_H)
+
+#define EF_R0                  6
+#define EF_R1                  7
+#define EF_R2                  8
+#define EF_R3                  9
+#define EF_R4                  10
+#define EF_R5                  11
+#define EF_R6                  12
+#define EF_R7                  13
+#define EF_R8                  14
+#define EF_R9                  15
+#define EF_R10                 16
+#define EF_R11                 17
+#define EF_R12                 18
+#define EF_R13                 19
+#define EF_R14                 20
+#define EF_R15                 21
+#define EF_R16                 22
+#define EF_R17                 23
+#define EF_R18                 24
+#define EF_R19                 25
+#define EF_R20                 26
+#define EF_R21                 27
+#define EF_R22                 28
+#define EF_R23                 29
+#define EF_R24                 30
+#define EF_R25                 31
+
 /*
  * k0/k1 unsaved
  */
-#define EF_REG28               34
-#define EF_REG29               35
-#define EF_REG30               36
-#define EF_REG31               37
+#define EF_R26                 32
+#define EF_R27                 33
+
+#define EF_R28                 34
+#define EF_R29                 35
+#define EF_R30                 36
+#define EF_R31                 37
 
 /*
  * Saved special registers
@@ -60,7 +64,66 @@
 #define EF_CP0_BADVADDR                41
 #define EF_CP0_STATUS          42
 #define EF_CP0_CAUSE           43
+#define EF_UNUSED0             44
+
+#define EF_SIZE                        180
+
+#endif
+
+#if CONFIG_MIPS64
+
+#define EF_R0                   0
+#define EF_R1                   1
+#define EF_R2                   2
+#define EF_R3                   3
+#define EF_R4                   4
+#define EF_R5                   5
+#define EF_R6                   6
+#define EF_R7                   7
+#define EF_R8                   8
+#define EF_R9                   9
+#define EF_R10                 10
+#define EF_R11                 11
+#define EF_R12                 12
+#define EF_R13                 13
+#define EF_R14                 14
+#define EF_R15                 15
+#define EF_R16                 16
+#define EF_R17                 17
+#define EF_R18                 18
+#define EF_R19                 19
+#define EF_R20                 20
+#define EF_R21                 21
+#define EF_R22                 22
+#define EF_R23                 23
+#define EF_R24                 24
+#define EF_R25                 25
+
+/*
+ * k0/k1 unsaved
+ */
+#define EF_R26                 26
+#define EF_R27                 27
+
+
+#define EF_R28                 28
+#define EF_R29                 29
+#define EF_R30                 30
+#define EF_R31                 31
+
+/*
+ * Saved special registers
+ */
+#define EF_LO                  32
+#define EF_HI                  33
+
+#define EF_CP0_EPC             34
+#define EF_CP0_BADVADDR                35
+#define EF_CP0_STATUS          36
+#define EF_CP0_CAUSE           37
+
+#define EF_SIZE                        304     /* size in bytes */
 
-#define EF_SIZE                        180     /* size in bytes */
+#endif /* CONFIG_MIPS64 */
 
 #endif /* __ASM_MIPS_REG_H */
diff -urN linux/include/asm-mips/elf.h linux/include/asm-mips/elf.h
--- linux/include/asm-mips/elf.h        2005/01/06 04:12:26     1.23
+++ linux/include/asm-mips/elf.h        2005/01/26 02:21:06     1.24
@@ -224,6 +224,14 @@
 
 #endif /* CONFIG_MIPS64 */
 
+extern void dump_regs(elf_greg_t *, struct pt_regs *regs);
+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_FPREGS(tsk, elf_fpregs)                  \
+       dump_task_fpu(tsk, elf_fpregs)
+
 #endif /* __KERNEL__ */
 
 /* This one accepts IRIX binaries.  */
@@ -232,10 +240,6 @@
 #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));
-
 /* This yields a mask that user programs can use to figure out what
    instruction set this cpu supports.  This could be done in userspace,
    but it's not easy, and we've already done it here.  */

<Prev in Thread] Current Thread [Next in Thread>