Search
lxdream.org :: lxdream :: r906:268ea359f884
lxdream 0.9.1
released Jun 29
Download Now
changeset906:268ea359f884
parent905:4c17ebd9ef5e
child907:5ecafd8d7923
authornkeynes
dateThu Oct 30 00:06:49 2008 +0000 (15 years ago)
Change xlat_get_native_pc to pass in the expected code region - this lets the Mac
unwind implementation range test the IP address (which works) rather than EBP
(which doesn't for some reason).

Remove the test in configure that prevents fomit-frame-pointer being used in Mac
builds.
configure
configure.in
src/sh4/ia32abi.h
src/sh4/ia32mac.h
src/sh4/sh4trans.c
src/sh4/xltcache.h
1.1 --- a/configure Wed Oct 29 23:51:58 2008 +0000
1.2 +++ b/configure Thu Oct 30 00:06:49 2008 +0000
1.3 @@ -6865,7 +6865,7 @@
1.4 _ACEOF
1.5
1.6 fi
1.7 -if test "x$enable_optimized" = "xyes" -a "x$APPLE_BUILD" != "xyes"; then
1.8 +if test "x$enable_optimized" = "xyes"; then
1.9 CFLAGS="$CFLAGS -fexceptions -fomit-frame-pointer"
1.10
1.11 cat >>confdefs.h <<\_ACEOF
2.1 --- a/configure.in Wed Oct 29 23:51:58 2008 +0000
2.2 +++ b/configure.in Thu Oct 30 00:06:49 2008 +0000
2.3 @@ -91,7 +91,7 @@
2.4 if test "x$HAVE_COCOA" = 'xyes' -a "x$with_gtk" = "xno"; then
2.5 AC_DEFINE(OSX_BUNDLE, [1], [Generating a bundled application])
2.6 fi
2.7 -if test "x$enable_optimized" = "xyes" -a "x$APPLE_BUILD" != "xyes"; then
2.8 +if test "x$enable_optimized" = "xyes"; then
2.9 CFLAGS="$CFLAGS -fexceptions -fomit-frame-pointer"
2.10 AC_DEFINE(HAVE_EXCEPTIONS, [1], [Have exception stack-frame information])
2.11 fi
3.1 --- a/src/sh4/ia32abi.h Wed Oct 29 23:51:58 2008 +0000
3.2 +++ b/src/sh4/ia32abi.h Thu Oct 30 00:06:49 2008 +0000
3.3 @@ -333,7 +333,7 @@
3.4 return _URC_NO_REASON;
3.5 }
3.6
3.7 -void *xlat_get_native_pc()
3.8 +void *xlat_get_native_pc( void *code, uint32_t code_size )
3.9 {
3.10 struct _Unwind_Exception exc;
3.11 struct UnwindInfo info;
3.12 @@ -346,7 +346,7 @@
3.13 return NULL;
3.14 }
3.15 #else
3.16 -void *xlat_get_native_pc()
3.17 +void *xlat_get_native_pc( void *code, uint32_t code_size )
3.18 {
3.19 void *result = NULL;
3.20 asm(
4.1 --- a/src/sh4/ia32mac.h Wed Oct 29 23:51:58 2008 +0000
4.2 +++ b/src/sh4/ia32mac.h Thu Oct 30 00:06:49 2008 +0000
4.3 @@ -343,39 +343,37 @@
4.4 #include <unwind.h>
4.5
4.6 struct UnwindInfo {
4.7 - int have_result;
4.8 + uintptr_t block_start;
4.9 + uintptr_t block_end;
4.10 void *pc;
4.11 };
4.12
4.13 _Unwind_Reason_Code xlat_check_frame( struct _Unwind_Context *context, void *arg )
4.14 {
4.15 - void *ebp = (void *)_Unwind_GetGR(context, 5);
4.16 - void *expect = (((uint8_t *)&sh4r) + 128 );
4.17 struct UnwindInfo *info = arg;
4.18 - if( ebp == expect ) {
4.19 - info->have_result = 1;
4.20 - info->pc = (void *)_Unwind_GetIP(context);
4.21 - } else if( info->have_result ) {
4.22 + void *pc = (void *)_Unwind_GetIP(context);
4.23 + if( ((uintptr_t)pc) >= info->block_start && ((uintptr_t)pc) < info->block_end ) {
4.24 + info->pc = pc;
4.25 return _URC_NORMAL_STOP;
4.26 }
4.27
4.28 return _URC_NO_REASON;
4.29 }
4.30
4.31 -void *xlat_get_native_pc()
4.32 +void *xlat_get_native_pc( void *code, uint32_t code_size )
4.33 {
4.34 struct _Unwind_Exception exc;
4.35 struct UnwindInfo info;
4.36
4.37 - info.have_result = 0;
4.38 + info.pc = NULL;
4.39 + info.block_start = (uintptr_t)code;
4.40 + info.block_end = info.block_start + code_size;
4.41 void *result = NULL;
4.42 _Unwind_Backtrace( xlat_check_frame, &info );
4.43 - if( info.have_result )
4.44 - return info.pc;
4.45 - return NULL;
4.46 + return info.pc;
4.47 }
4.48 #else
4.49 -void *xlat_get_native_pc()
4.50 +void *xlat_get_native_pc( void *code, uint32_t code_size )
4.51 {
4.52 void *result = NULL;
4.53 asm(
5.1 --- a/src/sh4/sh4trans.c Wed Oct 29 23:51:58 2008 +0000
5.2 +++ b/src/sh4/sh4trans.c Thu Oct 30 00:06:49 2008 +0000
5.3 @@ -158,14 +158,17 @@
5.4
5.5 void sh4_translate_exit_recover( )
5.6 {
5.7 - void *pc = xlat_get_native_pc();
5.8 - if( pc != NULL ) {
5.9 - // could be null if we're not actually running inside the translator
5.10 - void *code = xlat_get_code( sh4r.pc );
5.11 - xlat_recovery_record_t recover = xlat_get_post_recovery(code, pc, TRUE);
5.12 - if( recover != NULL ) {
5.13 - // Can be null if there is no recovery necessary
5.14 - sh4_translate_run_recovery(recover);
5.15 + void *code = xlat_get_code_by_vma( sh4r.pc );
5.16 + if( code != NULL ) {
5.17 + uint32_t size = xlat_get_code_size( code );
5.18 + void *pc = xlat_get_native_pc( code, size );
5.19 + if( pc != NULL ) {
5.20 + // could be null if we're not actually running inside the translator
5.21 + xlat_recovery_record_t recover = xlat_get_post_recovery(code, pc, TRUE);
5.22 + if( recover != NULL ) {
5.23 + // Can be null if there is no recovery necessary
5.24 + sh4_translate_run_recovery(recover);
5.25 + }
5.26 }
5.27 }
5.28 }
5.29 @@ -191,19 +194,22 @@
5.30 */
5.31 gboolean sh4_translate_flush_cache()
5.32 {
5.33 - void *pc = xlat_get_native_pc();
5.34 - assert( pc != NULL );
5.35 + void *code = xlat_get_code_by_vma( sh4r.pc );
5.36 + if( code != NULL ) {
5.37 + uint32_t size = xlat_get_code_size( code );
5.38 + void *pc = xlat_get_native_pc( code, size );
5.39 + assert( pc != NULL );
5.40
5.41 - void *code = xlat_get_code( sh4r.pc );
5.42 - xlat_recovery_record_t recover = xlat_get_post_recovery(code, pc, FALSE);
5.43 - if( recover != NULL ) {
5.44 - // Can be null if there is no recovery necessary
5.45 - sh4_translate_run_recovery(recover);
5.46 - xlat_flush_cache();
5.47 - return TRUE;
5.48 - } else {
5.49 - xlat_flush_cache();
5.50 - return FALSE;
5.51 + xlat_recovery_record_t recover = xlat_get_post_recovery(code, pc, FALSE);
5.52 + if( recover != NULL ) {
5.53 + // Can be null if there is no recovery necessary
5.54 + sh4_translate_run_recovery(recover);
5.55 + xlat_flush_cache();
5.56 + return TRUE;
5.57 + } else {
5.58 + xlat_flush_cache();
5.59 + return FALSE;
5.60 + }
5.61 }
5.62 }
5.63
6.1 --- a/src/sh4/xltcache.h Wed Oct 29 23:51:58 2008 +0000
6.2 +++ b/src/sh4/xltcache.h Thu Oct 30 00:06:49 2008 +0000
6.3 @@ -142,9 +142,11 @@
6.4 * Retrieve the current host address of the running translated code block.
6.5 * @return the host PC, or null if there is no currently executing translated
6.6 * block (or the stack is corrupted)
6.7 - * Note: this method is implemented in host-specific asm.
6.8 + * Note: the implementation of this method is host (and calling-convention) specific.
6.9 + * @param block_start start of the block the PC should be in
6.10 + * @param block_size size of the code block in bytes.
6.11 */
6.12 -void *xlat_get_native_pc();
6.13 +void *xlat_get_native_pc( void *block_start, uint32_t block_size );
6.14
6.15 /**
6.16 * Retrieve the size of the block starting at the specified pointer. If the
.