CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
104 lines
3.1 KiB
C++
104 lines
3.1 KiB
C++
//===-- FifoFiles.h ---------------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLDB_TOOLS_LLDB_DAP_FIFOFILES_H
|
|
#define LLDB_TOOLS_LLDB_DAP_FIFOFILES_H
|
|
|
|
#include "lldb/Host/Pipe.h"
|
|
#include "llvm/Support/Error.h"
|
|
#include "llvm/Support/JSON.h"
|
|
|
|
#include <chrono>
|
|
|
|
namespace lldb_dap {
|
|
|
|
/// Struct that controls the life of a fifo file in the filesystem.
|
|
///
|
|
/// The file is destroyed when the destructor is invoked.
|
|
struct FifoFile {
|
|
FifoFile(llvm::StringRef path, lldb::pipe_t pipe = LLDB_INVALID_PIPE);
|
|
|
|
~FifoFile();
|
|
|
|
void Connect();
|
|
|
|
void WriteLine(llvm::StringRef line);
|
|
|
|
std::string ReadLine();
|
|
|
|
llvm::StringRef GetPath() { return m_path; }
|
|
|
|
/// FifoFile is not copyable.
|
|
/// @{
|
|
FifoFile(const FifoFile &rhs) = delete;
|
|
void operator=(const FifoFile &rhs) = delete;
|
|
/// @}
|
|
|
|
protected:
|
|
std::string m_path;
|
|
lldb::pipe_t m_pipe;
|
|
};
|
|
|
|
/// Create a fifo file in the filesystem.
|
|
///
|
|
/// \param[in] path
|
|
/// The path for the fifo file.
|
|
///
|
|
/// \return
|
|
/// A \a std::shared_ptr<FifoFile> if the file could be created, or an
|
|
/// \a llvm::Error in case of failures.
|
|
llvm::Expected<std::shared_ptr<FifoFile>> CreateFifoFile(llvm::StringRef path);
|
|
|
|
class FifoFileIO {
|
|
public:
|
|
/// \param[in] fifo_file
|
|
/// The path to an input fifo file that exists in the file system.
|
|
///
|
|
/// \param[in] other_endpoint_name
|
|
/// A human readable name for the other endpoint that will communicate
|
|
/// using this file. This is used for error messages.
|
|
FifoFileIO(std::shared_ptr<FifoFile> fifo_file,
|
|
llvm::StringRef other_endpoint_name);
|
|
|
|
/// Read the next JSON object from the underlying input fifo file.
|
|
///
|
|
/// The JSON object is expected to be a single line delimited with \a
|
|
/// std::endl.
|
|
///
|
|
/// \return
|
|
/// An \a llvm::Error object indicating the success or failure of this
|
|
/// operation. Failures arise if the timeout is hit, the next line of text
|
|
/// from the fifo file is not a valid JSON object, or is it impossible to
|
|
/// read from the file.
|
|
llvm::Expected<llvm::json::Value> ReadJSON(std::chrono::milliseconds timeout);
|
|
|
|
/// Serialize a JSON object and write it to the underlying output fifo file.
|
|
///
|
|
/// \param[in] json
|
|
/// The JSON object to send. It will be printed as a single line delimited
|
|
/// with \a std::endl.
|
|
///
|
|
/// \param[in] timeout
|
|
/// A timeout for how long we should until for the data to be consumed.
|
|
///
|
|
/// \return
|
|
/// An \a llvm::Error object indicating whether the data was consumed by
|
|
/// a reader or not.
|
|
llvm::Error SendJSON(
|
|
const llvm::json::Value &json,
|
|
std::chrono::milliseconds timeout = std::chrono::milliseconds(20000));
|
|
|
|
private:
|
|
std::shared_ptr<FifoFile> m_fifo_file;
|
|
std::string m_other_endpoint_name;
|
|
};
|
|
|
|
} // namespace lldb_dap
|
|
|
|
#endif // LLDB_TOOLS_LLDB_DAP_FIFOFILES_H
|