--- a/src/sh4/xltcache.c Tue Jul 29 23:25:03 2008 +0000 +++ b/src/sh4/xltcache.c Sun Sep 28 01:09:51 2008 +0000 @@ -208,7 +208,7 @@ return result; } -xlat_recovery_record_t xlat_get_recovery( void *code, void *native_pc, gboolean recover_after ) +xlat_recovery_record_t xlat_get_post_recovery( void *code, void *native_pc, gboolean with_terminal ) { if( code != NULL ) { uintptr_t pc_offset = ((uint8_t *)native_pc) - ((uint8_t *)code); @@ -216,28 +216,39 @@ uint32_t count = block->recover_table_size; xlat_recovery_record_t records = (xlat_recovery_record_t)(&block->code[block->recover_table_offset]); uint32_t posn; - if( recover_after ) { - if( records[count-1].xlat_offset < pc_offset ) { - return NULL; - } - for( posn=count-1; posn > 0; posn-- ) { - if( records[posn-1].xlat_offset < pc_offset ) { - return &records[posn]; - } - } - return &records[0]; // shouldn't happen - } else { - for( posn = 1; posn < count; posn++ ) { - if( records[posn].xlat_offset >= pc_offset ) { - return &records[posn-1]; - } - } - return &records[count-1]; + if( count > 0 && !with_terminal ) + count--; + if( records[count-1].xlat_offset < pc_offset ) { + return NULL; } + for( posn=count-1; posn > 0; posn-- ) { + if( records[posn-1].xlat_offset < pc_offset ) { + return &records[posn]; + } + } + return &records[0]; // shouldn't happen } return NULL; } +xlat_recovery_record_t xlat_get_pre_recovery( void *code, void *native_pc ) +{ + if( code != NULL ) { + uintptr_t pc_offset = ((uint8_t *)native_pc) - ((uint8_t *)code); + xlat_cache_block_t block = BLOCK_FOR_CODE(code); + uint32_t count = block->recover_table_size; + xlat_recovery_record_t records = (xlat_recovery_record_t)(&block->code[block->recover_table_offset]); + uint32_t posn; + for( posn = 1; posn < count; posn++ ) { + if( records[posn].xlat_offset >= pc_offset ) { + return &records[posn-1]; + } + } + return &records[count-1]; + } + return NULL; +} + void **xlat_get_lut_entry( sh4addr_t address ) { void **page = xlat_lut[XLAT_LUT_PAGE(address)];