diff options
author | Eric Christopher <echristo@gmail.com> | 2019-12-10 15:04:02 -0800 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2019-12-10 15:04:45 -0800 |
commit | 1d41d1bcdfd70cf8f77bb32e2617392395c299a4 (patch) | |
tree | de9be5c61d0c9efde2ae04ebc507c7f3b770da8c /lldb/source/Utility | |
parent | f4a7d5659df7cb56c1baa34a39e9fe2639472741 (diff) | |
download | bcm5719-llvm-1d41d1bcdfd70cf8f77bb32e2617392395c299a4.tar.gz bcm5719-llvm-1d41d1bcdfd70cf8f77bb32e2617392395c299a4.zip |
Revert "Temporarily revert [lldb] e81268d - [lldb/Reproducers] Support multiple GDB remotes"
On multiple retry this issue won't duplicate - will revisit with author if
duplication works again.
This reverts commit c9e0b354e2749ce7ab553974692cb35c8651a869.
Diffstat (limited to 'lldb/source/Utility')
-rw-r--r-- | lldb/source/Utility/GDBRemote.cpp | 70 | ||||
-rw-r--r-- | lldb/source/Utility/Reproducer.cpp | 48 |
2 files changed, 65 insertions, 53 deletions
diff --git a/lldb/source/Utility/GDBRemote.cpp b/lldb/source/Utility/GDBRemote.cpp index 85c4bc69a8d..54f3a3cd8a8 100644 --- a/lldb/source/Utility/GDBRemote.cpp +++ b/lldb/source/Utility/GDBRemote.cpp @@ -14,6 +14,7 @@ #include <stdio.h> using namespace lldb; +using namespace lldb_private::repro; using namespace lldb_private; using namespace llvm; @@ -45,12 +46,6 @@ int StreamGDBRemote::PutEscapedBytes(const void *s, size_t src_len) { return bytes_written; } -void GDBRemotePacket::Serialize(raw_ostream &strm) const { - yaml::Output yout(strm); - yout << const_cast<GDBRemotePacket &>(*this); - strm.flush(); -} - llvm::StringRef GDBRemotePacket::GetTypeStr() const { switch (type) { case GDBRemotePacket::ePacketTypeSend: @@ -103,3 +98,66 @@ yaml::MappingTraits<GDBRemotePacket>::validate(IO &io, return {}; } + +void GDBRemoteProvider::Keep() { + std::vector<std::string> files; + for (auto &recorder : m_packet_recorders) { + files.push_back(recorder->GetFilename().GetPath()); + } + + FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file); + std::error_code ec; + llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text); + if (ec) + return; + yaml::Output yout(os); + yout << files; +} + +void GDBRemoteProvider::Discard() { m_packet_recorders.clear(); } + +llvm::Expected<std::unique_ptr<PacketRecorder>> +PacketRecorder::Create(const FileSpec &filename) { + std::error_code ec; + auto recorder = std::make_unique<PacketRecorder>(std::move(filename), ec); + if (ec) + return llvm::errorCodeToError(ec); + return std::move(recorder); +} + +PacketRecorder *GDBRemoteProvider::GetNewPacketRecorder() { + std::size_t i = m_packet_recorders.size() + 1; + std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") + + llvm::Twine(i) + llvm::Twine(".yaml")) + .str(); + auto recorder_or_error = + PacketRecorder::Create(GetRoot().CopyByAppendingPathComponent(filename)); + if (!recorder_or_error) { + llvm::consumeError(recorder_or_error.takeError()); + return nullptr; + } + + m_packet_recorders.push_back(std::move(*recorder_or_error)); + return m_packet_recorders.back().get(); +} + +void PacketRecorder::Record(const GDBRemotePacket &packet) { + if (!m_record) + return; + yaml::Output yout(m_os); + yout << const_cast<GDBRemotePacket &>(packet); + m_os.flush(); +} + +llvm::raw_ostream *GDBRemoteProvider::GetHistoryStream() { + FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file); + + std::error_code EC; + m_stream_up = std::make_unique<raw_fd_ostream>(history_file.GetPath(), EC, + sys::fs::OpenFlags::OF_Text); + return m_stream_up.get(); +} + +char GDBRemoteProvider::ID = 0; +const char *GDBRemoteProvider::Info::file = "gdb-remote.yaml"; +const char *GDBRemoteProvider::Info::name = "gdb-remote"; diff --git a/lldb/source/Utility/Reproducer.cpp b/lldb/source/Utility/Reproducer.cpp index 8a28e9b1367..b11e1a577ed 100644 --- a/lldb/source/Utility/Reproducer.cpp +++ b/lldb/source/Utility/Reproducer.cpp @@ -255,7 +255,7 @@ DataRecorder::Create(const FileSpec &filename) { DataRecorder *CommandProvider::GetNewDataRecorder() { std::size_t i = m_data_recorders.size() + 1; std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") + - llvm::Twine(i) + llvm::Twine(".txt")) + llvm::Twine(i) + llvm::Twine(".yaml")) .str(); auto recorder_or_error = DataRecorder::Create(GetRoot().CopyByAppendingPathComponent(filename)); @@ -304,53 +304,9 @@ void WorkingDirectoryProvider::Keep() { os << m_cwd << "\n"; } -llvm::raw_ostream *ProcessGDBRemoteProvider::GetHistoryStream() { - FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file); - - std::error_code EC; - m_stream_up = std::make_unique<raw_fd_ostream>(history_file.GetPath(), EC, - sys::fs::OpenFlags::OF_Text); - return m_stream_up.get(); -} - -std::unique_ptr<CommandLoader> CommandLoader::Create(Loader *loader) { - if (!loader) - return {}; - - FileSpec file = loader->GetFile<repro::CommandProvider::Info>(); - if (!file) - return {}; - - auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath()); - if (auto err = error_or_file.getError()) - return {}; - - std::vector<std::string> files; - llvm::yaml::Input yin((*error_or_file)->getBuffer()); - yin >> files; - - if (auto err = yin.error()) - return {}; - - for (auto &file : files) { - FileSpec absolute_path = - loader->GetRoot().CopyByAppendingPathComponent(file); - file = absolute_path.GetPath(); - } - - return std::make_unique<CommandLoader>(std::move(files)); -} - -llvm::Optional<std::string> CommandLoader::GetNextFile() { - if (m_index >= m_files.size()) - return {}; - return m_files[m_index++]; -} - void ProviderBase::anchor() {} char CommandProvider::ID = 0; char FileProvider::ID = 0; -char ProcessGDBRemoteProvider::ID = 0; char ProviderBase::ID = 0; char VersionProvider::ID = 0; char WorkingDirectoryProvider::ID = 0; @@ -358,8 +314,6 @@ const char *CommandProvider::Info::file = "command-interpreter.yaml"; const char *CommandProvider::Info::name = "command-interpreter"; const char *FileProvider::Info::file = "files.yaml"; const char *FileProvider::Info::name = "files"; -const char *ProcessGDBRemoteProvider::Info::file = "gdb-remote.yaml"; -const char *ProcessGDBRemoteProvider::Info::name = "gdb-remote"; const char *VersionProvider::Info::file = "version.txt"; const char *VersionProvider::Info::name = "version"; const char *WorkingDirectoryProvider::Info::file = "cwd.txt"; |