Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Dec 25, 2020

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

@@ -814,6 +815,16 @@ void MainWindow::updateEmulationActions(bool starting, bool running)
}
}

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.

@@ -90,22 +113,26 @@ inline std::optional<bool> FromChars(const std::string_view& str)

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
2 participants