Go to the documentation of this file.
12 #include "llvm/Support/Error.h"
13 #include "llvm/Support/FileSystem.h"
14 #include "llvm/Support/raw_ostream.h"
24 lldbassert(!InstanceImpl() &&
"Already initialized.");
25 InstanceImpl().emplace();
29 lldbassert(InstanceImpl() &&
"Already terminated.");
30 InstanceImpl().reset();
36 static std::optional<Diagnostics> g_diagnostics;
53 if (!diagnostics_dir) {
54 stream <<
"unable to create diagnostic dir: "
55 <<
toString(diagnostics_dir.takeError()) <<
'\n';
59 return Dump(stream, *diagnostics_dir);
63 stream <<
"LLDB diagnostics will be written to " << dir.
GetPath() <<
"\n";
64 stream <<
"Please include the directory content when filing a bug report\n";
75 SmallString<128> diagnostics_dir;
77 sys::fs::createUniqueDirectory(
"diagnostics", diagnostics_dir);
79 return errorCodeToError(ec);
80 return FileSpec(diagnostics_dir.str());
88 if (
Error err = c(dir))
92 return Error::success();
98 llvm::raw_fd_ostream stream(log_file.
GetPath(), ec, llvm::sys::fs::OF_None);
100 return errorCodeToError(ec);
102 return Error::success();
const char * toString(AppleArm64ExceptionClass EC)
RotatingLogHandler m_log_handler
static Diagnostics & Instance()
std::mutex m_callbacks_mutex
static llvm::Expected< FileSpec > CreateUniqueDirectory()
Create a unique diagnostic directory.
Diagnostics are a collection of files to help investigate bugs and troubleshoot issues.
void Emit(llvm::StringRef message) override
static llvm::raw_ostream & error(Stream &strm)
void Report(llvm::StringRef message)
void AddCallback(Callback callback)
std::function< llvm::Error(const FileSpec &)> Callback
llvm::SmallVector< Callback, 4 > m_callbacks
FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const
static std::optional< Diagnostics > & InstanceImpl()
message(FATAL_ERROR "invalid libipt include path provided") endif() include_directories($
bool Dump(llvm::raw_ostream &stream)
Gather diagnostics and print a message to the given output stream.
A class that represents a running process on the host machine.
llvm::Error Create(const FileSpec &dir)
Gather diagnostics in the given directory.
llvm::Error DumpDiangosticsLog(const FileSpec &dir) const
void Dump(llvm::raw_ostream &stream) const
static constexpr size_t g_num_log_messages
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.