#pragma once #include #include #include #include #include #include #include #include #include #include #include #include "vm.hpp" class GDBStub { public: GDBStub(int port); ~GDBStub(); void run(); void stop(); private: int server_fd; int client_fd; std::atomic running; // Buffer size for GDB packet handling static constexpr size_t BUFFER_SIZE = 4096; void send_packet(const std::string &packet); void send_ack(); void wait_ack(); std::string receive_packet(); void handle_packet(const std::string &packet); bool parse_memory_request(const std::string &packet, size_t &addr, size_t &length); std::string read_registers(); std::string read_memory(size_t addr, size_t length); };