Skip to content

Commit

Permalink
GdbServer: Save off some signal information when it occurs
Browse files Browse the repository at this point in the history
Enough for some state reconstruction that is missing
  • Loading branch information
Sonicadvance1 committed Dec 10, 2024
1 parent 146a5e3 commit 84aa49b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/GdbServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ GdbServer::GdbServer(FEXCore::Context::Context* ctx, FEX::HLE::SignalDelegator*
return false;
}

auto ThreadObject = FEX::HLE::ThreadManager::GetStateObjectFromFEXCoreThread(Thread);
ThreadObject->GdbInfo.Signal = Signal;

ThreadObject->GdbInfo.SignalPC = ArchHelpers::Context::GetPc(ucontext);
uint32_t IgnoreMask = Thread->CurrentFrame->InSyscallInfo & 0xFFFF;
this->SignalDelegation->SpillSRA(Thread, ucontext, IgnoreMask);

memcpy(ThreadObject->GdbInfo.GPRs, ArchHelpers::Context::GetArmGPRs(ucontext), sizeof(uint64_t) * 32);
ThreadObject->GdbInfo.PState = ArchHelpers::Context::GetArmPState(ucontext);

// Let GDB know that we have a signal
this->Break(Thread, Signal);

Expand Down
8 changes: 8 additions & 0 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ struct ThreadStateObject : public FEXCore::Allocator::FEXAllocOperators {
std::atomic_bool ThreadSleeping {false};
FEXCore::InterruptableConditionVariable ThreadPaused;

// GDB signal information
struct GdbInfoStruct {
int Signal {};
uint64_t SignalPC {};
uint64_t GPRs[32];
uint64_t PState {};
} GdbInfo;

int StatusCode {};
};

Expand Down

0 comments on commit 84aa49b

Please sign in to comment.