summaryrefslogtreecommitdiff
path: root/gdb_remote.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-07-25 18:22:07 -0700
committerMichael Pavone <pavone@retrodev.com>2015-07-25 18:22:07 -0700
commit80ff833dd8ad011b579bff26ac654819e6735bce (patch)
tree14f667ebb4739fd60780890884b98ce43e6b2e74 /gdb_remote.c
parent7406c8bf64624feff0bf982e4667a194d31f8484 (diff)
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Diffstat (limited to 'gdb_remote.c')
-rw-r--r--gdb_remote.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/gdb_remote.c b/gdb_remote.c
index 764cf83..0ea20c0 100644
--- a/gdb_remote.c
+++ b/gdb_remote.c
@@ -6,6 +6,7 @@
#include "gdb_remote.h"
#include "68kinst.h"
#include "debug.h"
+#include "util.h"
#include <unistd.h>
#include <fcntl.h>
#include <stddef.h>
@@ -76,8 +77,7 @@ void gdb_calc_checksum(char * command, char *out)
void write_or_die(int fd, const void *buf, size_t count)
{
if (write(fd, buf, count) < count) {
- fputs("Error writing to stdout\n", stderr);
- exit(1);
+ fatal_error("Error writing to stdout\n");
}
}
@@ -186,8 +186,7 @@ void gdb_run_command(m68k_context * context, uint32_t pc, char * command)
} else if(pc > 0xE00000) {
pc_ptr = ram + (pc & 0xFFFF)/2;
} else {
- fprintf(stderr, "Entered gdb remote debugger stub at address %X\n", pc);
- exit(1);
+ fatal_error("Entered gdb remote debugger stub at address %X\n", pc);
}
uint16_t * after_pc = m68k_decode(pc_ptr, &inst, pc & 0xFFFFFF);
uint32_t after = pc + (after_pc-pc_ptr)*2;
@@ -407,8 +406,7 @@ void gdb_run_command(m68k_context * context, uint32_t pc, char * command)
} else if(pc > 0xE00000) {
pc_ptr = ram + (pc & 0xFFFF)/2;
} else {
- fprintf(stderr, "Entered gdb remote debugger stub at address %X\n", pc);
- exit(1);
+ fatal_error("Entered gdb remote debugger stub at address %X\n", pc);
}
uint16_t * after_pc = m68k_decode(pc_ptr, &inst, pc & 0xFFFFFF);
uint32_t after = pc + (after_pc-pc_ptr)*2;
@@ -452,8 +450,7 @@ void gdb_run_command(m68k_context * context, uint32_t pc, char * command)
}
return;
not_impl:
- fprintf(stderr, "Command %s is not implemented, exiting...\n", command);
- exit(1);
+ fatal_error("Command %s is not implemented, exiting...\n", command);
}
m68k_context * gdb_debug_enter(m68k_context * context, uint32_t pc)
@@ -516,8 +513,7 @@ m68k_context * gdb_debug_enter(m68k_context * context, uint32_t pc)
*curbuf = 0;
//send acknowledgement
if (write(STDOUT_FILENO, "+", 1) < 1) {
- fputs("Error writing to stdout\n", stderr);
- exit(1);
+ fatal_error("Error writing to stdout\n");
}
gdb_run_command(context, pc, start);
curbuf += 2;