Mercurial > repos > blastem
comparison debug.c @ 744:fc68992cf18d
Merge windows branch with latest changes
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 28 May 2015 21:19:55 -0700 |
parents | 7178d750efbd |
children | 2317bdca03b4 daa31ee7d8cd |
comparison
equal
deleted
inserted
replaced
743:cf78cb045fa4 | 744:fc68992cf18d |
---|---|
1 #include "debug.h" | 1 #include "debug.h" |
2 #include "blastem.h" | 2 #include "blastem.h" |
3 #include "68kinst.h" | 3 #include "68kinst.h" |
4 #include <stdlib.h> | 4 #include <stdlib.h> |
5 #include <string.h> | 5 #include <string.h> |
6 #include <sys/select.h> | |
7 #include "render.h" | |
6 | 8 |
7 static bp_def * breakpoints = NULL; | 9 static bp_def * breakpoints = NULL; |
8 static bp_def * zbreakpoints = NULL; | 10 static bp_def * zbreakpoints = NULL; |
9 static uint32_t bp_index = 0; | 11 static uint32_t bp_index = 0; |
10 static uint32_t zbp_index = 0; | 12 static uint32_t zbp_index = 0; |
469 static char last_cmd[1024]; | 471 static char last_cmd[1024]; |
470 char input_buf[1024]; | 472 char input_buf[1024]; |
471 static uint32_t branch_t; | 473 static uint32_t branch_t; |
472 static uint32_t branch_f; | 474 static uint32_t branch_f; |
473 m68kinst inst; | 475 m68kinst inst; |
476 sync_components(context, 0); | |
474 //probably not necessary, but let's play it safe | 477 //probably not necessary, but let's play it safe |
475 address &= 0xFFFFFF; | 478 address &= 0xFFFFFF; |
476 if (address == branch_t) { | 479 if (address == branch_t) { |
477 bp_def ** f_bp = find_breakpoint(&breakpoints, branch_f); | 480 bp_def ** f_bp = find_breakpoint(&breakpoints, branch_f); |
478 if (!*f_bp) { | 481 if (!*f_bp) { |
505 uint16_t * after_pc = m68k_decode(pc, &inst, address); | 508 uint16_t * after_pc = m68k_decode(pc, &inst, address); |
506 m68k_disasm(&inst, input_buf); | 509 m68k_disasm(&inst, input_buf); |
507 printf("%X: %s\n", address, input_buf); | 510 printf("%X: %s\n", address, input_buf); |
508 uint32_t after = address + (after_pc-pc)*2; | 511 uint32_t after = address + (after_pc-pc)*2; |
509 int debugging = 1; | 512 int debugging = 1; |
513 int prompt = 1; | |
514 fd_set read_fds; | |
515 FD_ZERO(&read_fds); | |
516 struct timeval timeout; | |
510 while (debugging) { | 517 while (debugging) { |
511 fputs(">", stdout); | 518 if (prompt) { |
519 fputs(">", stdout); | |
520 fflush(stdout); | |
521 } | |
522 process_events(); | |
523 timeout.tv_sec = 0; | |
524 timeout.tv_usec = 16667; | |
525 FD_SET(fileno(stdin), &read_fds); | |
526 if(select(fileno(stdin) + 1, &read_fds, NULL, NULL, &timeout) < 1) { | |
527 prompt = 0; | |
528 continue; | |
529 } else { | |
530 prompt = 1; | |
531 } | |
512 if (!fgets(input_buf, sizeof(input_buf), stdin)) { | 532 if (!fgets(input_buf, sizeof(input_buf), stdin)) { |
513 fputs("fgets failed", stderr); | 533 fputs("fgets failed", stderr); |
514 break; | 534 break; |
515 } | 535 } |
516 strip_nl(input_buf); | 536 strip_nl(input_buf); |
630 for (int flag = 0; flag < 5; flag++) { | 650 for (int flag = 0; flag < 5; flag++) { |
631 value |= context->flags[flag] << (4-flag); | 651 value |= context->flags[flag] << (4-flag); |
632 } | 652 } |
633 } else if(param[0] == 'c') { | 653 } else if(param[0] == 'c') { |
634 value = context->current_cycle; | 654 value = context->current_cycle; |
635 } else if (param[0] == '0' && param[1] == 'x') { | 655 } else if ((param[0] == '0' && param[1] == 'x') || param[0] == '$') { |
636 uint32_t p_addr = strtol(param+2, NULL, 16); | 656 uint32_t p_addr = strtol(param+(param[0] == '0' ? 2 : 1), NULL, 16); |
637 value = read_dma_value(p_addr/2); | 657 if ((p_addr & 0xFFFFFF) == 0xC00004) { |
658 genesis_context * gen = context->system; | |
659 value = vdp_hv_counter_read(gen->vdp); | |
660 } else { | |
661 value = read_dma_value(p_addr/2); | |
662 } | |
638 } else { | 663 } else { |
639 fprintf(stderr, "Unrecognized parameter to p: %s\n", param); | 664 fprintf(stderr, "Unrecognized parameter to p: %s\n", param); |
640 break; | 665 break; |
641 } | 666 } |
642 printf(format, param, value); | 667 printf(format, param, value); |