LLDB mainline
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
lldb_private::Diagnostics Class Reference

Diagnostics are a collection of files to help investigate bugs and troubleshoot issues. More...

#include <Diagnostics.h>

Classes

struct  CallbackEntry
 

Public Types

using Callback = std::function< llvm::Error(const FileSpec &)>
 
using CallbackID = uint64_t
 

Public Member Functions

 Diagnostics ()
 
 ~Diagnostics ()
 
llvm::Error Create (const FileSpec &dir)
 Gather diagnostics in the given directory.
 
void Report (llvm::StringRef message)
 
CallbackID AddCallback (Callback callback)
 
void RemoveCallback (CallbackID id)
 
bool Dump (llvm::raw_ostream &stream)
 Gather diagnostics and print a message to the given output stream.
 
bool Dump (llvm::raw_ostream &stream, const FileSpec &dir)
 

Static Public Member Functions

static DiagnosticsInstance ()
 
static bool Enabled ()
 
static void Initialize ()
 
static void Terminate ()
 
static llvm::Expected< FileSpecCreateUniqueDirectory ()
 Create a unique diagnostic directory.
 

Private Member Functions

llvm::Error DumpDiangosticsLog (const FileSpec &dir) const
 

Static Private Member Functions

static std::optional< Diagnostics > & InstanceImpl ()
 

Private Attributes

RotatingLogHandler m_log_handler
 
CallbackID m_callback_id
 Monotonically increasing callback identifier.
 
llvm::SmallVector< CallbackEntry, 4 > m_callbacks
 List of callback entries.
 
std::mutex m_callbacks_mutex
 Mutex to protect callback list and callback identifier.
 

Detailed Description

Diagnostics are a collection of files to help investigate bugs and troubleshoot issues.

Any part of the debugger can register itself with the help of a callback to emit one or more files into the diagnostic directory.

Definition at line 28 of file Diagnostics.h.

Member Typedef Documentation

◆ Callback

using lldb_private::Diagnostics::Callback = std::function<llvm::Error(const FileSpec &)>

Definition at line 44 of file Diagnostics.h.

◆ CallbackID

Definition at line 45 of file Diagnostics.h.

Constructor & Destructor Documentation

◆ Diagnostics()

Diagnostics::Diagnostics ( )

Definition at line 42 of file Diagnostics.cpp.

◆ ~Diagnostics()

Diagnostics::~Diagnostics ( )

Definition at line 44 of file Diagnostics.cpp.

Member Function Documentation

◆ AddCallback()

Diagnostics::CallbackID Diagnostics::AddCallback ( Callback  callback)

Definition at line 46 of file Diagnostics.cpp.

References m_callback_id, m_callbacks, and m_callbacks_mutex.

Referenced by lldb_private::Debugger::Debugger().

◆ Create()

Error Diagnostics::Create ( const FileSpec dir)

Gather diagnostics in the given directory.

Definition at line 91 of file Diagnostics.cpp.

References DumpDiangosticsLog(), and m_callbacks.

Referenced by CommandObjectDiagnosticsDump::DoExecute(), and Dump().

◆ CreateUniqueDirectory()

llvm::Expected< FileSpec > Diagnostics::CreateUniqueDirectory ( )
static

Create a unique diagnostic directory.

Definition at line 82 of file Diagnostics.cpp.

Referenced by Dump(), and CommandObjectDiagnosticsDump::GetDirectory().

◆ Dump() [1/2]

bool Diagnostics::Dump ( llvm::raw_ostream &  stream)

Gather diagnostics and print a message to the given output stream.

Definition at line 59 of file Diagnostics.cpp.

References CreateUniqueDirectory(), Dump(), and lldb_private::toString().

Referenced by Dump(), and DumpDiagnostics().

◆ Dump() [2/2]

bool Diagnostics::Dump ( llvm::raw_ostream &  stream,
const FileSpec dir 
)

◆ DumpDiangosticsLog()

llvm::Error Diagnostics::DumpDiangosticsLog ( const FileSpec dir) const
private

◆ Enabled()

bool Diagnostics::Enabled ( )
static

◆ Initialize()

void Diagnostics::Initialize ( )
static

Definition at line 23 of file Diagnostics.cpp.

References InstanceImpl(), and lldbassert.

Referenced by lldb_private::SystemInitializerCommon::Initialize().

◆ Instance()

Diagnostics & Diagnostics::Instance ( )
static

◆ InstanceImpl()

std::optional< Diagnostics > & Diagnostics::InstanceImpl ( )
staticprivate

Definition at line 35 of file Diagnostics.cpp.

Referenced by Enabled(), Initialize(), Instance(), and Terminate().

◆ RemoveCallback()

void Diagnostics::RemoveCallback ( CallbackID  id)

◆ Report()

void Diagnostics::Report ( llvm::StringRef  message)

◆ Terminate()

void Diagnostics::Terminate ( )
static

Definition at line 28 of file Diagnostics.cpp.

References InstanceImpl(), and lldbassert.

Referenced by lldb_private::SystemInitializerCommon::Terminate().

Member Data Documentation

◆ m_callback_id

CallbackID lldb_private::Diagnostics::m_callback_id
private

Monotonically increasing callback identifier.

Unique per Diagnostic instance.

Definition at line 75 of file Diagnostics.h.

Referenced by AddCallback().

◆ m_callbacks

llvm::SmallVector<CallbackEntry, 4> lldb_private::Diagnostics::m_callbacks
private

List of callback entries.

Definition at line 78 of file Diagnostics.h.

Referenced by AddCallback(), Create(), and RemoveCallback().

◆ m_callbacks_mutex

std::mutex lldb_private::Diagnostics::m_callbacks_mutex
private

Mutex to protect callback list and callback identifier.

Definition at line 81 of file Diagnostics.h.

Referenced by AddCallback(), and RemoveCallback().

◆ m_log_handler

RotatingLogHandler lldb_private::Diagnostics::m_log_handler
private

Definition at line 64 of file Diagnostics.h.

Referenced by DumpDiangosticsLog(), and Report().


The documentation for this class was generated from the following files: