comparison debug.c @ 849:1416c4261d5b

Fix some debug commands that got broken when I added support for the command command
author Michael Pavone <pavone@retrodev.com>
date Sun, 01 Nov 2015 20:39:40 -0800
parents 079eb395ddd1
children 305c85c0b954
comparison
equal deleted inserted replaced
848:7068a9db6dd0 849:1416c4261d5b
513 #endif 513 #endif
514 514
515 static uint32_t branch_t; 515 static uint32_t branch_t;
516 static uint32_t branch_f; 516 static uint32_t branch_f;
517 517
518 int run_debugger_command(m68k_context *context, char *input_buf) 518 int run_debugger_command(m68k_context *context, char *input_buf, m68kinst inst, uint32_t after)
519 { 519 {
520 m68kinst inst;
521 char * param; 520 char * param;
522 char format_char; 521 char format_char;
523 uint32_t value, after; 522 uint32_t value;
524 bp_def *new_bp, **this_bp; 523 bp_def *new_bp, **this_bp;
525 switch(input_buf[0]) 524 switch(input_buf[0])
526 { 525 {
527 case 'c': 526 case 'c':
528 if (input_buf[1] == 0 || input_buf[1] == 'o' && input_buf[2] == 'n') 527 if (input_buf[1] == 0 || input_buf[1] == 'o' && input_buf[2] == 'n')
843 if (!*t_bp) { 842 if (!*t_bp) {
844 remove_breakpoint(context, branch_t); 843 remove_breakpoint(context, branch_t);
845 } 844 }
846 branch_t = branch_f = 0; 845 branch_t = branch_f = 0;
847 } 846 }
848 int debugging = 1; 847
849 //Check if this is a user set breakpoint, or just a temporary one
850 bp_def ** this_bp = find_breakpoint(&breakpoints, address);
851 if (*this_bp) {
852
853 if ((*this_bp)->commands)
854 {
855 char *commands = strdup((*this_bp)->commands);
856 char *copy = commands;
857
858 while (debugging && *commands)
859 {
860 char *cmd = commands;
861 strip_nl(cmd);
862 commands += strlen(cmd) + 1;
863 debugging = run_debugger_command(context, cmd);
864 }
865 free(copy);
866 }
867 if (debugging) {
868 printf("68K Breakpoint %d hit\n", (*this_bp)->index);
869 } else {
870 return context;
871 }
872 } else {
873 remove_breakpoint(context, address);
874 }
875 for (disp_def * cur = displays; cur; cur = cur->next) {
876 debugger_print(context, cur->format_char, cur->param);
877 }
878 uint16_t * pc; 848 uint16_t * pc;
879 if (address < 0x400000) { 849 if (address < 0x400000) {
880 pc = cart + address/2; 850 pc = cart + address/2;
881 } else if(address > 0xE00000) { 851 } else if(address > 0xE00000) {
882 pc = ram + (address & 0xFFFF)/2; 852 pc = ram + (address & 0xFFFF)/2;
883 } else { 853 } else {
884 fatal_error("Entered 68K debugger at address %X\n", address); 854 fatal_error("Entered 68K debugger at address %X\n", address);
885 } 855 }
886 uint16_t * after_pc = m68k_decode(pc, &inst, address); 856 uint16_t * after_pc = m68k_decode(pc, &inst, address);
857 uint32_t after = address + (after_pc-pc)*2;
858 int debugging = 1;
859 //Check if this is a user set breakpoint, or just a temporary one
860 bp_def ** this_bp = find_breakpoint(&breakpoints, address);
861 if (*this_bp) {
862
863 if ((*this_bp)->commands)
864 {
865 char *commands = strdup((*this_bp)->commands);
866 char *copy = commands;
867
868 while (debugging && *commands)
869 {
870 char *cmd = commands;
871 strip_nl(cmd);
872 commands += strlen(cmd) + 1;
873 debugging = run_debugger_command(context, cmd, inst, after);
874 }
875 free(copy);
876 }
877 if (debugging) {
878 printf("68K Breakpoint %d hit\n", (*this_bp)->index);
879 } else {
880 return context;
881 }
882 } else {
883 remove_breakpoint(context, address);
884 }
885 for (disp_def * cur = displays; cur; cur = cur->next) {
886 debugger_print(context, cur->format_char, cur->param);
887 }
887 m68k_disasm(&inst, input_buf); 888 m68k_disasm(&inst, input_buf);
888 printf("%X: %s\n", address, input_buf); 889 printf("%X: %s\n", address, input_buf);
889 uint32_t after = address + (after_pc-pc)*2;
890 #ifdef _WIN32 890 #ifdef _WIN32
891 #define prompt 1 891 #define prompt 1
892 #else 892 #else
893 int prompt = 1; 893 int prompt = 1;
894 fd_set read_fds; 894 fd_set read_fds;
921 if (input_buf[0]) { 921 if (input_buf[0]) {
922 strcpy(last_cmd, input_buf); 922 strcpy(last_cmd, input_buf);
923 } else { 923 } else {
924 strcpy(input_buf, last_cmd); 924 strcpy(input_buf, last_cmd);
925 } 925 }
926 debugging = run_debugger_command(context, input_buf); 926 debugging = run_debugger_command(context, input_buf, inst, after);
927 } 927 }
928 return context; 928 return context;
929 } 929 }