comparison debug.c @ 747:85c98a222fea

Merge
author Michael Pavone <pavone@retrodev.com>
date Thu, 28 May 2015 23:05:32 -0700
parents 2317bdca03b4 daa31ee7d8cd
children 724bbec47f86
comparison
equal deleted inserted replaced
740:25c9e9d39997 747:85c98a222fea
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 #ifndef _WIN32
6 #include <sys/select.h> 7 #include <sys/select.h>
8 #endif
7 #include "render.h" 9 #include "render.h"
8 10
9 static bp_def * breakpoints = NULL; 11 static bp_def * breakpoints = NULL;
10 static bp_def * zbreakpoints = NULL; 12 static bp_def * zbreakpoints = NULL;
11 static uint32_t bp_index = 0; 13 static uint32_t bp_index = 0;
508 uint16_t * after_pc = m68k_decode(pc, &inst, address); 510 uint16_t * after_pc = m68k_decode(pc, &inst, address);
509 m68k_disasm(&inst, input_buf); 511 m68k_disasm(&inst, input_buf);
510 printf("%X: %s\n", address, input_buf); 512 printf("%X: %s\n", address, input_buf);
511 uint32_t after = address + (after_pc-pc)*2; 513 uint32_t after = address + (after_pc-pc)*2;
512 int debugging = 1; 514 int debugging = 1;
515 #ifdef _WIN32
516 #define prompt 1
517 #else
513 int prompt = 1; 518 int prompt = 1;
514 fd_set read_fds; 519 fd_set read_fds;
515 FD_ZERO(&read_fds); 520 FD_ZERO(&read_fds);
516 struct timeval timeout; 521 struct timeval timeout;
522 #endif
517 while (debugging) { 523 while (debugging) {
518 if (prompt) { 524 if (prompt) {
519 fputs(">", stdout); 525 fputs(">", stdout);
520 fflush(stdout); 526 fflush(stdout);
521 } 527 }
522 process_events(); 528 process_events();
529 #ifndef _WIN32
523 timeout.tv_sec = 0; 530 timeout.tv_sec = 0;
524 timeout.tv_usec = 16667; 531 timeout.tv_usec = 16667;
525 FD_SET(fileno(stdin), &read_fds); 532 FD_SET(fileno(stdin), &read_fds);
526 if(select(fileno(stdin) + 1, &read_fds, NULL, NULL, &timeout) < 1) { 533 if(select(fileno(stdin) + 1, &read_fds, NULL, NULL, &timeout) < 1) {
527 prompt = 0; 534 prompt = 0;
528 continue; 535 continue;
529 } else { 536 } else {
530 prompt = 1; 537 prompt = 1;
531 } 538 }
539 #endif
532 if (!fgets(input_buf, sizeof(input_buf), stdin)) { 540 if (!fgets(input_buf, sizeof(input_buf), stdin)) {
533 fputs("fgets failed", stderr); 541 fputs("fgets failed", stderr);
534 break; 542 break;
535 } 543 }
536 strip_nl(input_buf); 544 strip_nl(input_buf);