diff options
| author | Mai M <mathew1800@gmail.com> | 2022-06-01 00:19:49 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-01 00:19:49 -0400 |
| commit | 13a8ca8266f18e5236b59c03b41a5e8907f61fa7 (patch) | |
| tree | 10f0e96a0689b2edb823f5833ff388ac9c645229 /src/core/debugger/debugger_interface.h | |
| parent | 2a412b39bae28b3b42e3b92a325fba1f52e20aed (diff) | |
| parent | 2ee161a0bf97c22112e228f0648c96751b829fce (diff) | |
Merge pull request #8394 from liamwhite/debugger
core/debugger: Implement new GDB stub debugger
Diffstat (limited to 'src/core/debugger/debugger_interface.h')
| -rw-r--r-- | src/core/debugger/debugger_interface.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/core/debugger/debugger_interface.h b/src/core/debugger/debugger_interface.h new file mode 100644 index 0000000000..0b357fcb5a --- /dev/null +++ b/src/core/debugger/debugger_interface.h @@ -0,0 +1,74 @@ +// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <functional> +#include <span> +#include <vector> + +#include "common/common_types.h" + +namespace Kernel { +class KThread; +} + +namespace Core { + +enum class DebuggerAction { + Interrupt, // Stop emulation as soon as possible. + Continue, // Resume emulation. + StepThread, // Step the currently-active thread. + ShutdownEmulation, // Shut down the emulator. +}; + +class DebuggerBackend { +public: + /** + * Can be invoked from a callback to synchronously wait for more data. + * Will return as soon as least one byte is received. Reads up to 4096 bytes. + */ + virtual std::span<const u8> ReadFromClient() = 0; + + /** + * Can be invoked from a callback to write data to the client. + * Returns immediately after the data is sent. + */ + virtual void WriteToClient(std::span<const u8> data) = 0; + + /** + * Gets the currently active thread when the debugger is stopped. + */ + virtual Kernel::KThread* GetActiveThread() = 0; + + /** + * Sets the currently active thread when the debugger is stopped. + */ + virtual void SetActiveThread(Kernel::KThread* thread) = 0; +}; + +class DebuggerFrontend { +public: + explicit DebuggerFrontend(DebuggerBackend& backend_) : backend{backend_} {} + + /** + * Called after the client has successfully connected to the port. + */ + virtual void Connected() = 0; + + /** + * Called when emulation has stopped. + */ + virtual void Stopped(Kernel::KThread* thread) = 0; + + /** + * Called when new data is asynchronously received on the client socket. + * A list of actions to perform is returned. + */ + [[nodiscard]] virtual std::vector<DebuggerAction> ClientData(std::span<const u8> data) = 0; + +protected: + DebuggerBackend& backend; +}; + +} // namespace Core |
