gdbstub.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <map>
  5. #include <memory>
  6. #include <optional>
  7. #include <string_view>
  8. #include <vector>
  9. #include "core/debugger/debugger_interface.h"
  10. #include "core/debugger/gdbstub_arch.h"
  11. namespace Core {
  12. class System;
  13. class GDBStub : public DebuggerFrontend {
  14. public:
  15. explicit GDBStub(DebuggerBackend& backend, Core::System& system);
  16. ~GDBStub() override;
  17. void Connected() override;
  18. void Stopped(Kernel::KThread* thread) override;
  19. void ShuttingDown() override;
  20. std::vector<DebuggerAction> ClientData(std::span<const u8> data) override;
  21. private:
  22. void ProcessData(std::vector<DebuggerAction>& actions);
  23. void ExecuteCommand(std::string_view packet, std::vector<DebuggerAction>& actions);
  24. void HandleVCont(std::string_view command, std::vector<DebuggerAction>& actions);
  25. void HandleQuery(std::string_view command);
  26. std::vector<char>::const_iterator CommandEnd() const;
  27. std::optional<std::string> DetachCommand();
  28. Kernel::KThread* GetThreadByID(u64 thread_id);
  29. void SendReply(std::string_view data);
  30. void SendStatus(char status);
  31. private:
  32. Core::System& system;
  33. std::unique_ptr<GDBStubArch> arch;
  34. std::vector<char> current_command;
  35. std::map<VAddr, u32> replaced_instructions;
  36. bool no_ack{};
  37. };
  38. } // namespace Core