summaryrefslogtreecommitdiffstats
path: root/src/core/debugger/gdbstub.h
diff options
context:
space:
mode:
authorMai M <mathew1800@gmail.com>2022-06-01 06:19:49 +0200
committerGitHub <noreply@github.com>2022-06-01 06:19:49 +0200
commitde2f2e5140eb85311e0fd844c580d6726adf7e03 (patch)
tree10f0e96a0689b2edb823f5833ff388ac9c645229 /src/core/debugger/gdbstub.h
parentMerge pull request #8401 from zhaobot/tx-update-20220601034505 (diff)
parentcore/debugger: Implement new GDB stub debugger (diff)
downloadyuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar
yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.gz
yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.bz2
yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.lz
yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.xz
yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.zst
yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.zip
Diffstat (limited to 'src/core/debugger/gdbstub.h')
-rw-r--r--src/core/debugger/gdbstub.h47
1 files changed, 47 insertions, 0 deletions
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 <map>
+#include <memory>
+#include <optional>
+#include <string_view>
+#include <vector>
+
+#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<DebuggerAction> ClientData(std::span<const u8> data) override;
+
+private:
+ void ProcessData(std::vector<DebuggerAction>& actions);
+ void ExecuteCommand(std::string_view packet, std::vector<DebuggerAction>& actions);
+ void HandleQuery(std::string_view command);
+ std::vector<char>::const_iterator CommandEnd() const;
+ std::optional<std::string> 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<GDBStubArch> arch;
+ std::vector<char> current_command;
+ std::map<VAddr, u32> replaced_instructions;
+};
+
+} // namespace Core