mirror of
https://github.com/FEX-Emu/FEX.git
synced 2025-02-12 10:29:24 +00:00
GdbServer: Fixes crash on gdb detach
GdbServer object was getting deleted before the socket thread was shutdown which was causing a crash on detach. Now on destructor it will wait for the thread to thread to exit.
This commit is contained in:
parent
7524029a06
commit
499a40ecb5
@ -127,8 +127,12 @@ void GdbServer::WaitForThreadWakeup() {
|
||||
}
|
||||
|
||||
GdbServer::~GdbServer() {
|
||||
CloseListenSocket();
|
||||
CoreShuttingDown = true;
|
||||
close(ListenSocket);
|
||||
|
||||
if (gdbServerThread->joinable()) {
|
||||
gdbServerThread->join(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
GdbServer::GdbServer(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *SignalDelegation, FEXCore::HLE::SyscallHandler *const SyscallHandler)
|
||||
@ -1432,8 +1436,7 @@ void GdbServer::GdbServerLoop() {
|
||||
}
|
||||
}
|
||||
|
||||
close(ListenSocket);
|
||||
unlink(GdbUnixSocketPath.c_str());
|
||||
CloseListenSocket();
|
||||
}
|
||||
static void* ThreadHandler(void *Arg) {
|
||||
FEXCore::Threads::SetThreadName("FEX:gdbserver");
|
||||
@ -1493,6 +1496,14 @@ void GdbServer::OpenListenSocket() {
|
||||
LogMan::Msg::IFmt("[GdbServer] gdb-multiarch -ex \"target extended-remote {}\"", GdbUnixSocketPath);
|
||||
}
|
||||
|
||||
void GdbServer::CloseListenSocket() {
|
||||
if (ListenSocket != -1) {
|
||||
close(ListenSocket);
|
||||
ListenSocket = -1;
|
||||
}
|
||||
unlink(GdbUnixSocketPath.c_str());
|
||||
}
|
||||
|
||||
fextl::unique_ptr<std::iostream> GdbServer::OpenSocket() {
|
||||
// Block until a connection arrives
|
||||
struct sockaddr_storage their_addr{};
|
||||
|
@ -39,6 +39,7 @@ private:
|
||||
void Break(int signal);
|
||||
|
||||
void OpenListenSocket();
|
||||
void CloseListenSocket();
|
||||
enum class WaitForConnectionResult {
|
||||
CONNECTION,
|
||||
ERROR,
|
||||
|
Loading…
x
Reference in New Issue
Block a user