From: Dale Farnsworth <[EMAIL PROTECTED]>

Move kgdb_fault_setjmp() and kgdb_fault_longjmp() to assembly files
to avoid the C function munging that occurs when compiling with
-fno-omit-frame-pointer.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

---

This differs from the previous patch in that the assembly files
are named kgdb_setjmp32.S and kgdb_setjmp64.S

I believe this addresses all issues that have been raised.

diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index d017037..25b26aa 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -60,7 +60,13 @@ obj-$(CONFIG_BOOTX_TEXT)     += btext.o
 obj-$(CONFIG_SMP)              += smp.o
 obj-$(CONFIG_KPROBES)          += kprobes.o
 obj-$(CONFIG_PPC_UDBG_16550)   += legacy_serial.o udbg_16550.o
-obj-$(CONFIG_KGDB)             += kgdb.o
+
+ifeq ($(CONFIG_PPC32),y)
+obj-$(CONFIG_KGDB)             += kgdb.o kgdb_setjmp32.o
+else
+obj-$(CONFIG_KGDB)             += kgdb.o kgdb_setjmp64.o
+endif
+
 module-$(CONFIG_PPC64)         += module_64.o
 obj-$(CONFIG_MODULES)          += $(module-y)
 
diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c
index 9d5aaf8..f061c65 100644
--- a/arch/powerpc/kernel/kgdb.c
+++ b/arch/powerpc/kernel/kgdb.c
@@ -7,7 +7,6 @@
  *
  * Copied from arch/ppc/kernel/kgdb.c, updated for ppc64
  *
- * Copyright (C) 1996 Paul Mackerras (setjmp/longjmp)
  * 1998 (c) Michael AK Tesch ([EMAIL PROTECTED])
  * Copyright (C) 2003 Timesys Corporation.
  * Copyright (C) 2004-2006 MontaVista Software, Inc.
@@ -469,78 +468,6 @@ #endif
        return -1;
 }
 
-int kgdb_fault_setjmp(unsigned long *curr_context)
-{
-#ifdef CONFIG_PPC32
-        __asm__ __volatile__("mflr 0; stw 0,0(%0);\n\
-                              stw 1,4(%0); stw 2,8(%0);\n\
-                              mfcr 0; stw 0,12(%0);\n\
-                              stmw 13,16(%0)\n" : : "r" (curr_context));
-#else
-       __asm__ __volatile__("mflr 0; std 0,0(%0)\n\
-                             std       1,8(%0)\n\
-                             std       2,16(%0)\n\
-                             mfcr 0; std 0,24(%0)\n\
-                             std       13,32(%0)\n\
-                             std       14,40(%0)\n\
-                             std       15,48(%0)\n\
-                             std       16,56(%0)\n\
-                             std       17,64(%0)\n\
-                             std       18,72(%0)\n\
-                             std       19,80(%0)\n\
-                             std       20,88(%0)\n\
-                             std       21,96(%0)\n\
-                             std       22,104(%0)\n\
-                             std       23,112(%0)\n\
-                             std       24,120(%0)\n\
-                             std       25,128(%0)\n\
-                             std       26,136(%0)\n\
-                             std       27,144(%0)\n\
-                             std       28,152(%0)\n\
-                             std       29,160(%0)\n\
-                             std       30,168(%0)\n\
-                             std       31,176(%0)\n" : : "r" (curr_context));
-#endif
-       return 0;
-}
-
-void kgdb_fault_longjmp(unsigned long *curr_context)
-{
-#ifdef CONFIG_PPC32
-       __asm__ __volatile__("lmw 13,16(%0);\n\
-                             lwz 0,12(%0); mtcrf 0x38,0;\n\
-                             lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);\n\
-                             mtlr 0; mr 3,1\n" : : "r" (curr_context));
-#else
-       __asm__ __volatile__("ld        13,32(%0)\n\
-                             ld        14,40(%0)\n\
-                             ld        15,48(%0)\n\
-                             ld        16,56(%0)\n\
-                             ld        17,64(%0)\n\
-                             ld        18,72(%0)\n\
-                             ld        19,80(%0)\n\
-                             ld        20,88(%0)\n\
-                             ld        21,96(%0)\n\
-                             ld        22,104(%0)\n\
-                             ld        23,112(%0)\n\
-                             ld        24,120(%0)\n\
-                             ld        25,128(%0)\n\
-                             ld        26,136(%0)\n\
-                             ld        27,144(%0)\n\
-                             ld        28,152(%0)\n\
-                             ld        29,160(%0)\n\
-                             ld        30,168(%0)\n\
-                             ld        31,176(%0)\n\
-                             ld        0,24(%0)\n\
-                             mtcrf     0x38,0\n\
-                             ld        0,0(%0)\n\
-                             ld        1,8(%0)\n\
-                             ld        2,16(%0)\n\
-                             mtlr      0\n\
-                             mr        3,1\n" : : "r" (curr_context));
-#endif
-}
-
 /*
  * Global data
  */
diff --git a/arch/powerpc/kernel/kgdb_setjmp32.S 
b/arch/powerpc/kernel/kgdb_setjmp32.S
new file mode 100644
index 0000000..c9461b4
--- /dev/null
+++ b/arch/powerpc/kernel/kgdb_setjmp32.S
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 1996 Paul Mackerras
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program as licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+#include <asm/processor.h>
+#include <asm/ppc_asm.h>
+
+       .text
+
+/*
+ * Save/restore state in case a memory access causes a fault.
+ *
+ * int kgdb_fault_setjmp(unsigned long *curr_context);
+ * void kgdb_fault_longjmp(unsigned long *curr_context);
+ */
+
+_GLOBAL(kgdb_fault_setjmp)
+       mflr    r0
+       stw     r0,0(r3)
+       stw     r1,4(r3)
+       stw     r2,8(r3)
+       mfcr    r0
+       stw     r0,12(r3)
+       stmw    r13,16(r3)
+       li      r3,0
+       blr
+
+_GLOBAL(kgdb_fault_longjmp)
+       lmw     r13,16(r3)
+       lwz     r0,12(r3)
+       mtcrf   0x38,r0
+       lwz     r0,0(r3)
+       lwz     r1,4(r3)
+       lwz     r2,8(r3)
+       mtlr    r0
+       mr      r3,r1
+       blr
diff --git a/arch/powerpc/kernel/kgdb_setjmp64.S 
b/arch/powerpc/kernel/kgdb_setjmp64.S
new file mode 100644
index 0000000..f0776de
--- /dev/null
+++ b/arch/powerpc/kernel/kgdb_setjmp64.S
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 1996 Paul Mackerras
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program as licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+#include <asm/processor.h>
+#include <asm/ppc_asm.h>
+
+       .text
+
+/*
+ * Save/restore state in case a memory access causes a fault.
+ *
+ * int kgdb_fault_setjmp(unsigned long *curr_context);
+ * void kgdb_fault_longjmp(unsigned long *curr_context);
+ */
+
+_GLOBAL(kgdb_fault_setjmp)
+       mflr    r0
+       std     r0,0(r3)
+       std     r1,8(r3)
+       std     r2,16(r3)
+       mfcr    r0
+       std     r0,24(r3)
+       std     r13,32(r3)
+       std     r14,40(r3)
+       std     r15,48(r3)
+       std     r16,56(r3)
+       std     r17,64(r3)
+       std     r18,72(r3)
+       std     r19,80(r3)
+       std     r20,88(r3)
+       std     r21,96(r3)
+       std     r22,104(r3)
+       std     r23,112(r3)
+       std     r24,120(r3)
+       std     r25,128(r3)
+       std     r26,136(r3)
+       std     r27,144(r3)
+       std     r28,152(r3)
+       std     r29,160(r3)
+       std     r30,168(r3)
+       std     r31,176(r3)
+       li      r3,0
+       blr
+
+_GLOBAL(kgdb_fault_longjmp)
+       ld      r13,32(r3)
+       ld      r14,40(r3)
+       ld      r15,48(r3)
+       ld      r16,56(r3)
+       ld      r17,64(r3)
+       ld      r18,72(r3)
+       ld      r19,80(r3)
+       ld      r20,88(r3)
+       ld      r21,96(r3)
+       ld      r22,104(r3)
+       ld      r23,112(r3)
+       ld      r24,120(r3)
+       ld      r25,128(r3)
+       ld      r26,136(r3)
+       ld      r27,144(r3)
+       ld      r28,152(r3)
+       ld      r29,160(r3)
+       ld      r30,168(r3)
+       ld      r31,176(r3)
+       ld      r0,24(r3)
+       mtcrf   0x38,r0
+       ld      r0,0(r3)
+       ld      r1,8(r3)
+       ld      r2,16(r3)
+       mtlr    r0
+       mr      r3,r1
+       blr
diff --git a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile
index 466437f..28a8e8e 100644
--- a/arch/ppc/kernel/Makefile
+++ b/arch/ppc/kernel/Makefile
@@ -15,7 +15,7 @@ obj-$(CONFIG_MODULES)         += ppc_ksyms.o
 obj-$(CONFIG_NOT_COHERENT_CACHE)       += dma-mapping.o
 obj-$(CONFIG_PCI)              += pci.o
 obj-$(CONFIG_RAPIDIO)          += rio.o
-obj-$(CONFIG_KGDB)             += ppc-stub.o
+obj-$(CONFIG_KGDB)             += kgdb.o kgdb_setjmp32.o
 obj-$(CONFIG_SMP)              += smp.o smp-tbsync.o
 obj-$(CONFIG_KEXEC)            += machine_kexec.o relocate_kernel.o
 
diff --git a/arch/ppc/kernel/kgdb.c b/arch/ppc/kernel/kgdb.c
index d1cfda5..51c2a28 100644
--- a/arch/ppc/kernel/kgdb.c
+++ b/arch/ppc/kernel/kgdb.c
@@ -246,26 +246,6 @@ #endif
 }
 
 /*
- * Save/restore state in case a memory access causes a fault.
- */
-int kgdb_fault_setjmp(unsigned long *curr_context)
-{
-       __asm__ __volatile__("mflr 0; stw 0,0(%0);"
-                            "stw 1,4(%0); stw 2,8(%0);"
-                            "mfcr 0; stw 0,12(%0);"
-                            "stmw 13,16(%0)"::"r"(curr_context));
-       return 0;
-}
-
-void kgdb_fault_longjmp(unsigned long *curr_context)
-{
-       __asm__ __volatile__("lmw 13,16(%0);"
-                            "lwz 0,12(%0); mtcrf 0x38,0;"
-                            "lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);"
-                            "mtlr 0; mr 3,1"::"r"(curr_context));
-}
-
-/*
  * This function does PoerPC specific procesing for interfacing to gdb.
  */
 int kgdb_arch_handle_exception(int vector, int signo, int err_code,
diff --git a/arch/ppc/kernel/kgdb_setjmp32.S b/arch/ppc/kernel/kgdb_setjmp32.S
new file mode 100644
index 0000000..c9461b4
--- /dev/null
+++ b/arch/ppc/kernel/kgdb_setjmp32.S
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 1996 Paul Mackerras
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program as licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+#include <asm/processor.h>
+#include <asm/ppc_asm.h>
+
+       .text
+
+/*
+ * Save/restore state in case a memory access causes a fault.
+ *
+ * int kgdb_fault_setjmp(unsigned long *curr_context);
+ * void kgdb_fault_longjmp(unsigned long *curr_context);
+ */
+
+_GLOBAL(kgdb_fault_setjmp)
+       mflr    r0
+       stw     r0,0(r3)
+       stw     r1,4(r3)
+       stw     r2,8(r3)
+       mfcr    r0
+       stw     r0,12(r3)
+       stmw    r13,16(r3)
+       li      r3,0
+       blr
+
+_GLOBAL(kgdb_fault_longjmp)
+       lmw     r13,16(r3)
+       lwz     r0,12(r3)
+       mtcrf   0x38,r0
+       lwz     r0,0(r3)
+       lwz     r1,4(r3)
+       lwz     r2,8(r3)
+       mtlr    r0
+       mr      r3,r1
+       blr

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Kgdb-bugreport mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to