Merge pull request #10336 from aldelaro5/gdb-stub-fix-first-packet

GDB Stub: do not send a packet when we just connected
This commit is contained in:
Léo Lam 2022-01-03 01:40:16 +01:00 committed by GitHub
commit 4ee20368f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -136,7 +136,8 @@ void Run()
state_lock.unlock();
if (GDBStub::IsActive() && GDBStub::HasControl())
{
GDBStub::SendSignal(GDBStub::Signal::Sigtrap);
if (!GDBStub::JustConnected())
GDBStub::SendSignal(GDBStub::Signal::Sigtrap);
GDBStub::ProcessCommands(true);
// If we are still going to step, emulate the fact we just sent a step command
if (GDBStub::HasControl())

View File

@ -63,6 +63,7 @@ constexpr u32 NUM_BREAKPOINT_TYPES = 4;
const s64 GDB_UPDATE_CYCLES = 100000;
static bool s_has_control = false;
static bool s_just_connected = false;
static int s_tmpsock = -1;
static int s_sock = -1;
@ -901,6 +902,7 @@ static void HandleRemoveBreakpoint()
void ProcessCommands(bool loop_until_continue)
{
s_just_connected = false;
while (IsActive())
{
if (CPU::GetState() == CPU::State::PowerDown)
@ -1041,6 +1043,7 @@ static void InitGeneric(int domain, const sockaddr* server_addr, socklen_t serve
if (s_sock < 0)
ERROR_LOG_FMT(GDB_STUB, "Failed to accept gdb client");
INFO_LOG_FMT(GDB_STUB, "Client connected.");
s_just_connected = true;
#ifdef _WIN32
closesocket(s_tmpsock);
@ -1086,6 +1089,11 @@ void TakeControl()
s_has_control = true;
}
bool JustConnected()
{
return s_just_connected;
}
void SendSignal(Signal signal)
{
char bfr[128] = {};

View File

@ -22,6 +22,7 @@ void Deinit();
bool IsActive();
bool HasControl();
void TakeControl();
bool JustConnected();
void ProcessCommands(bool loop_until_continue);
void SendSignal(Signal signal);