diff --git a/gdbstub/gdbstub b/gdbstub/gdbstub index 13012701..1266e617 160000 --- a/gdbstub/gdbstub +++ b/gdbstub/gdbstub @@ -1 +1 @@ -Subproject commit 13012701334821cf1038a81920eaafff1921268a +Subproject commit 1266e61757af01485f56b4e5bd3969fdaba9c356 diff --git a/gdbstub/gdbstub_sys.c b/gdbstub/gdbstub_sys.c index 86f18f63..bf154fcf 100644 --- a/gdbstub/gdbstub_sys.c +++ b/gdbstub/gdbstub_sys.c @@ -196,15 +196,22 @@ static int wait_hit_or_break(struct msg *msg) break; } } - else if (msg->type != MSG_TYPE_HIT) { - fprintf(stderr, "unexpected msg.type %d\n", msg->type); - return 1; + else { + switch (msg->type) { + case MSG_TYPE_BREAK: + return 1; + case MSG_TYPE_HIT: + return 0; + + default: + fprintf(stderr, "%s:%d:unexpected msg.type %d\n", + __func__, __LINE__, msg->type); + return EOF; + } } - else - return 0; } while (1); - return 1; + return EOF; } #endif diff --git a/gdbstub/gdbstub_sys.h b/gdbstub/gdbstub_sys.h index f44dfcc9..4d0fe3e9 100644 --- a/gdbstub/gdbstub_sys.h +++ b/gdbstub/gdbstub_sys.h @@ -66,7 +66,8 @@ struct msg { MSG_TYPE_SHUTDOWN, /* Response frames. */ - MSG_TYPE_HIT + MSG_TYPE_HIT, + MSG_TYPE_BREAK, } type; union { diff --git a/libpcsxcore/psxinterpreter.c b/libpcsxcore/psxinterpreter.c index ae100cb9..0ea4b1bf 100644 --- a/libpcsxcore/psxinterpreter.c +++ b/libpcsxcore/psxinterpreter.c @@ -655,8 +655,10 @@ void psxMTLO() { _rLo_ = _rRs_; } // Lo = Rs * Special purpose instructions * * Format: OP * *********************************************************/ +static void process_gdb(int); void psxBREAK() { // Break exception - psx rom doens't handles this + if (Config.GdbServer) process_gdb(1); } void psxSYSCALL() { @@ -1204,7 +1206,7 @@ static void intClear(u32 Addr, u32 Size) { static void intShutdown() { } -static void process_gdb(void) { +static void process_gdb(int found_break) { static int shutdown; static u32 tgt_addr; static int step, must_continue; @@ -1215,7 +1217,14 @@ start: if (shutdown) return; - if (halt || step || (must_continue && tgt_addr && tgt_addr == psxRegs.pc)) { + if (found_break) { + msg.type = MSG_TYPE_BREAK; + gdbstub_sys_send(&msg); + must_continue = 0; + step = 0; + halt = 0; + } + else if (halt || step || (must_continue && tgt_addr && tgt_addr == psxRegs.pc)) { msg.type = MSG_TYPE_HIT; #if DEBUG == 1 printf("hit address 0x%08X\n", psxRegs.pc); @@ -1276,7 +1285,7 @@ static inline void execI() { debugI(); - if (Config.GdbServer) process_gdb(); + if (Config.GdbServer) process_gdb(0); else if (Config.Debug) ProcessDebug(); psxRegs.pc += 4;