For gdb-4.17 : returning floats on sysV68

Philippe De Muyter phdm@macqel.be
Sun Feb 8 15:57:00 GMT 1998


Thanks for having included my previous patches in gdb-4.16.85.  But I think
you should edit the date of my ChangeLog entry :)
Here is a new patch, completing the previous one.

Mon Feb  9 00:37:47 1998  Philippe De Muyter  <phdm@macqel.be>

	* m68k/tm-delta68.h (EXTRACT_RETURN_VALUE): Type argument for
	`REGISTER_CONVERT_TO_VIRTUAL is `TYPE', not
	`REGISTER_VIRTUAL_TYPE (FP0_REGNUM)';
	(STORE_RETURN_VALUE): Ditto, and offset for `write_register_bytes'
	is `REGISTER_BYTE (FP0_REGNUM)', not `FP0_REGNUM'.
	(FRAME_NUM_ARGS): New macro.
	* m68k/tm-news.h (EXTRACT_RETURN_VALUE, STORE_RETURN_VALUE): Ditto.
	* delta68-nat.c (clear_insn_cache): New function, forgotten in previous
	patch.

--- /tmp/dm19968	Mon Feb  9 00:27:34 1998
+++ ./gdb/config/m68k/tm-delta68.h	Sun Feb  8 19:18:56 1998
@@ -44,8 +44,7 @@
 
 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF)			\
   if (TYPE_CODE (TYPE) == TYPE_CODE_FLT)				\
-    REGISTER_CONVERT_TO_VIRTUAL (FP0_REGNUM,				\
-				 REGISTER_VIRTUAL_TYPE (FP0_REGNUM),	\
+    REGISTER_CONVERT_TO_VIRTUAL (FP0_REGNUM, TYPE,			\
 				 &REGBUF[REGISTER_BYTE (FP0_REGNUM)],	\
 				 VALBUF);				\
   else									\
@@ -65,14 +64,29 @@
   if (TYPE_CODE (TYPE) == TYPE_CODE_FLT)				\
       {									\
 	char raw_buf[REGISTER_RAW_SIZE (FP0_REGNUM)];			\
-	REGISTER_CONVERT_TO_RAW (REGISTER_VIRTUAL_TYPE (FP0_REGNUM),	\
-				 FP0_REGNUM, VALBUF, raw_buf);		\
-	write_register_bytes (FP0_REGNUM,				\
+	REGISTER_CONVERT_TO_RAW (TYPE, FP0_REGNUM, VALBUF, raw_buf);	\
+	write_register_bytes (REGISTER_BYTE (FP0_REGNUM),		\
 			      raw_buf, REGISTER_RAW_SIZE (FP0_REGNUM)); \
       }									\
   else									\
     write_register_bytes ((TYPE_CODE(TYPE) == TYPE_CODE_PTR ? 8 * 4 : 0), \
 			  VALBUF, TYPE_LENGTH (TYPE))
+
+/* Return number of args passed to a frame.
+   Can return -1, meaning no way to tell.  */
+
+#define FRAME_NUM_ARGS(val, fi)  \
+{ register CORE_ADDR pc = FRAME_SAVED_PC (fi);			\
+  register int insn = 0177777 & read_memory_integer (pc, 2);	\
+  val = 0;							\
+  if (insn == 0047757 || insn == 0157374)  /* lea W(sp),sp or addaw #W,sp */ \
+    val = read_memory_integer (pc + 2, 2);			\
+  else if ((insn & 0170777) == 0050217 /* addql #N, sp */	\
+	   || (insn & 0170777) == 0050117)  /* addqw */		\
+    { val = (insn >> 9) & 7; if (val == 0) val = 8; }		\
+  else if (insn == 0157774) /* addal #WW, sp */			\
+    val = read_memory_integer (pc + 2, 4);			\
+  val >>= 2; }
 
 /* On M68040 versions of sysV68 R3V7.1, ptrace(PT_WRITE_I) does not clear
    the processor's instruction cache as it should.  */
--- /tmp/dm19968	Mon Feb  9 00:27:35 1998
+++ ./gdb/config/m68k/tm-news.h	Sun Feb  8 19:19:36 1998
@@ -34,8 +34,7 @@
 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
   { if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
       { \
-	REGISTER_CONVERT_TO_VIRTUAL (FP0_REGNUM, \
-				     REGISTER_VIRTUAL_TYPE (FP0_REGNUM), \
+	REGISTER_CONVERT_TO_VIRTUAL (FP0_REGNUM, TYPE, \
 			             &REGBUF[REGISTER_BYTE (FP0_REGNUM)], \
 				     VALBUF); \
       } \
@@ -50,9 +49,8 @@
   { if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
       { \
 	char raw_buf[REGISTER_RAW_SIZE (FP0_REGNUM)]; \
-	REGISTER_CONVERT_TO_RAW (REGISTER_VIRTUAL_TYPE (FP0_REGNUM), \
-				 FP0_REGNUM, VALBUF, raw_buf); \
-	write_register_bytes (FP0_REGNUM, \
+	REGISTER_CONVERT_TO_RAW (TYPE, FP0_REGNUM, VALBUF, raw_buf); \
+	write_register_bytes (REGISTER_BYTE (FP0_REGNUM), \
 			      raw_buf, REGISTER_RAW_SIZE (FP0_REGNUM)); \
       } \
     else \
--- /tmp/dm19968	Mon Feb  9 00:27:36 1998
+++ ./gdb/delta68-nat.c	Sun Feb  8 11:38:06 1998
@@ -77,3 +77,10 @@ _initialize_delta68_nat ()
       exit (1);
     }
 }
+
+clear_insn_cache ()
+{
+#ifdef MCT_TEXT /* in sys/signal.h on sysV68 R3V7.1 */
+  memctl(0, 4096, MCT_TEXT);
+#endif
+}



More information about the Gdb mailing list