mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-26 13:26:30 -05:00
gdbstub: Ensure gdbstub doesn't drop packets crucial to initialization
This commit is contained in:
parent
e8ded20d24
commit
38036eb1c8
3 changed files with 16 additions and 2 deletions
|
@ -166,7 +166,7 @@ struct System::Impl {
|
|||
service_manager = std::make_shared<Service::SM::ServiceManager>();
|
||||
|
||||
Service::Init(service_manager, system);
|
||||
GDBStub::Init();
|
||||
GDBStub::DeferStart();
|
||||
|
||||
renderer = VideoCore::CreateRenderer(emu_window, system);
|
||||
if (!renderer->Init()) {
|
||||
|
|
|
@ -141,6 +141,7 @@ constexpr char target_xml[] =
|
|||
)";
|
||||
|
||||
int gdbserver_socket = -1;
|
||||
bool defer_start = false;
|
||||
|
||||
u8 command_buffer[GDB_BUFFER_SIZE];
|
||||
u32 command_length;
|
||||
|
@ -1165,7 +1166,8 @@ static void RemoveBreakpoint() {
|
|||
}
|
||||
|
||||
void HandlePacket() {
|
||||
if (!IsConnected()) {
|
||||
if (!IsConnected() && defer_start) {
|
||||
ToggleServer(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1256,6 +1258,10 @@ void ToggleServer(bool status) {
|
|||
}
|
||||
}
|
||||
|
||||
void DeferStart() {
|
||||
defer_start = true;
|
||||
}
|
||||
|
||||
static void Init(u16 port) {
|
||||
if (!server_enabled) {
|
||||
// Set the halt loop to false in case the user enabled the gdbstub mid-execution.
|
||||
|
@ -1341,6 +1347,7 @@ void Shutdown() {
|
|||
if (!server_enabled) {
|
||||
return;
|
||||
}
|
||||
defer_start = false;
|
||||
|
||||
LOG_INFO(Debug_GDBStub, "Stopping GDB ...");
|
||||
if (gdbserver_socket != -1) {
|
||||
|
|
|
@ -43,6 +43,13 @@ void ToggleServer(bool status);
|
|||
/// Start the gdbstub server.
|
||||
void Init();
|
||||
|
||||
/**
|
||||
* Defer initialization of the gdbstub to the first packet processing functions.
|
||||
* This avoids a case where the gdbstub thread is frozen after initialization
|
||||
* and fails to respond in time to packets.
|
||||
*/
|
||||
void DeferStart();
|
||||
|
||||
/// Stop gdbstub server.
|
||||
void Shutdown();
|
||||
|
||||
|
|
Loading…
Reference in a new issue