From: Roman.Hodek@informatik.uni-erlangen.de (Roman Hodek)
Date: Thu, 4 Dec 1997 18:27:46 +0100 (CET)
To: linux-m68k@lists.linux-m68k.org
Subject: L68K: kgdb fix
Sender: owner-linux-m68k@phil.uni-sb.de
Reply-To: Roman.Hodek@informatik.uni-erlangen.de


The patch below makes kgdb work properly again. It basically turns off
special handling of init functions and data. gdb doesn't like it if
the code of one object file doesn't really come in one chunk, and
moving init functions to the end of all code does exactly this.
Effects range from miscalculated function addresses to total loss of
infos about functions (locals, args, ...)

Another little patch is that %a2 is now also saved in the stack frame
and should be restored. This makes C-c in gdb work again.

Roman

------------------------------------------------------------------------------
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.64.orig/arch/m68k/kernel/kgdb.c linux-2.1.64/arch/m68k/kernel/kgdb.c
--- linux-2.1.64.orig/arch/m68k/kernel/kgdb.c	Sat Nov 22 01:05:22 1997
+++ linux-2.1.64/arch/m68k/kernel/kgdb.c	Wed Dec  3 21:04:36 1997
@@ -833,7 +833,7 @@
   "		movel	%sp@(12),%sp\n"		/* revert stack to where 'inthandler' set
 									 * it up */
   /* restore regs from frame */
-  "		moveml	%sp@+,%d1-%d5/%a0-%a1\n"
+  "		moveml	%sp@+,%d1-%d5/%a0-%a2\n"
   "		movel	%sp@+,%d0\n"
   "		addql	#8,%sp\n"			/* throw away orig_d0 and stkadj */
   /* save them into 'registers' */
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.64.orig/include/asm-m68k/init.h linux-2.1.64/include/asm-m68k/init.h
--- linux-2.1.64.orig/include/asm-m68k/init.h	Mon Apr 28 17:40:24 1997
+++ linux-2.1.64/include/asm-m68k/init.h	Thu Dec  4 18:01:12 1997
@@ -1,6 +1,10 @@
 #ifndef _M68K_INIT_H
 #define _M68K_INIT_H
 
+#include <linux/config.h>
+
+#ifndef CONFIG_KGDB
+
 #define __init __attribute__ ((__section__ (".text.init")))
 #define __initdata __attribute__ ((__section__ (".data.init")))
 #define __initfunc(__arginit) \
@@ -11,4 +15,19 @@
 #define __FINIT		.previous
 #define __INITDATA	.section	".data.init",#alloc,#write
 
+#else
+
+/* gdb doesn't like it all if the code for one source file isn't together in
+ * the executable, so we must avoid the .init sections :-( */
+	
+#define __init
+#define __initdata
+#define __initfunc(__arginit) __arginit
+/* For assembly routines */
+#define __INIT
+#define __FINIT
+#define __INITDATA
+
+#endif /* CONFIG_KGDB */
+	
 #endif
