#pragma once #include #include #include #include #include #include #include #include #include namespace vls::debug::live { enum class State { idle, running, stopped, completed, failed, cancelled }; struct Stop { std::uint64_t generation{}; std::uint32_t sequence{}; }; struct Options { std::filesystem::path worker; // vls_gcc_probe std::filesystem::path compiler; std::string compiler_sha256; std::filesystem::path source; std::filesystem::path trace; bool stepping{true}; std::chrono::milliseconds deadline{60000}; std::size_t max_notice_bytes{64 * 1024}; }; // One live private-compiler session speaking the supervisor notice protocol. // Control actions are serialized; an inspection snapshot belongs to the stop // generation that requested it and is not reused after the session moves. class LiveSession { public: explicit LiveSession(Options); ~LiveSession(); LiveSession(const LiveSession &) = delete; LiveSession &operator=(const LiveSession &) = delete; LiveSession(LiveSession &&) = delete; LiveSession &operator=(LiveSession &&) = delete; // Spawns the worker and waits for the first stop. [[nodiscard]] std::expected start(); // At a stop: single-step. Returns the next stop or nullopt when finished. [[nodiscard]] std::expected, std::string> step(); [[nodiscard]] std::expected, std::string> continue_run(); // Requests cancellation and reaps the worker. [[nodiscard]] std::expected cancel(); // Read-only bounded snapshot at the current stop. [[nodiscard]] std::expected inspect(); [[nodiscard]] State state() const; [[nodiscard]] std::optional stop() const; [[nodiscard]] std::string outcome() const; [[nodiscard]] std::string reason() const; private: struct State_; std::unique_ptr state_; }; } // namespace vls::debug::live