[lldb] Extract reproducer providers & co into their own header.
Extract all the provider related logic from Reproducer.h and move it
into its own header ReproducerProvider.h. These classes are seeing most
of the development these days and this reorganization reduces
incremental compilation from ~520 to ~110 files when making changes to
the new header.
diff --git a/lldb/source/Utility/ProcessInfo.cpp b/lldb/source/Utility/ProcessInfo.cpp
index aae48d6..310d2b2 100644
--- a/lldb/source/Utility/ProcessInfo.cpp
+++ b/lldb/source/Utility/ProcessInfo.cpp
@@ -9,6 +9,7 @@
#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/ReproducerProvider.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/UserIDResolver.h"
@@ -347,57 +348,6 @@
io.mapRequired("parent-pid", Info.m_parent_pid);
}
-llvm::Expected<std::unique_ptr<ProcessInfoRecorder>>
-ProcessInfoRecorder::Create(const FileSpec &filename) {
- std::error_code ec;
- auto recorder =
- std::make_unique<ProcessInfoRecorder>(std::move(filename), ec);
- if (ec)
- return llvm::errorCodeToError(ec);
- return std::move(recorder);
-}
-
-void ProcessInfoProvider::Keep() {
- std::vector<std::string> files;
- for (auto &recorder : m_process_info_recorders) {
- recorder->Stop();
- 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;
- llvm::yaml::Output yout(os);
- yout << files;
-}
-
-void ProcessInfoProvider::Discard() { m_process_info_recorders.clear(); }
-
-ProcessInfoRecorder *ProcessInfoProvider::GetNewProcessInfoRecorder() {
- std::size_t i = m_process_info_recorders.size() + 1;
- std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") +
- llvm::Twine(i) + llvm::Twine(".yaml"))
- .str();
- auto recorder_or_error = ProcessInfoRecorder::Create(
- GetRoot().CopyByAppendingPathComponent(filename));
- if (!recorder_or_error) {
- llvm::consumeError(recorder_or_error.takeError());
- return nullptr;
- }
-
- m_process_info_recorders.push_back(std::move(*recorder_or_error));
- return m_process_info_recorders.back().get();
-}
-
-void ProcessInfoRecorder::Record(const ProcessInstanceInfoList &process_infos) {
- if (!m_record)
- return;
- llvm::yaml::Output yout(m_os);
- yout << const_cast<ProcessInstanceInfoList &>(process_infos);
- m_os.flush();
-}
llvm::Optional<ProcessInstanceInfoList>
repro::GetReplayProcessInstanceInfoList() {
@@ -425,7 +375,3 @@
return infos;
}
-
-char ProcessInfoProvider::ID = 0;
-const char *ProcessInfoProvider::Info::file = "process-info.yaml";
-const char *ProcessInfoProvider::Info::name = "process-info";