Mercurial > repos > blastem
comparison m68k_core_x86.c @ 908:20e30ca7e8a2
Fix problem in 68K debugger caused by stack alignment change
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 02 Dec 2015 07:06:03 -0800 |
parents | 6011409ded0d |
children | 8cdd4ddedd9a |
comparison
equal
deleted
inserted
replaced
907:b5d35222047e | 908:20e30ca7e8a2 |
---|---|
2203 static code_ptr bp_stub = NULL; | 2203 static code_ptr bp_stub = NULL; |
2204 m68k_options * opts = context->options; | 2204 m68k_options * opts = context->options; |
2205 code_info native; | 2205 code_info native; |
2206 native.cur = get_native_address_trans(context, address); | 2206 native.cur = get_native_address_trans(context, address); |
2207 native.last = native.cur + 128; | 2207 native.last = native.cur + 128; |
2208 native.stack_off = 0; | |
2208 code_ptr start_native = native.cur; | 2209 code_ptr start_native = native.cur; |
2209 mov_ir(&native, address, opts->gen.scratch1, SZ_D); | 2210 mov_ir(&native, address, opts->gen.scratch1, SZ_D); |
2210 if (!bp_stub) { | 2211 if (!bp_stub) { |
2211 code_info *code = &opts->gen.code; | 2212 code_info *code = &opts->gen.code; |
2212 check_code_prologue(code); | 2213 check_code_prologue(code); |
2213 bp_stub = code->cur; | 2214 bp_stub = code->cur; |
2214 call(&native, bp_stub); | 2215 call(&native, bp_stub); |
2215 | 2216 |
2217 uint32_t tmp_stack_off = code->stack_off; | |
2216 //Calculate length of prologue | 2218 //Calculate length of prologue |
2217 check_cycles_int(&opts->gen, address); | 2219 check_cycles_int(&opts->gen, address); |
2218 int check_int_size = code->cur-bp_stub; | 2220 int check_int_size = code->cur-bp_stub; |
2219 code->cur = bp_stub; | 2221 code->cur = bp_stub; |
2222 code->stack_off = tmp_stack_off; | |
2220 | 2223 |
2221 //Save context and call breakpoint handler | 2224 //Save context and call breakpoint handler |
2222 call(code, opts->gen.save_context); | 2225 call(code, opts->gen.save_context); |
2223 push_r(code, opts->gen.scratch1); | 2226 push_r(code, opts->gen.scratch1); |
2224 call_args_abi(code, bp_handler, 2, opts->gen.context_reg, opts->gen.scratch1); | 2227 call_args_abi(code, bp_handler, 2, opts->gen.context_reg, opts->gen.scratch1); |
2234 *jmp_off = code->cur - (jmp_off+1); | 2237 *jmp_off = code->cur - (jmp_off+1); |
2235 //jump back to body of translated instruction | 2238 //jump back to body of translated instruction |
2236 pop_r(code, opts->gen.scratch1); | 2239 pop_r(code, opts->gen.scratch1); |
2237 add_ir(code, check_int_size - (native.cur-start_native), opts->gen.scratch1, SZ_PTR); | 2240 add_ir(code, check_int_size - (native.cur-start_native), opts->gen.scratch1, SZ_PTR); |
2238 jmp_r(code, opts->gen.scratch1); | 2241 jmp_r(code, opts->gen.scratch1); |
2242 code->stack_off = tmp_stack_off; | |
2239 } else { | 2243 } else { |
2240 call(&native, bp_stub); | 2244 call(&native, bp_stub); |
2241 } | 2245 } |
2242 } | 2246 } |
2243 | 2247 |
2502 opts->gen.handle_cycle_limit_int = code->cur; | 2506 opts->gen.handle_cycle_limit_int = code->cur; |
2503 //calculate stack adjust size | 2507 //calculate stack adjust size |
2504 add_ir(code, 16-sizeof(void*), RSP, SZ_PTR); | 2508 add_ir(code, 16-sizeof(void*), RSP, SZ_PTR); |
2505 uint32_t adjust_size = code->cur - opts->gen.handle_cycle_limit_int; | 2509 uint32_t adjust_size = code->cur - opts->gen.handle_cycle_limit_int; |
2506 code->cur = opts->gen.handle_cycle_limit_int; | 2510 code->cur = opts->gen.handle_cycle_limit_int; |
2507 | 2511 |
2508 cmp_rdispr(code, opts->gen.context_reg, offsetof(m68k_context, int_cycle), opts->gen.cycles, SZ_D); | 2512 cmp_rdispr(code, opts->gen.context_reg, offsetof(m68k_context, int_cycle), opts->gen.cycles, SZ_D); |
2509 code_ptr do_int = code->cur + 1; | 2513 code_ptr do_int = code->cur + 1; |
2510 jcc(code, CC_NC, code->cur + 2); | 2514 jcc(code, CC_NC, code->cur + 2); |
2511 cmp_rdispr(code, opts->gen.context_reg, offsetof(m68k_context, sync_cycle), opts->gen.cycles, SZ_D); | 2515 cmp_rdispr(code, opts->gen.context_reg, offsetof(m68k_context, sync_cycle), opts->gen.cycles, SZ_D); |
2512 skip_sync = code->cur + 1; | 2516 skip_sync = code->cur + 1; |