Go to the documentation of this file.
9 #ifndef LLDB_UTILITY_REPRODUCER_PROVIDER_H
10 #define LLDB_UTILITY_REPRODUCER_PROVIDER_H
16 #include "llvm/ADT/StringRef.h"
17 #include "llvm/Support/Error.h"
18 #include "llvm/Support/FileCollector.h"
19 #include "llvm/Support/YAMLTraits.h"
35 m_os(filename.GetPath(), ec,
llvm::sys::fs::OF_TextWithCRLF),
60 static llvm::Expected<std::unique_ptr<DataRecorder>>
63 template <
typename T>
void Record(
const T &t,
bool newline =
false) {
79 static llvm::Expected<std::unique_ptr<YamlRecorder>>
82 template <
typename T>
void Record(
const T &t) {
85 llvm::yaml::Output yout(
m_os);
89 yout << const_cast<T &>(t);
102 m_collector = std::make_shared<llvm::FileCollector>(
111 void Keep()
override;
137 void Keep()
override;
154 llvm::raw_fd_ostream os(file.
GetPath(), ec, llvm::sys::fs::OF_TextWithCRLF);
173 llvm::SmallString<128> cwd;
174 if (std::error_code EC = llvm::sys::fs::current_path(cwd))
193 llvm::SmallString<128> home_dir;
194 llvm::sys::path::home_directory(home_dir);
211 void Keep()
override;
245 template <
typename T,
typename V>
252 std::string filename = (llvm::Twine(V::Info::name) + llvm::Twine(
"-") +
253 llvm::Twine(i) + llvm::Twine(
".yaml"))
255 auto recorder_or_error =
256 T::Create(this->
GetRoot().CopyByAppendingPathComponent(filename));
257 if (!recorder_or_error) {
258 llvm::consumeError(recorder_or_error.takeError());
262 m_recorders.push_back(std::move(*recorder_or_error));
267 std::vector<std::string> files;
270 files.push_back(recorder->GetFilename().GetPath());
275 llvm::raw_fd_ostream os(file.
GetPath(), ec, llvm::sys::fs::OF_TextWithCRLF);
278 llvm::yaml::Output yout(os);
306 static llvm::Expected<std::unique_ptr<ProcessInfoRecorder>>
323 void Keep()
override;
347 auto error_or_file = llvm::MemoryBuffer::getFile(file.
GetPath());
348 if (
auto err = error_or_file.getError())
351 std::vector<std::string> files;
352 llvm::yaml::Input yin((*error_or_file)->getBuffer());
355 if (
auto err = yin.error())
358 for (
auto &file : files) {
361 file = absolute_path.
GetPath();
364 return std::make_unique<MultiLoader<T>>(std::move(files));
381 std::pair<FileSpec, FileSpec>
GetPaths(
const UUID *uuid)
const;
389 template <
typename T>
391 llvm::Expected<std::string> dir = loader->
LoadBuffer<T>();
393 return dir.takeError();
408 io.mapRequired(
"uuid", entry.
uuid);
416 #endif // LLDB_UTILITY_REPRODUCER_PROVIDER_H
Entry(std::string uuid, std::string module_path, std::string symbol_path)
VersionProvider(const FileSpec &directory)
void RecordInterestingDirectory(const llvm::Twine &dir)
void AddSymbolFile(const UUID *uuid, const FileSpec &module_path, const FileSpec &symbol_path)
static llvm::Expected< std::unique_ptr< ProcessInfoRecorder > > Create(const FileSpec &filename)
std::vector< Entry > m_symbol_files
void Discard() override
The Discard method is called when it is decided that we do not need to keep any information and will ...
void Record(const ProcessInstanceInfoList &process_infos)
static llvm::Expected< std::unique_ptr< YamlRecorder > > Create(const FileSpec &filename)
static std::unique_ptr< MultiLoader > Create(Loader *loader)
llvm::Optional< std::string > GetNextFile()
Recorder that records its data as YAML to a file.
DirectoryProvider(const FileSpec &root)
bool operator<(const Entry &rhs) const
Recorder that records its data as text to a file.
void Keep() override
The Keep method is called when it is decided that we need to keep the data in order to provide a repr...
DataRecorder(const FileSpec &filename, std::error_code &ec)
const FileSpec & GetFilename()
Loader for data captured with the MultiProvider.
llvm::Expected< std::string > GetDirectoryFrom(repro::Loader *loader)
Helper to read directories written by the DirectoryProvider.
Abstract provider to storing directory paths.
MultiProvider(const FileSpec &directory)
The MultiProvider is a provider that hands out recorder which can be used to capture data for differe...
ProcessInfoRecorder(const FileSpec &filename, std::error_code &ec)
void Keep() override
The Keep method is called when it is decided that we need to keep the data in order to provide a repr...
static llvm::Expected< std::unique_ptr< DataRecorder > > Create(const FileSpec &filename)
llvm::Expected< std::string > LoadBuffer()
SymbolFileLoader(Loader *loader)
void Keep() override
The Keep method is called when it is decided that we need to keep the data in order to provide a repr...
Provider for mapping UUIDs to symbol and executable files.
ProcessInfoProvider(const FileSpec &directory)
The recorder is a small object handed out by a provider to record data.
FileProvider(const FileSpec &directory)
SymbolFileProvider(const FileSpec &directory)
string(SUBSTRING ${p} 10 -1 pStripped) if($
std::vector< std::unique_ptr< T > > m_recorders
FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const
Provider for the LLDB version number.
std::vector< std::string > m_files
HomeDirectoryProvider(const FileSpec &directory)
bool operator==(const Entry &rhs) const
ProcessInfoRecorder * GetNewProcessInfoRecorder()
std::unique_ptr< llvm::raw_fd_ostream > m_stream_up
void RecordInterestingDirectoryRecursive(const llvm::Twine &dir)
void Record(const T &t, bool newline=false)
void SetVersion(std::string version)
std::shared_ptr< llvm::FileCollector > GetFileCollector()
AbstractRecorder(const FileSpec &filename, std::error_code &ec)
MultiLoader(std::vector< std::string > files)
void Keep() override
The Keep method is called when it is decided that we need to keep the data in order to provide a repr...
void Keep() override
The Keep method is called when it is decided that we need to keep the data in order to provide a repr...
A class that represents a running process on the host machine.
CommandProvider(const FileSpec &directory)
llvm::raw_fd_ostream m_os
std::vector< SymbolFileProvider::Entry > m_symbol_files
void Keep() override
The Keep method is called when it is decided that we need to keep the data in order to provide a repr...
std::shared_ptr< llvm::FileCollector > m_collector
const FileSpec & GetRoot() const
WorkingDirectoryProvider(const FileSpec &directory)
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
const FileSpec & GetRoot() const
Provider for the home directory.
std::vector< std::unique_ptr< ProcessInfoRecorder > > m_process_info_recorders
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
void SetDirectory(std::string directory)
void Discard() override
The Discard method is called when it is decided that we do not need to keep any information and will ...
YamlRecorder(const FileSpec &filename, std::error_code &ec)
std::pair< FileSpec, FileSpec > GetPaths(const UUID *uuid) const
Provider for the current working directory.
static void mapping(IO &io, lldb_private::repro::SymbolFileProvider::Entry &entry)
llvm::StringRef GetDirectory()