From fb4b3c127f7c390358d7f4cadd2f58de116fec48 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 30 May 2022 19:35:01 -0400 Subject: core/debugger: Implement new GDB stub debugger --- src/core/debugger/debugger_interface.h | 74 ++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/core/debugger/debugger_interface.h (limited to 'src/core/debugger/debugger_interface.h') 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 @@ +// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include + +#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 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 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 ClientData(std::span data) = 0; + +protected: + DebuggerBackend& backend; +}; + +} // namespace Core -- cgit v1.2.3