|
LLDB mainline
|
Diagnostics maintain an always-on, in-memory log of recent diagnostic messages that can be written out to help investigate bugs and troubleshoot issues. More...
#include <Diagnostics.h>
Classes | |
| struct | Attachments |
| The bundle directory and the files written into it, recorded as each one is created so a file that could not be written is simply absent. More... | |
| struct | Report |
| The state a triager needs to make sense of a bug report. More... | |
Public Member Functions | |
| Diagnostics () | |
| ~Diagnostics () | |
| llvm::Error | Create (const FileSpec &dir) |
| Write the in-memory diagnostic log into the given directory. | |
| llvm::Expected< Report > | Collect (Debugger &debugger, const ExecutionContext &exe_ctx, const FileSpec &dir) |
Collect a full diagnostics bundle into dir and return its report. | |
| void | Record (llvm::StringRef message) |
| Record a diagnostic message into the always-on, in-memory log. | |
| bool | Dump (llvm::raw_ostream &stream) |
| Write the diagnostic log into a directory and print a message to the given output stream. | |
| bool | Dump (llvm::raw_ostream &stream, const FileSpec &dir) |
Static Public Member Functions | |
| static Diagnostics & | Instance () |
| static bool | Enabled () |
| static void | Initialize () |
| static void | Terminate () |
| static llvm::Expected< FileSpec > | CreateUniqueDirectory () |
| Create a unique diagnostic directory. | |
Private Member Functions | |
| llvm::Error | DumpDiangosticsLog (const FileSpec &dir) const |
Static Private Member Functions | |
| static std::optional< Diagnostics > & | InstanceImpl () |
| static std::string | GetHostDescription (const ExecutionContext &exe_ctx) |
| Scalars carried in the report rather than written as files. | |
| static std::string | GetInvocation () |
Private Attributes | |
| RotatingLogHandler | m_log_handler |
| static void | CollectStatistics (Debugger &debugger, const ExecutionContext &exe_ctx, const FileSpec &dir, std::vector< std::string > &files) |
| static void | CollectCommands (Debugger &debugger, const ExecutionContext &exe_ctx, const FileSpec &dir, std::vector< std::string > &files) |
| void | CollectLogs (Debugger &debugger, const FileSpec &dir, std::vector< std::string > &files) |
Collect the individual parts of the bundle into dir, appending the name of each file to files as it is written. | |
Diagnostics maintain an always-on, in-memory log of recent diagnostic messages that can be written out to help investigate bugs and troubleshoot issues.
Definition at line 34 of file Diagnostics.h.
| Diagnostics::Diagnostics | ( | ) |
Definition at line 59 of file Diagnostics.cpp.
References g_num_log_messages, and m_log_handler.
Referenced by Instance().
| Diagnostics::~Diagnostics | ( | ) |
Definition at line 61 of file Diagnostics.cpp.
| llvm::Expected< Diagnostics::Report > Diagnostics::Collect | ( | Debugger & | debugger, |
| const ExecutionContext & | exe_ctx, | ||
| const FileSpec & | dir ) |
Collect a full diagnostics bundle into dir and return its report.
Writes the always-on log, the debugger's file-backed logs, statistics, and a snapshot of the commands a triager runs first. Collection is best-effort: a failure to produce one artifact never aborts the rest, so a partial bundle is always better than none.
Definition at line 183 of file Diagnostics.cpp.
References lldb_private::Diagnostics::Report::attachments, CollectCommands(), CollectLogs(), CollectStatistics(), lldb_private::Diagnostics::Attachments::directory, lldb_private::Diagnostics::Attachments::files, GetHostDescription(), GetInvocation(), lldb_private::FileSpec::GetPath(), lldb_private::GetVersion(), lldb_private::Diagnostics::Report::invocation, lldb_private::Diagnostics::Report::os, and lldb_private::Diagnostics::Report::version.
Referenced by CommandObjectDiagnosticsDump::DoExecute(), and CommandObjectDiagnosticsReport::DoExecute().
|
staticprivate |
Definition at line 229 of file Diagnostics.cpp.
References Available(), CaptureCommand(), g_triage_commands, and WriteArtifact().
Referenced by Collect().
|
private |
Collect the individual parts of the bundle into dir, appending the name of each file to files as it is written.
Definition at line 203 of file Diagnostics.cpp.
References lldb_private::Debugger::CopyLogFilesToDirectory(), Create(), and error().
Referenced by Collect().
|
staticprivate |
Definition at line 216 of file Diagnostics.cpp.
References lldb_private::ExecutionContext::GetTargetPtr(), lldb_private::DebuggerStats::ReportStatistics(), and WriteArtifact().
Referenced by Collect().
Write the in-memory diagnostic log into the given directory.
Definition at line 95 of file Diagnostics.cpp.
References DumpDiangosticsLog().
Referenced by CollectLogs(), and Dump().
|
static |
Create a unique diagnostic directory.
Definition at line 86 of file Diagnostics.cpp.
Referenced by Dump(), CommandObjectDiagnosticsDump::GetDirectory(), and CommandObjectDiagnosticsReport::GetDirectory().
| bool Diagnostics::Dump | ( | llvm::raw_ostream & | stream | ) |
Write the diagnostic log into a directory and print a message to the given output stream.
Definition at line 63 of file Diagnostics.cpp.
References CreateUniqueDirectory(), Dump(), and lldb_private::toString().
Referenced by Dump(), and DumpDiagnostics().
Definition at line 74 of file Diagnostics.cpp.
References Create(), error(), lldb_private::FileSpec::GetPath(), and lldb_private::toString().
|
private |
Definition at line 102 of file Diagnostics.cpp.
References lldb_private::FileSpec::CopyByAppendingPathComponent(), lldb_private::FileSpec::GetPath(), and m_log_handler.
Referenced by Create().
|
static |
Definition at line 50 of file Diagnostics.cpp.
References InstanceImpl().
Referenced by lldb_private::Debugger::ReportDiagnosticImpl().
|
staticprivate |
Scalars carried in the report rather than written as files.
Definition at line 244 of file Diagnostics.cpp.
References lldb_private::Target::GetPlatform(), and lldb_private::ExecutionContext::GetTargetPtr().
Referenced by Collect().
|
staticprivate |
Definition at line 262 of file Diagnostics.cpp.
References lldb_private::Args::GetArgumentAtIndex(), lldb_private::Args::GetArgumentCount(), lldb_private::ProcessInfo::GetArguments(), lldb_private::Host::GetCurrentProcessID(), and lldb_private::Host::GetProcessInfo().
Referenced by Collect().
|
static |
Definition at line 40 of file Diagnostics.cpp.
References InstanceImpl(), and lldbassert.
Referenced by lldb_private::SystemInitializerCommon::Initialize().
|
static |
Definition at line 57 of file Diagnostics.cpp.
References Diagnostics(), and InstanceImpl().
Referenced by CommandObjectDiagnosticsDump::DoExecute(), CommandObjectDiagnosticsReport::DoExecute(), DumpDiagnostics(), and lldb_private::Debugger::ReportDiagnosticImpl().
|
staticprivate |
Definition at line 52 of file Diagnostics.cpp.
Referenced by Enabled(), Initialize(), Instance(), and Terminate().
| void Diagnostics::Record | ( | llvm::StringRef | message | ) |
Record a diagnostic message into the always-on, in-memory log.
Definition at line 112 of file Diagnostics.cpp.
References m_log_handler.
Referenced by lldb_private::Debugger::ReportDiagnosticImpl().
|
static |
Definition at line 45 of file Diagnostics.cpp.
References InstanceImpl(), and lldbassert.
Referenced by lldb_private::SystemInitializerCommon::Terminate().
|
private |
Definition at line 115 of file Diagnostics.h.
Referenced by Diagnostics(), DumpDiangosticsLog(), and Record().