summaryrefslogtreecommitdiff
path: root/src/core/debugger/debugger_interface.h
diff options
context:
space:
mode:
authorGravatar Mai M2022-06-01 00:19:49 -0400
committerGravatar GitHub2022-06-01 00:19:49 -0400
commitde2f2e5140eb85311e0fd844c580d6726adf7e03 (patch)
tree10f0e96a0689b2edb823f5833ff388ac9c645229 /src/core/debugger/debugger_interface.h
parentMerge pull request #8401 from zhaobot/tx-update-20220601034505 (diff)
parentcore/debugger: Implement new GDB stub debugger (diff)
downloadyuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.gz
yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.xz
yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.zip
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.h74
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
12namespace Kernel {
13class KThread;
14}
15
16namespace Core {
17
18enum 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
25class DebuggerBackend {
26public:
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
50class DebuggerFrontend {
51public:
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
70protected:
71 DebuggerBackend& backend;
72};
73
74} // namespace Core