comparison debug.c @ 1692:5dacaef602a7 segacd

Merge from default
author Michael Pavone <pavone@retrodev.com>
date Sat, 05 Jan 2019 00:58:08 -0800
parents 5aa0c3c43b97
children d6d4c006a7b3
comparison
equal deleted inserted replaced
1504:95b3a1a8b26c 1692:5dacaef602a7
785 } 785 }
786 } 786 }
787 insert_breakpoint(context, after, debugger); 787 insert_breakpoint(context, after, debugger);
788 return 0; 788 return 0;
789 case 's': 789 case 's':
790 if (inst.op == M68K_RTS) { 790 if (input_buf[1] == 'e') {
791 after = m68k_read_long(context->aregs[7], context); 791 param = find_param(input_buf);
792 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) { 792 if (!param) {
793 after = m68k_read_long(context->aregs[7] + 2, context); 793 fputs("Missing destination parameter for set\n", stderr);
794 } else if(m68k_is_branch(&inst)) { 794 }
795 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) { 795 char *val = find_param(param);
796 branch_f = after; 796 if (!val) {
797 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; 797 fputs("Missing value parameter for set\n", stderr);
798 insert_breakpoint(context, branch_t, debugger); 798 }
799 } else if(inst.op == M68K_DBCC) { 799 long int_val;
800 if (inst.extra.cond == COND_FALSE) { 800 int reg_num;
801 if (context->dregs[inst.dst.params.regs.pri] & 0xFFFF) { 801 switch (val[0])
802 after = m68k_branch_target(&inst, context->dregs, context->aregs); 802 {
803 case 'd':
804 case 'a':
805 reg_num = val[1] - '0';
806 if (reg_num < 0 || reg_num > 8) {
807 fprintf(stderr, "Invalid register %s\n", val);
808 return 1;
809 }
810 int_val = (val[0] == 'd' ? context->dregs : context->aregs)[reg_num];
811 break;
812 case '$':
813 int_val = strtol(val+1, NULL, 16);
814 break;
815 case '0':
816 if (val[1] == 'x') {
817 int_val = strtol(val+2, NULL, 16);
818 break;
819 }
820 default:
821 int_val = strtol(val, NULL, 10);
822 }
823 switch(param[0])
824 {
825 case 'd':
826 case 'a':
827 reg_num = param[1] - '0';
828 if (reg_num < 0 || reg_num > 8) {
829 fprintf(stderr, "Invalid register %s\n", param);
830 return 1;
831 }
832 (param[0] == 'd' ? context->dregs : context->aregs)[reg_num] = int_val;
833 break;
834 default:
835 fprintf(stderr, "Invalid destinatino %s\n", param);
836 }
837 break;
838 } else {
839 if (inst.op == M68K_RTS) {
840 after = m68k_read_long(context->aregs[7], context);
841 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) {
842 after = m68k_read_long(context->aregs[7] + 2, context);
843 } else if(m68k_is_branch(&inst)) {
844 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) {
845 branch_f = after;
846 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF;
847 insert_breakpoint(context, branch_t, debugger);
848 } else if(inst.op == M68K_DBCC) {
849 if (inst.extra.cond == COND_FALSE) {
850 if (context->dregs[inst.dst.params.regs.pri] & 0xFFFF) {
851 after = m68k_branch_target(&inst, context->dregs, context->aregs);
852 }
853 } else {
854 branch_t = after;
855 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs);
856 insert_breakpoint(context, branch_f, debugger);
803 } 857 }
804 } else { 858 } else {
805 branch_t = after; 859 after = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF;
806 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs); 860 }
807 insert_breakpoint(context, branch_f, debugger); 861 }
808 } 862 insert_breakpoint(context, after, debugger);
809 } else { 863 return 0;
810 after = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; 864 }
811 }
812 }
813 insert_breakpoint(context, after, debugger);
814 return 0;
815 case 'v': { 865 case 'v': {
816 genesis_context * gen = context->system; 866 genesis_context * gen = context->system;
817 //VDP debug commands 867 //VDP debug commands
818 switch(input_buf[1]) 868 switch(input_buf[1])
819 { 869 {
898 m68kinst inst; 948 m68kinst inst;
899 949
900 init_terminal(); 950 init_terminal();
901 951
902 sync_components(context, 0); 952 sync_components(context, 0);
953 genesis_context *gen = context->system;
954 vdp_force_update_framebuffer(gen->vdp);
903 //probably not necessary, but let's play it safe 955 //probably not necessary, but let's play it safe
904 address &= 0xFFFFFF; 956 address &= 0xFFFFFF;
905 if (address == branch_t) { 957 if (address == branch_t) {
906 bp_def ** f_bp = find_breakpoint(&breakpoints, branch_f); 958 bp_def ** f_bp = find_breakpoint(&breakpoints, branch_f);
907 if (!*f_bp) { 959 if (!*f_bp) {