================ @@ -0,0 +1,152 @@ +//===-- Transport.cpp -----------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "Transport.h" +#include "Protocol.h" +#include "lldb/Utility/IOObject.h" +#include "lldb/Utility/Status.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/raw_ostream.h" +#include <utility> + +using namespace llvm; +using namespace lldb; +using namespace lldb_private; +using namespace lldb_dap; +using namespace lldb_dap::protocol; + +static Status ReadFull(IOObjectSP &descriptor, size_t length, + std::string &text) { + if (!descriptor || !descriptor->IsValid()) + return Status("transport input is closed"); + + std::string data; + data.resize(length); + + auto status = descriptor->Read(data.data(), length); + if (status.Fail()) + return status; + + // If we got back zero then we have reached EOF. + if (length == 0) + return Status(Transport::kEOF, lldb::eErrorTypeGeneric, "end-of-file"); + + text += data.substr(0, length); + return Status(); +} + +static Status ReadUpTo(IOObjectSP &descriptor, std::string &line, ---------------- vogelsgesang wrote:
I am not a native speaker. but "read until" seems to describe the behavior better. "read until you find the string `\n`". With `ReadUpTo`, I would rather think of "read up to 100 bytes" ```suggestion static Status ReadUntil(IOObjectSP &descriptor, std::string &line, ``` https://github.com/llvm/llvm-project/pull/130026 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits