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/gdbstub.h | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/core/debugger/gdbstub.h (limited to 'src/core/debugger/gdbstub.h') diff --git a/src/core/debugger/gdbstub.h b/src/core/debugger/gdbstub.h new file mode 100644 index 000000000..b93a3a511 --- /dev/null +++ b/src/core/debugger/gdbstub.h @@ -0,0 +1,47 @@ +// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include +#include +#include + +#include "core/debugger/debugger_interface.h" +#include "core/debugger/gdbstub_arch.h" + +namespace Core { + +class System; + +class GDBStub : public DebuggerFrontend { +public: + explicit GDBStub(DebuggerBackend& backend, Core::System& system); + ~GDBStub(); + + void Connected() override; + void Stopped(Kernel::KThread* thread) override; + std::vector ClientData(std::span data) override; + +private: + void ProcessData(std::vector& actions); + void ExecuteCommand(std::string_view packet, std::vector& actions); + void HandleQuery(std::string_view command); + std::vector::const_iterator CommandEnd() const; + std::optional DetachCommand(); + Kernel::KThread* GetThreadByID(u64 thread_id); + + static u8 CalculateChecksum(std::string_view data); + void SendReply(std::string_view data); + void SendStatus(char status); + +private: + Core::System& system; + std::unique_ptr arch; + std::vector current_command; + std::map replaced_instructions; +}; + +} // namespace Core -- cgit v1.2.3