1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

GDB: remove wrong_checksum_exception

This commit is contained in:
Nekotekina 2019-11-08 01:11:59 +03:00
parent 587ae17aa2
commit e74a311931
2 changed files with 13 additions and 22 deletions

View File

@ -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)

View File

@ -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