Mercurial > repos > blastem
comparison debug.c @ 723:7178d750efbd
Process events while waiting for 68K debugger input. This prevents "not responsive" dialogs when sitting in the debugger
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 21 May 2015 18:37:41 -0700 |
parents | 8aa9aacefe12 |
children | 2317bdca03b4 daa31ee7d8cd |
comparison
equal
deleted
inserted
replaced
722:8f5339961903 | 723:7178d750efbd |
---|---|
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; |
506 uint16_t * after_pc = m68k_decode(pc, &inst, address); | 508 uint16_t * after_pc = m68k_decode(pc, &inst, address); |
507 m68k_disasm(&inst, input_buf); | 509 m68k_disasm(&inst, input_buf); |
508 printf("%X: %s\n", address, input_buf); | 510 printf("%X: %s\n", address, input_buf); |
509 uint32_t after = address + (after_pc-pc)*2; | 511 uint32_t after = address + (after_pc-pc)*2; |
510 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; | |
511 while (debugging) { | 517 while (debugging) { |
512 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 } | |
513 if (!fgets(input_buf, sizeof(input_buf), stdin)) { | 532 if (!fgets(input_buf, sizeof(input_buf), stdin)) { |
514 fputs("fgets failed", stderr); | 533 fputs("fgets failed", stderr); |
515 break; | 534 break; |
516 } | 535 } |
517 strip_nl(input_buf); | 536 strip_nl(input_buf); |