Fix off-by-one unwinding error.
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 25 May 2008 00:36:06 +0000 (00:36 +0000)
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 25 May 2008 00:36:06 +0000 (00:36 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4570 c046a42c-6fe2-441c-8c8c-71466251a162

dyngen-exec.h
target-alpha/op_helper.c
target-arm/op_helper.c
target-cris/op_helper.c
target-i386/helper.c
target-m68k/op_helper.c
target-mips/op_helper.c
target-ppc/op_helper.c
target-sh4/op_helper.c
target-sparc/op_helper.c
tcg/arm/tcg-target.c

index 52cb779..f51d363 100644 (file)
@@ -287,4 +287,16 @@ extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
 #error unsupported CPU
 #endif
 
+/* The return address may point to the start of the next instruction.
+   Subtracting one gets us the call instruction itself.  */
+#if defined(__s390__)
+# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
+#elif defined(__arm__)
+/* Thumb return addresses have the low bit set, so we need to subtract two.
+   This is still safe in ARM mode because instructions are 4 bytes.  */
+# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
+#else
+# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
+#endif
+
 #endif /* !defined(__DYNGEN_EXEC_H__) */
index 072499e..36b98b8 100644 (file)
@@ -1093,12 +1093,6 @@ void helper_reset_FT2 (void)
 /* Softmmu support */
 #if !defined (CONFIG_USER_ONLY)
 
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
-
 /* XXX: the two following helpers are pure hacks.
  *      Hopefully, we emulate the PALcode, then we should never see
  *      HW_LD / HW_ST instructions.
index 555b55c..5d9fd84 100644 (file)
@@ -68,11 +68,6 @@ uint32_t HELPER(neon_tbl)(uint32_t ireg, uint32_t def,
 #if !defined(CONFIG_USER_ONLY)
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"
index ea8016b..abcf9b4 100644 (file)
 #include "mmu.h"
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"
index 4562a16..cab085a 100644 (file)
@@ -4663,11 +4663,6 @@ static float approx_rcp(float a)
 #if !defined(CONFIG_USER_ONLY)
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"
index f45c4d9..f2e9f03 100644 (file)
@@ -32,11 +32,6 @@ void do_interrupt(int is_hw)
 extern int semihosting_enabled;
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"
index 017d12a..2020e9e 100644 (file)
 
 #include "host-utils.h"
 
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
-
 /*****************************************************************************/
 /* Exceptions processing helpers */
 
index 544d906..1c08172 100644 (file)
@@ -2612,11 +2612,6 @@ DO_SPE_OP1(fsctuf);
 #if !defined (CONFIG_USER_ONLY)
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"
index bbc3030..8c8318f 100644 (file)
@@ -28,11 +28,6 @@ void do_raise_exception(void)
 #ifndef CONFIG_USER_ONLY
 
 #define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"
index 2d85560..250f719 100644 (file)
@@ -2871,12 +2871,6 @@ static void do_unaligned_access(target_ulong addr, int is_write, int is_user,
 
 #define MMUSUFFIX _mmu
 #define ALIGNED_ONLY
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & \
-                          0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
 
 #define SHIFT 0
 #include "softmmu_template.h"
index a3f4c6d..3ced47e 100644 (file)
@@ -1180,7 +1180,6 @@ static inline void tcg_out_qemu_st(TCGContext *s, int cond,
 
     tcg_out_bl(s, cond, (tcg_target_long) qemu_st_helpers[s_bits] -
                     (tcg_target_long) s->code_ptr);
-
 # if TARGET_LONG_BITS == 64
     if (opc == 3)
         tcg_out_dat_imm(s, cond, ARITH_ADD, 13, 13, 0x10);