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

GDBServer fixes #3592

Closed
wants to merge 10 commits into from
2 changes: 1 addition & 1 deletion Source/Tools/FEXLoader/FEXLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ int main(int argc, char** argv, char** const envp) {
FEX::AOT::AOTGenSection(CTX.get(), Section);
}
} else {
CTX->RunUntilExit(ParentThread);
SyscallHandler->TM.RunPrimaryThread(CTX.get(), ParentThread);
}

if (AOTEnabled) {
Expand Down
2 changes: 2 additions & 0 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class ThreadManager final {
void StopThread(FEXCore::Core::InternalThreadState* Thread);
void RunThread(FEXCore::Core::InternalThreadState* Thread);

void RunPrimaryThread(FEXCore::Context::Context* CTX, FEXCore::Core::InternalThreadState* Thread);
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference between this and "RunThread"?


void Pause();
void Run();
void Step();
Expand Down
14 changes: 10 additions & 4 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
namespace FEX::HLE {
FEXCore::Core::InternalThreadState*
ThreadManager::CreateThread(uint64_t InitialRIP, uint64_t StackPointer, FEXCore::Core::CPUState* NewThreadState, uint64_t ParentTID) {
auto Thread = CTX->CreateThread(InitialRIP, StackPointer, NewThreadState, ParentTID);

++IdleWaitRefCount;
return Thread;
return CTX->CreateThread(InitialRIP, StackPointer, NewThreadState, ParentTID);
}

void ThreadManager::DestroyThread(FEXCore::Core::InternalThreadState* Thread) {
Expand All @@ -34,6 +31,15 @@ void ThreadManager::StopThread(FEXCore::Core::InternalThreadState* Thread) {
void ThreadManager::RunThread(FEXCore::Core::InternalThreadState* Thread) {
// Tell the thread to start executing
Thread->StartRunning.NotifyAll();
++IdleWaitRefCount;
}

void ThreadManager::RunPrimaryThread(FEXCore::Context::Context* CTX, FEXCore::Core::InternalThreadState* Thread) {
Thread->ThreadManager.TID = FHU::Syscalls::gettid();
Thread->ThreadManager.PID = ::getpid();

++IdleWaitRefCount;
CTX->RunUntilExit(Thread);
}

void ThreadManager::HandleThreadDeletion(FEXCore::Core::InternalThreadState* Thread) {
Expand Down