Skip to content

GDB server stub for remote debugging (using upstream debugging interfaces)#1244

Merged
stenzek merged 4 commits intostenzek:masterfrom
boricj:gdbserver
Dec 25, 2020
Merged

GDB server stub for remote debugging (using upstream debugging interfaces)#1244
stenzek merged 4 commits intostenzek:masterfrom
boricj:gdbserver

Conversation

@boricj
Copy link
Contributor

@boricj boricj commented Dec 17, 2020

Just like #1192, but rebased on top of upstream's debugging interfaces and without watchpoints.

@boricj boricj changed the title GDB server stub for remote debugging GDB server stub for remote debugging (using upstream debugging interfaces) Dec 17, 2020
@boricj boricj force-pushed the gdbserver branch 4 times, most recently from fa7d7d3 to 5abf528 Compare December 17, 2020 19:00
Copy link
Owner

@stenzek stenzek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for working through this.

I have some threading concerns, mainly with the commands - if they execute only after sending an interrupt first, replacing those PauseSystem calls will do the trick. But if breakpoints can be added during execution, you'll probably want to use executeOnEmulationThread if the system isn't paused.

I still think we're better off implementing this in the core rather than Qt, but that conversion can happen later, or I can do it myself :) But otherwise, looks good!

connect(&m_socket, &QTcpSocket::disconnected, this, &GDBConnection::gotDisconnected);

if (m_socket.setSocketDescriptor(m_descriptor)) {
g_host_interface->PauseSystem(true);
Copy link
Owner

@stenzek stenzek Dec 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be pauseSystem(true, true), since it will be executed on a different thread AFAICT (and we want to wait for the system to finish pausing).

}
}

if (g_settings.debugging.enable_gdb_server) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not the best place for this, but we can move it later if we move the server to the core.

return std::nullopt;
}

#if 0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is replaced by the above implementation, can just remove it rather than #if 0'ing it out.


if (GDBProtocol::IsPacketInterrupt(m_readBuffer)) {
Log_DebugPrintf("(%u) > Interrupt request", m_descriptor);
g_host_interface->PauseSystem(true);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - this should use pauseSystem. Specifically pauseSystem(true, true), that way it blocks the server thread until the emu thread actually pauses, and doesn't race when executing other commands such as adding breakpoints.

}
else if (GDBProtocol::IsPacketContinue(m_readBuffer)) {
Log_DebugPrintf("(%u) > Continue request", m_descriptor);
g_host_interface->PauseSystem(false);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pauseSystem(false, false) should be okay here I think, as the client won't send any other commands before another interrupt request?

@stenzek stenzek merged commit 2586475 into stenzek:master Dec 25, 2020
@boricj boricj deleted the gdbserver branch May 19, 2021 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants