#pragma once #include #include #include #include #include #include #include #include namespace vls::gcc { class ReplayRecording; } namespace vls::debug { namespace Protocol = Void::LanguageServer::Protocol; using Json = Protocol::Json; // DAP and the versioned inspection requests share the same cursor and generation. class ReplaySession { public: static std::expected open(const std::filesystem::path &path); ReplaySession(const ReplaySession &) = delete; ReplaySession &operator=(const ReplaySession &) = delete; ReplaySession(ReplaySession &&) noexcept = default; ReplaySession &operator=(ReplaySession &&) = delete; [[nodiscard]] Json::Object identity() const; [[nodiscard]] Json::Object describe() const; [[nodiscard]] bool matches(const Json::Object &arguments) const; [[nodiscard]] std::expected timeline(std::size_t start, std::size_t count) const; [[nodiscard]] std::expected frames(std::size_t start, std::size_t count) const; // A false result represents the boundary in the requested direction. It preserves the cursor. [[nodiscard]] std::expected initial_position(); [[nodiscard]] std::expected move_to_value(bool forward); [[nodiscard]] std::expected seek(std::uint32_t sequence); void finish(); [[nodiscard]] bool paused() const { return sequence_.has_value(); } [[nodiscard]] std::string_view pause_kind() const { return pause_kind_; } [[nodiscard]] bool source_available() const { return source_available_; } [[nodiscard]] std::string_view source_bytes() const; [[nodiscard]] std::size_t frame_count() const; [[nodiscard]] const Json &frame(std::size_t top_first_index) const; [[nodiscard]] std::int64_t frame_handle(std::size_t index) const; [[nodiscard]] std::int64_t scope_handle(std::size_t index) const; [[nodiscard]] std::optional handle_index(std::int64_t handle, bool scope) const; private: ReplaySession(std::shared_ptr recording, std::string id); std::shared_ptr recording_; std::string id_; bool source_available_; bool finished_{}; std::int64_t generation_{}; std::int64_t next_handle_{1}; std::int64_t frame_base_{1}; std::optional sequence_; std::string_view pause_kind_{"none"}; Json cursor_{nullptr}; }; } // namespace vls::debug