# HG changeset patch # User Michael Pavone # Date 1483261844 28800 # Node ID 136b1676109bcc121240f51aa5e0afdc70c849c3 # Parent 8f14767661fa7fe8f8f82f31ddb56c4deb4ebf0c Partial fix for Z80 debugger brokeness introduced with stack alignment changes diff -r 8f14767661fa -r 136b1676109b z80_to_x86.c --- a/z80_to_x86.c Wed Dec 28 20:39:27 2016 -0800 +++ b/z80_to_x86.c Sun Jan 01 01:10:44 2017 -0800 @@ -3662,7 +3662,15 @@ uint32_t zbreakpoint_patch(z80_context * context, uint16_t address, code_ptr dst) { - code_info code = {dst, dst+32}; + code_info code = { + dst, + dst+32, +#ifdef X86_64 + 8 +#else + 0 +#endif + }; mov_ir(&code, address, context->options->gen.scratch1, SZ_W); call(&code, context->bp_stub); return code.cur-dst; @@ -3670,13 +3678,14 @@ void zcreate_stub(z80_context * context) { + //FIXME: Stack offset stuff is still a bit broken z80_options * opts = context->options; code_info *code = &opts->gen.code; uint32_t start_stack_off = code->stack_off; check_code_prologue(code); context->bp_stub = code->cur; - //Calculate length of prologue + //Calculate length of prologue check_cycles_int(&opts->gen, 0); int check_int_size = code->cur-context->bp_stub; code->cur = context->bp_stub; @@ -3684,7 +3693,10 @@ //Calculate length of patch int patch_size = zbreakpoint_patch(context, 0, code->cur); - //Save context and call breakpoint handler +#ifdef X86_64 + code->stack_off = 8; +#endif + //Save context and call breakpoint handler call(code, opts->gen.save_context); push_r(code, opts->gen.scratch1); call_args_abi(code, context->bp_handler, 2, opts->gen.context_reg, opts->gen.scratch1); @@ -3693,7 +3705,7 @@ call(code, opts->gen.load_context); pop_r(code, opts->gen.scratch1); //do prologue stuff - or_rr(code, opts->gen.cycles, opts->gen.cycles, SZ_D); + cmp_ir(code, 1, opts->gen.cycles, SZ_D); uint8_t * jmp_off = code->cur+1; jcc(code, CC_NS, code->cur + 7); pop_r(code, opts->gen.scratch1); @@ -3732,7 +3744,7 @@ z80_options * opts = context->options; code_info tmp_code = opts->gen.code; opts->gen.code.cur = native; - opts->gen.code.last = native + 16; + opts->gen.code.last = native + 128; check_cycles_int(&opts->gen, address); opts->gen.code = tmp_code; }