diff --git a/gdbstub.c b/gdbstub.c index 775a239..78ec755 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -45,7 +45,7 @@ #include #endif -#define DEBUG_GDB +//#define DEBUG_GDB enum RSState { RS_IDLE, @@ -455,7 +455,7 @@ static void gdb_read_byte(GDBState *s, int ch) int i, csum; char reply[1]; -printf("%s: state %u, byte %02x (%c)\n", __FUNCTION__, s->state, ch, ch); +//printf("%s: state %u, byte %02x (%c)\n", __FUNCTION__, s->state, ch, ch); fflush(stdout); switch(s->state) { @@ -515,7 +515,7 @@ gdb_handlesig (CPUState *env, int sig) s = &gdbserver_state; -printf("%s: sig: %u\n", __FUNCTION__, sig); +//printf("%s: sig: %u\n", __FUNCTION__, sig); fflush(stdout); /* disable single step if it was enabled */ @@ -537,7 +537,7 @@ fflush(stdout); { int i; -printf("%s: read: %d\n", __FUNCTION__, n); +//printf("%s: read: %d\n", __FUNCTION__, n); fflush(stdout); for (i = 0; i < n; i++) @@ -573,7 +573,7 @@ gdb_poll (CPUState *env) return 0; } -printf("%s: revents: %08x\n", __FUNCTION__, pfd.revents); +//printf("%s: revents: %08x\n", __FUNCTION__, pfd.revents); fflush(stdout); if (pfd.revents & (POLLIN | POLLHUP)) diff --git a/main.c b/main.c index 2ea6338..1bd6a2f 100644 --- a/main.c +++ b/main.c @@ -25,6 +25,14 @@ #include "gdbstub.h" +static void *oom_check(void *ptr) +{ + if (ptr == NULL) { + abort(); + } + return ptr; +} + static x49gp_t *x49gp; #ifdef QEMU_OLD // LD TEMPO HACK @@ -383,7 +391,7 @@ printf("%s:%u: x49gp: %p\n", __FUNCTION__, __LINE__, x49gp); exit(1); } - error = x49gp_modules_load(x49gp, argv[1]); + error = x49gp_modules_load(x49gp, argv[argc-1]); if (error) { if (error != -EAGAIN) { exit(1); @@ -408,15 +416,17 @@ printf("%s:%u: x49gp: %p\n", __FUNCTION__, __LINE__, x49gp); x49gp_mod_timer(x49gp->lcd_timer, x49gp_get_clock()); -#if 0 - gdbserver_start(1234); - gdb_handlesig(x49gp->env, 0); -#endif + if(argc>=3) { + if((argv[1][0]=='-')&&(argv[1][1]=='d')&&(argv[1][2]==0)) { + gdbserver_start(1234); + gdb_handlesig(x49gp->env, 0); + } + } x49gp_main_loop(x49gp); - x49gp_modules_save(x49gp, argv[1]); + x49gp_modules_save(x49gp, argv[argc-1]); x49gp_modules_exit(x49gp); diff --git a/timer.c b/timer.c index 9a5258f..ff8a8a5 100644 --- a/timer.c +++ b/timer.c @@ -232,11 +232,9 @@ x49gp_main_loop_wait(x49gp_t *x49gp, int timeout) { // printf("%s: timeout: %d\n", __FUNCTION__, timeout); -#if 0 if (gdb_poll(x49gp->env)) { gdb_handlesig(x49gp->env, 0); } else -#endif poll(NULL, 0, timeout); if (x49gp->arm_idle != X49GP_ARM_OFF) { @@ -277,11 +275,9 @@ printf("PC %08x: SRAM %08x: %08x %08x %08x <%08x>\n", x49gp->env->regs[15], 0x08 * ((uint32_t *) &x49gp->sram[0x0a0c]) = 0x00000000; } -#if 0 if (ret == EXCP_DEBUG) { gdb_handlesig(x49gp->env, SIGTRAP); } -#endif if (x49gp->arm_idle != prev_idle) { if (x49gp->arm_idle == X49GP_ARM_OFF) {