summaryrefslogtreecommitdiff
path: root/debug.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-05-21 18:37:41 -0700
committerMichael Pavone <pavone@retrodev.com>2015-05-21 18:37:41 -0700
commit68f82c7735196d65a2d57ce8d36cac01a402c3a2 (patch)
treec32238fdd09f9ba469590cb7caecb03bb41e78f6 /debug.c
parentda1788598fe5f71295b6086ed8ef54fa39bbbd22 (diff)
Process events while waiting for 68K debugger input. This prevents "not responsive" dialogs when sitting in the debugger
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/debug.c b/debug.c
index 11ec9ad..ac5c34d 100644
--- a/debug.c
+++ b/debug.c
@@ -3,6 +3,8 @@
#include "68kinst.h"
#include <stdlib.h>
#include <string.h>
+#include <sys/select.h>
+#include "render.h"
static bp_def * breakpoints = NULL;
static bp_def * zbreakpoints = NULL;
@@ -508,8 +510,25 @@ m68k_context * debugger(m68k_context * context, uint32_t address)
printf("%X: %s\n", address, input_buf);
uint32_t after = address + (after_pc-pc)*2;
int debugging = 1;
+ int prompt = 1;
+ fd_set read_fds;
+ FD_ZERO(&read_fds);
+ struct timeval timeout;
while (debugging) {
- fputs(">", stdout);
+ if (prompt) {
+ fputs(">", stdout);
+ fflush(stdout);
+ }
+ process_events();
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 16667;
+ FD_SET(fileno(stdin), &read_fds);
+ if(select(fileno(stdin) + 1, &read_fds, NULL, NULL, &timeout) < 1) {
+ prompt = 0;
+ continue;
+ } else {
+ prompt = 1;
+ }
if (!fgets(input_buf, sizeof(input_buf), stdin)) {
fputs("fgets failed", stderr);
break;