Mercurial > repos > blastem
comparison debug.c @ 1922:4a811fd1fb6f
Added soft reset command to debugger. Added more debugger help
author | Eric Fry <yuv422@users.noreply.github.com> |
---|---|
date | Fri, 10 Apr 2020 23:01:13 +1000 |
parents | 5d028088e320 |
children | 23394a890508 |
comparison
equal
deleted
inserted
replaced
1921:5d028088e320 | 1922:4a811fd1fb6f |
---|---|
139 value &= 0xFFFF; | 139 value &= 0xFFFF; |
140 } else if (param[3] == 'b') { | 140 } else if (param[3] == 'b') { |
141 value &= 0xFF; | 141 value &= 0xFF; |
142 } | 142 } |
143 } | 143 } |
144 } else if (param[0] == 'S' && param[1] == 'R') { | 144 } else if (param[0] == 's' && param[1] == 'r') { |
145 value = (context->status << 8); | 145 value = (context->status << 8); |
146 for (int flag = 0; flag < 5; flag++) { | 146 for (int flag = 0; flag < 5; flag++) { |
147 value |= context->flags[flag] << (4-flag); | 147 value |= context->flags[flag] << (4-flag); |
148 } | 148 } |
149 } else if(param[0] == 'c') { | 149 } else if(param[0] == 'c') { |
150 value = context->current_cycle; | 150 value = context->current_cycle; |
151 } else if(param[0] == 'f') { | 151 } else if(param[0] == 'f') { |
152 genesis_context *gen = context->system; | 152 genesis_context *gen = context->system; |
153 value = gen->vdp->frame; | 153 value = gen->vdp->frame; |
154 } else if (param[0] == 'p' && param[1] == 'c') { | |
155 value = 0; //TODO PC value here; | |
154 } else if ((param[0] == '0' && param[1] == 'x') || param[0] == '$') { | 156 } else if ((param[0] == '0' && param[1] == 'x') || param[0] == '$') { |
155 char *after; | 157 char *after; |
156 uint32_t p_addr = strtol(param+(param[0] == '0' ? 2 : 1), &after, 16); | 158 uint32_t p_addr = strtol(param+(param[0] == '0' ? 2 : 1), &after, 16); |
157 if (after[0] == '.' && after[1] == 'l') { | 159 if (after[0] == '.' && after[1] == 'l') { |
158 value = m68k_read_long(p_addr, context); | 160 value = m68k_read_long(p_addr, context); |
571 #endif | 573 #endif |
572 | 574 |
573 static uint32_t branch_t; | 575 static uint32_t branch_t; |
574 static uint32_t branch_f; | 576 static uint32_t branch_f; |
575 | 577 |
576 int run_debugger_command(m68k_context *context, char *input_buf, m68kinst inst, uint32_t after) | 578 int run_debugger_command(m68k_context *context, uint32_t address, char *input_buf, m68kinst inst, uint32_t after) |
577 { | 579 { |
578 char * param; | 580 char * param; |
579 char format_char; | 581 char format_char; |
580 genesis_context *system = context->system; | 582 genesis_context *system = context->system; |
581 uint32_t value; | 583 uint32_t value; |
721 break; | 723 break; |
722 } | 724 } |
723 } | 725 } |
724 param = find_param(input_buf); | 726 param = find_param(input_buf); |
725 if (!param) { | 727 if (!param) { |
726 fputs("p command requires a parameter\n", stderr); | 728 m68k_disasm(&inst, input_buf); |
729 printf("%X: %s\n", address, input_buf); | |
727 break; | 730 break; |
728 } | 731 } |
729 debugger_print(context, format_char, param); | 732 debugger_print(context, format_char, param); |
730 break; | 733 break; |
731 case 'n': | 734 case 'n': |
788 case 's': | 791 case 's': |
789 if (input_buf[1] == 'e') { | 792 if (input_buf[1] == 'e') { |
790 param = find_param(input_buf); | 793 param = find_param(input_buf); |
791 if (!param) { | 794 if (!param) { |
792 fputs("Missing destination parameter for set\n", stderr); | 795 fputs("Missing destination parameter for set\n", stderr); |
796 return 1; | |
793 } | 797 } |
794 char *val = find_param(param); | 798 char *val = find_param(param); |
795 if (!val) { | 799 if (!val) { |
796 fputs("Missing value parameter for set\n", stderr); | 800 fputs("Missing value parameter for set\n", stderr); |
801 return 1; | |
797 } | 802 } |
798 long int_val; | 803 long int_val; |
799 int reg_num; | 804 int reg_num; |
800 switch (val[0]) | 805 switch (val[0]) |
801 { | 806 { |
832 break; | 837 break; |
833 default: | 838 default: |
834 fprintf(stderr, "Invalid destinatino %s\n", param); | 839 fprintf(stderr, "Invalid destinatino %s\n", param); |
835 } | 840 } |
836 break; | 841 break; |
842 } else if (input_buf[1] == 'r') { | |
843 system->header.soft_reset(&system->header); | |
844 return 0; | |
837 } else { | 845 } else { |
838 if (inst.op == M68K_RTS) { | 846 if (inst.op == M68K_RTS) { |
839 after = m68k_read_long(context->aregs[7], context); | 847 after = m68k_read_long(context->aregs[7], context); |
840 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) { | 848 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) { |
841 after = m68k_read_long(context->aregs[7] + 2, context); | 849 after = m68k_read_long(context->aregs[7] + 2, context); |
933 break; | 941 break; |
934 case 'q': | 942 case 'q': |
935 puts("Quitting"); | 943 puts("Quitting"); |
936 exit(0); | 944 exit(0); |
937 break; | 945 break; |
938 default: | 946 default: |
939 fprintf(stderr, "Unrecognized debugger command %s\nUse '?' for help.\n", input_buf); | 947 fprintf(stderr, "Unrecognized debugger command %s\nUse '?' for help.\n", input_buf); |
940 break; | 948 break; |
941 } | 949 } |
942 return 1; | 950 return 1; |
943 } | 951 } |
952 printf(" a ADDRESS - Advance to address\n"); | 960 printf(" a ADDRESS - Advance to address\n"); |
953 printf(" n - Advance to next instruction\n"); | 961 printf(" n - Advance to next instruction\n"); |
954 printf(" o - Advance to next instruction ignoring branches to\n"); | 962 printf(" o - Advance to next instruction ignoring branches to\n"); |
955 printf(" lower addresses (good for breaking out of loops)\n"); | 963 printf(" lower addresses (good for breaking out of loops)\n"); |
956 printf(" s - Advance to next instruction (follows bsr/jsr)\n"); | 964 printf(" s - Advance to next instruction (follows bsr/jsr)\n"); |
965 printf(" se REG|ADDRESS VALUE - Set value\n"); | |
966 printf(" sr - Soft reset\n"); | |
957 printf(" c - Continue\n"); | 967 printf(" c - Continue\n"); |
958 printf(" bt - Print a backtrace\n"); | 968 printf(" bt - Print a backtrace\n"); |
959 printf(" p[/(x|X|d|c)] VALUE - Print a register or memory location\n"); | 969 printf(" p[/(x|X|d|c)] VALUE - Print a register or memory location\n"); |
960 printf(" di[/(x|X|d|c)] VALUE - Print a register or memory location each time\n"); | 970 printf(" di[/(x|X|d|c)] VALUE - Print a register or memory location each time\n"); |
961 printf(" a breakpoint is hit\n"); | 971 printf(" a breakpoint is hit\n"); |
962 printf(" vs - Print VDP sprite list\n"); | 972 printf(" vs - Print VDP sprite list\n"); |
963 printf(" vr - Print VDP register info\n"); | 973 printf(" vr - Print VDP register info\n"); |
974 printf(" yc [CHANNEL NUM] - Print YM-2612 channel info\n"); | |
975 printf(" yt - Print YM-2612 timer info\n"); | |
964 printf(" zb ADDRESS - Set a Z80 breakpoint\n"); | 976 printf(" zb ADDRESS - Set a Z80 breakpoint\n"); |
965 printf(" zp[/(x|X|d|c)] VALUE - Display a Z80 value\n"); | 977 printf(" zp[/(x|X|d|c)] VALUE - Display a Z80 value\n"); |
966 printf(" ? - Display help\n"); | 978 printf(" ? - Display help\n"); |
967 printf(" q - Quit BlastEm\n"); | 979 printf(" q - Quit BlastEm\n"); |
968 } | 980 } |
1027 while (debugging && *commands) | 1039 while (debugging && *commands) |
1028 { | 1040 { |
1029 char *cmd = commands; | 1041 char *cmd = commands; |
1030 strip_nl(cmd); | 1042 strip_nl(cmd); |
1031 commands += strlen(cmd) + 1; | 1043 commands += strlen(cmd) + 1; |
1032 debugging = run_debugger_command(context, cmd, inst, after); | 1044 debugging = run_debugger_command(context, address, cmd, inst, after); |
1033 } | 1045 } |
1034 free(copy); | 1046 free(copy); |
1035 } | 1047 } |
1036 if (debugging) { | 1048 if (debugging) { |
1037 printf("68K Breakpoint %d hit\n", (*this_bp)->index); | 1049 printf("68K Breakpoint %d hit\n", (*this_bp)->index); |
1080 if (input_buf[0]) { | 1092 if (input_buf[0]) { |
1081 strcpy(last_cmd, input_buf); | 1093 strcpy(last_cmd, input_buf); |
1082 } else { | 1094 } else { |
1083 strcpy(input_buf, last_cmd); | 1095 strcpy(input_buf, last_cmd); |
1084 } | 1096 } |
1085 debugging = run_debugger_command(context, input_buf, inst, after); | 1097 debugging = run_debugger_command(context, address, input_buf, inst, after); |
1086 } | 1098 } |
1087 return; | 1099 return; |
1088 } | 1100 } |