GDBServer: Preparation work to get this moved to the frontend

GDBServer is inherently OS specific which is why all this code is
removed when compiling for mingw/win32. This should get moved to the
frontend before we start landing more work to clean this interface up.

Not really any functional change.

Changes:

FEXCore/Context: Adds new public interfaces, these were previously
private.
- WaitForIdle
   - If `Pause` was called or the process is shutting down then this
     will wait until all threads have paused or exited.
- WaitForThreadsToRun
   - If `Pause` was previously called and then `Run` was called to get
     them running again, this waits until all the threads have come out
     of idle to avoid races.
- GetThreads
   - Returns the `InternalThreadData` for all the current threads.
   - GDBServer needs to know all the internal thread data state when the
     threads are paused which is what this gives it.

GDBServer:
- Removes usages of internal data structures where possible.
   - This gets it clean enough that moving it out of FEXCore is now
     possible.
This commit is contained in:
Ryan Houdek committed 2023-11-02 20:11:01 -07:00
1 parent 03f63f99a8
commit e2c65189ff
5 files changed
+72 -36

No files matched your search

+25
View File
@@ -87,6 +87,11 @@ namespace FEXCore::Context {
void *VDSO_kernel_rt_sigreturn;
};
struct ThreadsState {
FEXCore::Core::InternalThreadState* ParentThread;
fextl::vector<FEXCore::Core::InternalThreadState*>* Threads;
};
using CodeRangeInvalidationFn = std::function<void(uint64_t start, uint64_t Length)>;
using CustomCPUFactoryType = std::function<fextl::unique_ptr<CPU::CPUBackend>(Context*, Core::InternalThreadState *Thread)>;
@@ -141,6 +146,18 @@ namespace FEXCore::Context {
*/
FEX_DEFAULT_VISIBILITY virtual void Pause() = 0;
/**
* @brief Waits for all threads to be idle.
*
* Idling can happen when the process is shutting down or the debugger has asked for all threads to pause.
*/
FEX_DEFAULT_VISIBILITY virtual void WaitForIdle() = 0;
/**
* @brief When resuming from a paused state, waits for all threads to start executing before returning.
*/
FEX_DEFAULT_VISIBILITY virtual void WaitForThreadsToRun() = 0;
/**
* @brief Starts (or continues) the CPU core
*
@@ -318,6 +335,14 @@ namespace FEXCore::Context {
*
*/
FEX_DEFAULT_VISIBILITY virtual void EnableExitOnHLT() = 0;
/**
* @brief Gets the thread data for FEX's internal tracked threads.
*
* @return struct containing all the thread information.
*/
FEX_DEFAULT_VISIBILITY virtual ThreadsState GetThreads() = 0;
private:
};