diff options
| author | 2022-05-30 19:35:01 -0400 | |
|---|---|---|
| committer | 2022-06-01 00:01:25 -0400 | |
| commit | fb4b3c127f7c390358d7f4cadd2f58de116fec48 (patch) | |
| tree | e2588a859d364a32be0cd9e0401a345c6492d1a7 /src/core/debugger/debugger_interface.h | |
| parent | Merge pull request #8368 from german77/seventimes (diff) | |
| download | yuzu-fb4b3c127f7c390358d7f4cadd2f58de116fec48.tar.gz yuzu-fb4b3c127f7c390358d7f4cadd2f58de116fec48.tar.xz yuzu-fb4b3c127f7c390358d7f4cadd2f58de116fec48.zip | |
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 000000000..0b357fcb5 --- /dev/null +++ b/src/core/debugger/debugger_interface.h | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <functional> | ||
| 7 | #include <span> | ||
| 8 | #include <vector> | ||
| 9 | |||
| 10 | #include "common/common_types.h" | ||
| 11 | |||
| 12 | namespace Kernel { | ||
| 13 | class KThread; | ||
| 14 | } | ||
| 15 | |||
| 16 | namespace Core { | ||
| 17 | |||
| 18 | enum class DebuggerAction { | ||
| 19 | Interrupt, // Stop emulation as soon as possible. | ||
| 20 | Continue, // Resume emulation. | ||
| 21 | StepThread, // Step the currently-active thread. | ||
| 22 | ShutdownEmulation, // Shut down the emulator. | ||
| 23 | }; | ||
| 24 | |||
| 25 | class DebuggerBackend { | ||
| 26 | public: | ||
| 27 | /** | ||
| 28 | * Can be invoked from a callback to synchronously wait for more data. | ||
| 29 | * Will return as soon as least one byte is received. Reads up to 4096 bytes. | ||
| 30 | */ | ||
| 31 | virtual std::span<const u8> ReadFromClient() = 0; | ||
| 32 | |||
| 33 | /** | ||
| 34 | * Can be invoked from a callback to write data to the client. | ||
| 35 | * Returns immediately after the data is sent. | ||
| 36 | */ | ||
| 37 | virtual void WriteToClient(std::span<const u8> data) = 0; | ||
| 38 | |||
| 39 | /** | ||
| 40 | * Gets the currently active thread when the debugger is stopped. | ||
| 41 | */ | ||
| 42 | virtual Kernel::KThread* GetActiveThread() = 0; | ||
| 43 | |||
| 44 | /** | ||
| 45 | * Sets the currently active thread when the debugger is stopped. | ||
| 46 | */ | ||
| 47 | virtual void SetActiveThread(Kernel::KThread* thread) = 0; | ||
| 48 | }; | ||
| 49 | |||
| 50 | class DebuggerFrontend { | ||
| 51 | public: | ||
| 52 | explicit DebuggerFrontend(DebuggerBackend& backend_) : backend{backend_} {} | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Called after the client has successfully connected to the port. | ||
| 56 | */ | ||
| 57 | virtual void Connected() = 0; | ||
| 58 | |||
| 59 | /** | ||
| 60 | * Called when emulation has stopped. | ||
| 61 | */ | ||
| 62 | virtual void Stopped(Kernel::KThread* thread) = 0; | ||
| 63 | |||
| 64 | /** | ||
| 65 | * Called when new data is asynchronously received on the client socket. | ||
| 66 | * A list of actions to perform is returned. | ||
| 67 | */ | ||
| 68 | [[nodiscard]] virtual std::vector<DebuggerAction> ClientData(std::span<const u8> data) = 0; | ||
| 69 | |||
| 70 | protected: | ||
| 71 | DebuggerBackend& backend; | ||
| 72 | }; | ||
| 73 | |||
| 74 | } // namespace Core | ||