mirror of
https://github.com/Vita3K/Vita3K.git
synced 2026-07-11 01:34:23 +02:00
gdbstub: Fix GDB command matching and don't reply with "Unrecognized Command" (#3497)
Also: * Mark thread as suspended so we can resume later
This commit is contained in:
@@ -696,7 +696,8 @@ constexpr bool cmp_less(T t, U u) noexcept {
|
||||
}
|
||||
|
||||
static bool command_begins_with(PacketCommand &command, const std::string_view small_str) {
|
||||
if (!cmp_less(small_str.size(), command.content_length))
|
||||
// If the command's content is shorter than small_str, it can't match
|
||||
if (static_cast<size_t>(command.content_length) < small_str.size())
|
||||
return false;
|
||||
|
||||
return std::memcmp(command.content_start, small_str.data(), small_str.size()) == 0;
|
||||
@@ -737,8 +738,10 @@ static int64_t server_next(EmuEnvState &state) {
|
||||
|
||||
PacketCommand command = parse_command(buffer + a, length - a);
|
||||
if (command.is_valid) {
|
||||
bool found_command = false;
|
||||
for (const auto &function : functions) {
|
||||
if (command_begins_with(command, function.name)) {
|
||||
found_command = true;
|
||||
LOG_GDB("GDB Server Recognized Command as {}. {}", function.name,
|
||||
std::string(command.content_start, command.content_length));
|
||||
state.gdb.last_reply = function.function(state, command);
|
||||
@@ -748,8 +751,11 @@ static int64_t server_next(EmuEnvState &state) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
LOG_GDB("GDB Server Unrecognized Command. {}", std::string(command.content_start, command.content_length));
|
||||
|
||||
if (!found_command) {
|
||||
LOG_GDB("GDB Server Unrecognized Command. {}", std::string(command.content_start, command.content_length));
|
||||
state.gdb.last_reply = "";
|
||||
server_reply(state.gdb, state.gdb.last_reply.c_str());
|
||||
}
|
||||
a += command.content_length + 3;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -299,6 +299,8 @@ bool ThreadState::run_loop() {
|
||||
something_to_do.wait(lock);
|
||||
break;
|
||||
case ThreadToDo::suspend:
|
||||
update_status(ThreadStatus::suspend);
|
||||
something_to_do.wait(lock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user