-
Notifications
You must be signed in to change notification settings - Fork 597
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
Conversation
fa7d7d3
to
5abf528
Compare
There was a problem hiding this 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!
src/duckstation-qt/gdbconnection.cpp
Outdated
connect(&m_socket, &QTcpSocket::disconnected, this, &GDBConnection::gotDisconnected); | ||
|
||
if (m_socket.setSocketDescriptor(m_descriptor)) { | ||
g_host_interface->PauseSystem(true); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
src/common/string_util.h
Outdated
@@ -90,22 +113,26 @@ inline std::optional<bool> FromChars(const std::string_view& str) | |||
|
|||
return std::nullopt; | |||
} | |||
|
|||
#if 0 |
There was a problem hiding this comment.
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.
src/duckstation-qt/gdbconnection.cpp
Outdated
|
||
if (GDBProtocol::IsPacketInterrupt(m_readBuffer)) { | ||
Log_DebugPrintf("(%u) > Interrupt request", m_descriptor); | ||
g_host_interface->PauseSystem(true); |
There was a problem hiding this comment.
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.
src/duckstation-qt/gdbconnection.cpp
Outdated
} | ||
else if (GDBProtocol::IsPacketContinue(m_readBuffer)) { | ||
Log_DebugPrintf("(%u) > Continue request", m_descriptor); | ||
g_host_interface->PauseSystem(false); |
There was a problem hiding this comment.
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?
Just like #1192, but rebased on top of upstream's debugging interfaces and without watchpoints.