Hi!
Compiling the kdb with gcc 3.1 breaks kdba_setjmp. It seems
that gcc 3.1 is more clever about omiting frame pointers for
leaf functions. When it does this for kdba_setjmp it causes an
oops on entry to kdb.
The attached patch uses the gcc built in functions to get the
frame pointer and the return adddress. This gets rid of the hard
coded stack offsets and should make it more portable.
Jim Houston - Concurrent Computer Corp.
---
diff -urN -X dontdiff 2.4.18-ccur1.orig/arch/i386/kdb/kdbasupport.c
2.4.18-ccur1/arch/i386/kdb/kdbasupport.c
--- 2.4.18-ccur1.orig/arch/i386/kdb/kdbasupport.c Wed Jun 12 09:44:32 2002
+++ 2.4.18-ccur1/arch/i386/kdb/kdbasupport.c Thu Aug 1 06:05:38 2002
@@ -1041,56 +1041,31 @@
int
kdba_setjmp(kdb_jmp_buf *jb)
{
-#if defined(CONFIG_FRAME_POINTER)
- __asm__ ("movl 8(%esp), %eax\n\t"
- "movl %ebx, 0(%eax)\n\t"
- "movl %esi, 4(%eax)\n\t"
- "movl %edi, 8(%eax)\n\t"
- "movl (%esp), %ecx\n\t"
- "movl %ecx, 12(%eax)\n\t"
- "leal 8(%esp), %ecx\n\t"
- "movl %ecx, 16(%eax)\n\t"
- "movl 4(%esp), %ecx\n\t"
- "movl %ecx, 20(%eax)\n\t");
-#else /* CONFIG_FRAME_POINTER */
- __asm__ ("movl 4(%esp), %eax\n\t"
- "movl %ebx, 0(%eax)\n\t"
- "movl %esi, 4(%eax)\n\t"
- "movl %edi, 8(%eax)\n\t"
- "movl %ebp, 12(%eax)\n\t"
- "leal 4(%esp), %ecx\n\t"
- "movl %ecx, 16(%eax)\n\t"
- "movl 0(%esp), %ecx\n\t"
- "movl %ecx, 20(%eax)\n\t");
-#endif /* CONFIG_FRAME_POINTER */
+ register kdb_jmp_buf *eax asm("eax") = jb;
+
+ __asm__("movl %%ebx,0(%0)\n\t"
+ "movl %%esi,4(%0)\n\t"
+ "movl %%edi,8(%0)\n\t" : : "a" (eax));
+ eax->regs[3] = (unsigned long)__builtin_frame_address(1);
+ eax->regs[4] = (unsigned long)&jb;
+ eax->regs[5] = (unsigned long)__builtin_return_address(0);
KDB_STATE_SET(LONGJMP);
return 0;
}
void
kdba_longjmp(kdb_jmp_buf *jb, int reason)
-{
-#if defined(CONFIG_FRAME_POINTER)
- __asm__("movl 8(%esp), %ecx\n\t"
- "movl 12(%esp), %eax\n\t"
- "movl 20(%ecx), %edx\n\t"
- "movl 0(%ecx), %ebx\n\t"
- "movl 4(%ecx), %esi\n\t"
- "movl 8(%ecx), %edi\n\t"
- "movl 12(%ecx), %ebp\n\t"
- "movl 16(%ecx), %esp\n\t"
- "jmp *%edx\n");
-#else /* CONFIG_FRAME_POINTER */
- __asm__("movl 4(%esp), %ecx\n\t"
- "movl 8(%esp), %eax\n\t"
- "movl 20(%ecx), %edx\n\t"
- "movl 0(%ecx), %ebx\n\t"
- "movl 4(%ecx), %esi\n\t"
- "movl 8(%ecx), %edi\n\t"
- "movl 12(%ecx), %ebp\n\t"
- "movl 16(%ecx), %esp\n\t"
- "jmp *%edx\n");
-#endif /* CONFIG_FRAME_POINTER */
+{
+ __asm__(
+ "movl 20(%0), %%edx\n\t"
+ "movl 0(%0), %%ebx\n\t"
+ "movl 4(%0), %%esi\n\t"
+ "movl 8(%0), %%edi\n\t"
+ "movl 12(%0), %%ebp\n\t"
+ "movl 16(%0), %%esp\n\t"
+ "jmp *%%edx\n" : :
+ "c" (jb),
+ "a" (reason));
}
#endif /* KDB_HAVE_LONGJMP */