Mercurial > repos > blastem
comparison debug.c @ 1111:2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 19 Dec 2016 13:28:18 -0800 |
parents | 22e87b739ad6 |
children | 6b5c92b6205c |
comparison
equal
deleted
inserted
replaced
1110:d1eed3b1121c | 1111:2eb54e24914e |
---|---|
601 if (!param) { | 601 if (!param) { |
602 fputs("b command requires a parameter\n", stderr); | 602 fputs("b command requires a parameter\n", stderr); |
603 break; | 603 break; |
604 } | 604 } |
605 value = strtol(param, NULL, 16); | 605 value = strtol(param, NULL, 16); |
606 insert_breakpoint(context, value, (uint8_t *)debugger); | 606 insert_breakpoint(context, value, debugger); |
607 new_bp = malloc(sizeof(bp_def)); | 607 new_bp = malloc(sizeof(bp_def)); |
608 new_bp->next = breakpoints; | 608 new_bp->next = breakpoints; |
609 new_bp->address = value; | 609 new_bp->address = value; |
610 new_bp->index = bp_index++; | 610 new_bp->index = bp_index++; |
611 new_bp->commands = NULL; | 611 new_bp->commands = NULL; |
618 if (!param) { | 618 if (!param) { |
619 fputs("a command requires a parameter\n", stderr); | 619 fputs("a command requires a parameter\n", stderr); |
620 break; | 620 break; |
621 } | 621 } |
622 value = strtol(param, NULL, 16); | 622 value = strtol(param, NULL, 16); |
623 insert_breakpoint(context, value, (uint8_t *)debugger); | 623 insert_breakpoint(context, value, debugger); |
624 return 0; | 624 return 0; |
625 case 'd': | 625 case 'd': |
626 if (input_buf[1] == 'i') { | 626 if (input_buf[1] == 'i') { |
627 format_char = 0; | 627 format_char = 0; |
628 for(int i = 2; input_buf[i] != 0 && input_buf[i] != ' '; i++) { | 628 for(int i = 2; input_buf[i] != 0 && input_buf[i] != ' '; i++) { |
680 after = (read_dma_value((context->aregs[7]+2)/2) << 16) | read_dma_value((context->aregs[7]+2)/2 + 1); | 680 after = (read_dma_value((context->aregs[7]+2)/2) << 16) | read_dma_value((context->aregs[7]+2)/2 + 1); |
681 } else if(m68k_is_noncall_branch(&inst)) { | 681 } else if(m68k_is_noncall_branch(&inst)) { |
682 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) { | 682 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) { |
683 branch_f = after; | 683 branch_f = after; |
684 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs); | 684 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs); |
685 insert_breakpoint(context, branch_t, (uint8_t *)debugger); | 685 insert_breakpoint(context, branch_t, debugger); |
686 } else if(inst.op == M68K_DBCC) { | 686 } else if(inst.op == M68K_DBCC) { |
687 if ( inst.extra.cond == COND_FALSE) { | 687 if ( inst.extra.cond == COND_FALSE) { |
688 if (context->dregs[inst.dst.params.regs.pri] & 0xFFFF) { | 688 if (context->dregs[inst.dst.params.regs.pri] & 0xFFFF) { |
689 after = m68k_branch_target(&inst, context->dregs, context->aregs); | 689 after = m68k_branch_target(&inst, context->dregs, context->aregs); |
690 } | 690 } |
691 } else { | 691 } else { |
692 branch_t = after; | 692 branch_t = after; |
693 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs); | 693 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs); |
694 insert_breakpoint(context, branch_f, (uint8_t *)debugger); | 694 insert_breakpoint(context, branch_f, debugger); |
695 } | 695 } |
696 } else { | 696 } else { |
697 after = m68k_branch_target(&inst, context->dregs, context->aregs); | 697 after = m68k_branch_target(&inst, context->dregs, context->aregs); |
698 } | 698 } |
699 } | 699 } |
700 insert_breakpoint(context, after, (uint8_t *)debugger); | 700 insert_breakpoint(context, after, debugger); |
701 return 0; | 701 return 0; |
702 case 'o': | 702 case 'o': |
703 if (inst.op == M68K_RTS) { | 703 if (inst.op == M68K_RTS) { |
704 after = (read_dma_value(context->aregs[7]/2) << 16) | read_dma_value(context->aregs[7]/2 + 1); | 704 after = (read_dma_value(context->aregs[7]/2) << 16) | read_dma_value(context->aregs[7]/2 + 1); |
705 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) { | 705 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) { |
709 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; | 709 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
710 if (branch_t < after) { | 710 if (branch_t < after) { |
711 branch_t = 0; | 711 branch_t = 0; |
712 } else { | 712 } else { |
713 branch_f = after; | 713 branch_f = after; |
714 insert_breakpoint(context, branch_t, (uint8_t *)debugger); | 714 insert_breakpoint(context, branch_t, debugger); |
715 } | 715 } |
716 } else if(inst.op == M68K_DBCC) { | 716 } else if(inst.op == M68K_DBCC) { |
717 uint32_t target = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; | 717 uint32_t target = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
718 if (target > after) { | 718 if (target > after) { |
719 if (inst.extra.cond == COND_FALSE) { | 719 if (inst.extra.cond == COND_FALSE) { |
720 after = target; | 720 after = target; |
721 } else { | 721 } else { |
722 branch_f = target; | 722 branch_f = target; |
723 branch_t = after; | 723 branch_t = after; |
724 insert_breakpoint(context, branch_f, (uint8_t *)debugger); | 724 insert_breakpoint(context, branch_f, debugger); |
725 } | 725 } |
726 } | 726 } |
727 } else { | 727 } else { |
728 after = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; | 728 after = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
729 } | 729 } |
730 } | 730 } |
731 insert_breakpoint(context, after, (uint8_t *)debugger); | 731 insert_breakpoint(context, after, debugger); |
732 return 0; | 732 return 0; |
733 case 's': | 733 case 's': |
734 if (inst.op == M68K_RTS) { | 734 if (inst.op == M68K_RTS) { |
735 after = (read_dma_value(context->aregs[7]/2) << 16) | read_dma_value(context->aregs[7]/2 + 1); | 735 after = (read_dma_value(context->aregs[7]/2) << 16) | read_dma_value(context->aregs[7]/2 + 1); |
736 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) { | 736 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) { |
737 after = (read_dma_value((context->aregs[7]+2)/2) << 16) | read_dma_value((context->aregs[7]+2)/2 + 1); | 737 after = (read_dma_value((context->aregs[7]+2)/2) << 16) | read_dma_value((context->aregs[7]+2)/2 + 1); |
738 } else if(m68k_is_branch(&inst)) { | 738 } else if(m68k_is_branch(&inst)) { |
739 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) { | 739 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) { |
740 branch_f = after; | 740 branch_f = after; |
741 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; | 741 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
742 insert_breakpoint(context, branch_t, (uint8_t *)debugger); | 742 insert_breakpoint(context, branch_t, debugger); |
743 } else if(inst.op == M68K_DBCC && inst.extra.cond != COND_FALSE) { | 743 } else if(inst.op == M68K_DBCC && inst.extra.cond != COND_FALSE) { |
744 branch_t = after; | 744 branch_t = after; |
745 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; | 745 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
746 insert_breakpoint(context, branch_f, (uint8_t *)debugger); | 746 insert_breakpoint(context, branch_f, debugger); |
747 } else { | 747 } else { |
748 after = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; | 748 after = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
749 } | 749 } |
750 } | 750 } |
751 insert_breakpoint(context, after, (uint8_t *)debugger); | 751 insert_breakpoint(context, after, debugger); |
752 return 0; | 752 return 0; |
753 case 'v': { | 753 case 'v': { |
754 genesis_context * gen = context->system; | 754 genesis_context * gen = context->system; |
755 //VDP debug commands | 755 //VDP debug commands |
756 switch(input_buf[1]) | 756 switch(input_buf[1]) |