From e74a311931826eb2cf0d4dd8540a156fe85e1055 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 8 Nov 2019 01:11:59 +0300 Subject: [PATCH] GDB: remove wrong_checksum_exception --- rpcs3/Emu/GDB.cpp | 29 +++++++++-------------------- rpcs3/Emu/GDB.h | 6 ++++-- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/rpcs3/Emu/GDB.cpp b/rpcs3/Emu/GDB.cpp index a3a4dde20c..43bee185fd 100644 --- a/rpcs3/Emu/GDB.cpp +++ b/rpcs3/Emu/GDB.cpp @@ -70,15 +70,6 @@ struct gdb_cmd u8 checksum; }; -class wrong_checksum_exception : public std::runtime_error -{ -public: - wrong_checksum_exception(char const* const message) - : runtime_error(message) - { - } -}; - bool check_errno_again() { #ifdef _WIN32 @@ -251,7 +242,7 @@ u8 gdb_thread::read_hexbyte() return hex_to_u8(s); } -void gdb_thread::try_read_cmd(gdb_cmd& out_cmd) +bool gdb_thread::try_read_cmd(gdb_cmd& out_cmd) { char c = read_char(); //interrupt @@ -259,7 +250,7 @@ void gdb_thread::try_read_cmd(gdb_cmd& out_cmd) out_cmd.cmd = '\x03'; out_cmd.data = ""; out_cmd.checksum = 0; - return; + return true; } if (UNLIKELY(c != '$')) { //gdb starts conversation with + for some reason @@ -302,9 +293,7 @@ void gdb_thread::try_read_cmd(gdb_cmd& out_cmd) } } out_cmd.checksum = read_hexbyte(); - if (out_cmd.checksum != checksum) { - throw wrong_checksum_exception("Wrong checksum for packet" HERE); - } + return out_cmd.checksum == checksum; } bool gdb_thread::read_cmd(gdb_cmd& out_cmd) @@ -313,12 +302,12 @@ bool gdb_thread::read_cmd(gdb_cmd& out_cmd) { try { - try_read_cmd(out_cmd); - ack(true); - return true; - } - catch (const wrong_checksum_exception&) - { + if (try_read_cmd(out_cmd)) + { + ack(true); + return true; + } + ack(false); } catch (const std::runtime_error& e) diff --git a/rpcs3/Emu/GDB.h b/rpcs3/Emu/GDB.h index 8ec891f287..6e90119e6e 100644 --- a/rpcs3/Emu/GDB.h +++ b/rpcs3/Emu/GDB.h @@ -28,8 +28,10 @@ class gdb_thread char read_char(); //reads pairs of hex characters and returns their integer value u8 read_hexbyte(); - //tries to read command, throws exceptions if anything goes wrong - void try_read_cmd(gdb_cmd& out_cmd); + + // Tries to read command, returns false on error + bool try_read_cmd(gdb_cmd& out_cmd); + //reads commands until receiveing one with valid checksum //in case of other exception (i.e. wrong first char of command) //it will log exception text and return false