Search
lxdream.org :: lxdream/src/sh4/ia32abi.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/ia32abi.h
changeset 899:18e0cdea76aa
prev736:a02d1475ccfd
next901:32c5cf5e206f
author nkeynes
date Sat Oct 25 12:36:42 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Add --enable-optimized flag (on by default).
When optimized, add -fomit-frame-pointer -fexceptions on non-Mac x86 (Unwinding doesn't seem to work correctly on Mac)
file annotate diff log raw
1.1 --- a/src/sh4/ia32abi.h Mon Jul 14 07:44:42 2008 +0000
1.2 +++ b/src/sh4/ia32abi.h Sat Oct 25 12:36:42 2008 +0000
1.3 @@ -264,6 +264,46 @@
1.4 }
1.5 }
1.6
1.7 +/**
1.8 + * The unwind methods only work if we compiled with DWARF2 frame information
1.9 + * (ie -fexceptions), otherwise we have to use the direct frame scan.
1.10 + */
1.11 +#ifdef HAVE_EXCEPTIONS
1.12 +#include <unwind.h>
1.13 +
1.14 +struct UnwindInfo {
1.15 + int have_result;
1.16 + void *pc;
1.17 +};
1.18 +
1.19 +_Unwind_Reason_Code xlat_check_frame( struct _Unwind_Context *context, void *arg )
1.20 +{
1.21 + void *ebp = (void *)_Unwind_GetGR(context, 5);
1.22 + void *expect = (((uint8_t *)&sh4r) + 128 );
1.23 + struct UnwindInfo *info = arg;
1.24 + if( ebp == expect ) {
1.25 + info->have_result = 1;
1.26 + info->pc = (void *)_Unwind_GetIP(context);
1.27 + } else if( info->have_result ) {
1.28 + return _URC_NORMAL_STOP;
1.29 + }
1.30 +
1.31 + return _URC_NO_REASON;
1.32 +}
1.33 +
1.34 +void *xlat_get_native_pc()
1.35 +{
1.36 + struct _Unwind_Exception exc;
1.37 + struct UnwindInfo info;
1.38 +
1.39 + info.have_result = 0;
1.40 + void *result = NULL;
1.41 + _Unwind_Backtrace( xlat_check_frame, &info );
1.42 + if( info.have_result )
1.43 + return info.pc;
1.44 + return NULL;
1.45 +}
1.46 +#else
1.47 void *xlat_get_native_pc()
1.48 {
1.49 void *result = NULL;
1.50 @@ -286,6 +326,7 @@
1.51 : "eax", "ecx", "edx" );
1.52 return result;
1.53 }
1.54 +#endif
1.55
1.56 #endif /* !lxdream_ia32abi_H */
1.57
.