This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit/rx sim] Fix a big endian mode decode cache problem


I've committed the patch below.

GDB test results for rx-elf are abysmally bad when using any big
endian multilib.  (These can be enabled via the -mbig-endian-data
switch.)

In particular, GDB often stops with a SIGTRAP just after continuing
from a breakpoint (or some other stop which used an internal
breakpoint to get to that point).  It turned out that in big endian
mode, the decode cache was not be correctly invalidated when GDB wrote
the original instruction back over the breakpoint.  As a consequence,
the simulator would often execute the trap instruction instead of the
instruction that GDB had just written out to memory.  (Whether this
problem would happen or not was dependent on the length of the
instruction and its offset within a word.)

The patch below fixes this problem by using a "swapped" address in the
code which invalidates the decode cache.  This problem could be solved
by doing the address swapping prior to placing decoded instructions in
the cache, but doing it in that manner would have performance
implications.

I've shown this patch to DJ and he has approved it.

Kevin

	* mem.c (rx_mem_ptr): When invalidating the decode cache, account
	for the fact that the instruction decoder never uses swapped
	addresses.

Index: mem.c
===================================================================
RCS file: /cvs/src/src/sim/rx/mem.c,v
retrieving revision 1.4
diff -u -p -r1.4 mem.c
--- mem.c	29 Jul 2010 18:41:28 -0000	1.4
+++ mem.c	29 Sep 2010 23:31:24 -0000
@@ -104,13 +104,19 @@ rx_mem_ptr (unsigned long address, enum 
 
   if (action == MPA_WRITING)
     {
+      int pto_dc;
       if (ptr[pt1][pt2][pto] == MC_PUSHED_PC)
 	execution_error (SIM_ERR_CORRUPT_STACK, address);
       ptr[pt1][pt2][pto] = MC_DATA;
-      if (ptdc[pt1][pt2][pto])
+
+      /* The instruction decoder doesn't store it's decoded instructions
+         at word swapped addresses.  Therefore, when clearing the decode
+	 cache, we have to account for that here.  */
+      pto_dc = pto ^ (rx_big_endian ? 3 : 0);
+      if (ptdc[pt1][pt2][pto_dc])
 	{
-	  free (ptdc[pt1][pt2][pto]);
-	  ptdc[pt1][pt2][pto] = NULL;
+	  free (ptdc[pt1][pt2][pto_dc]);
+	  ptdc[pt1][pt2][pto_dc] = NULL;
 	}
     }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]