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

#include <Log.h>

Classes

struct  Category
 
class  Channel
 

Public Types

using MaskType = uint64_t
 The underlying type of all log channel enums.
 

Public Member Functions

 Log (Channel &channel)
 
 ~Log ()=default
 
void PutCString (const char *cstr)
 
void PutString (llvm::StringRef str)
 
template<typename... Args>
void Format (llvm::StringRef file, llvm::StringRef function, const char *format, Args &&... args)
 
template<typename... Args>
void FormatError (llvm::Error error, llvm::StringRef file, llvm::StringRef function, const char *format, Args &&... args)
 
void Formatf (llvm::StringRef file, llvm::StringRef function, const char *format,...) __attribute__((format(printf
 
void void Printf (const char *format,...) __attribute__((format(printf
 Prefer using LLDB_LOGF whenever possible.
 
void void void Error (const char *fmt,...) __attribute__((format(printf
 
void void void void Verbose (const char *fmt,...) __attribute__((format(printf
 
void void void void void Warning (const char *fmt,...) __attribute__((format(printf
 
void void void void void const Flags GetOptions () const
 
MaskType GetMask () const
 
bool GetVerbose () const
 
void VAPrintf (const char *format, va_list args)
 
void VAError (const char *format, va_list args)
 
void VAFormatf (llvm::StringRef file, llvm::StringRef function, const char *format, va_list args)
 
void Enable (const std::shared_ptr< LogHandler > &handler_sp, std::optional< MaskType > flags=std::nullopt, uint32_t options=0)
 
void Disable (std::optional< MaskType > flags=std::nullopt)
 

Static Public Member Functions

static void Register (llvm::StringRef name, Channel &channel)
 
static void Unregister (llvm::StringRef name)
 
static bool EnableLogChannel (const std::shared_ptr< LogHandler > &log_handler_sp, uint32_t log_options, llvm::StringRef channel, llvm::ArrayRef< const char * > categories, llvm::raw_ostream &error_stream)
 
static bool DisableLogChannel (llvm::StringRef channel, llvm::ArrayRef< const char * > categories, llvm::raw_ostream &error_stream)
 
static bool DumpLogChannel (llvm::StringRef channel, llvm::raw_ostream &output_stream, llvm::raw_ostream &error_stream)
 
static bool ListChannelCategories (llvm::StringRef channel, llvm::raw_ostream &stream)
 
static std::vector< llvm::StringRef > ListChannels ()
 Returns the list of log channels.
 
static void ForEachChannelCategory (llvm::StringRef channel, llvm::function_ref< void(llvm::StringRef, llvm::StringRef)> lambda)
 Calls the given lambda for every category in the given channel.
 
static void DisableAllLogChannels ()
 
static void ListAllLogChannels (llvm::raw_ostream &stream)
 

Static Public Attributes

template<MaskType Bit>
static constexpr MaskType ChannelFlag = MaskType(1) << Bit
 

Private Types

typedef llvm::StringMap< LogChannelMap
 

Private Member Functions

void WriteHeader (llvm::raw_ostream &OS, llvm::StringRef file, llvm::StringRef function)
 
void WriteMessage (llvm::StringRef message)
 
void Format (llvm::StringRef file, llvm::StringRef function, const llvm::formatv_object_base &payload)
 
std::shared_ptr< LogHandlerGetHandler ()
 
bool Dump (llvm::raw_ostream &stream)
 
 Log (const Log &)=delete
 
void operator= (const Log &)=delete
 

Static Private Member Functions

static void ForEachCategory (const Log::ChannelMap::value_type &entry, llvm::function_ref< void(llvm::StringRef, llvm::StringRef)> lambda)
 
static void ListCategories (llvm::raw_ostream &stream, const ChannelMap::value_type &entry)
 
static Log::MaskType GetFlags (llvm::raw_ostream &stream, const ChannelMap::value_type &entry, llvm::ArrayRef< const char * > categories)
 

Private Attributes

Channelm_channel
 
llvm::sys::RWMutex m_mutex
 
std::shared_ptr< LogHandlerm_handler
 
std::atomic< uint32_t > m_options {0}
 
std::atomic< MaskTypem_mask {0}
 

Static Private Attributes

static llvm::ManagedStatic< ChannelMapg_channel_map
 

Detailed Description

Definition at line 132 of file Log.h.

Member Typedef Documentation

◆ ChannelMap

typedef llvm::StringMap<Log> lldb_private::Log::ChannelMap
private

Definition at line 308 of file Log.h.

◆ MaskType

using lldb_private::Log::MaskType = uint64_t

The underlying type of all log channel enums.

Declare them as: enum class MyLog : MaskType { Channel0 = Log::ChannelFlag<0>, Channel1 = Log::ChannelFlag<1>, ..., LLVM_MARK_AS_BITMASK_ENUM(LastChannel), };

Definition at line 141 of file Log.h.

Constructor & Destructor Documentation

◆ Log() [1/2]

lldb_private::Log::Log ( Channel channel)
inline

Definition at line 231 of file Log.h.

◆ ~Log()

lldb_private::Log::~Log ( )
default

◆ Log() [2/2]

lldb_private::Log::Log ( const Log )
privatedelete

Member Function Documentation

◆ Disable()

void Log::Disable ( std::optional< MaskType flags = std::nullopt)

◆ DisableAllLogChannels()

void Log::DisableAllLogChannels ( )
static

◆ DisableLogChannel()

bool Log::DisableLogChannel ( llvm::StringRef  channel,
llvm::ArrayRef< const char * >  categories,
llvm::raw_ostream &  error_stream 
)
static

Definition at line 251 of file Log.cpp.

References g_channel_map, and GetFlags().

Referenced by CommandObjectLogDisable::DoExecute().

◆ Dump()

bool Log::Dump ( llvm::raw_ostream &  stream)
private

Definition at line 127 of file Log.cpp.

References m_handler, and m_mutex.

◆ DumpLogChannel()

bool Log::DumpLogChannel ( llvm::StringRef  channel,
llvm::raw_ostream &  output_stream,
llvm::raw_ostream &  error_stream 
)
static

Definition at line 267 of file Log.cpp.

References g_channel_map.

Referenced by CommandObjectLogDump::DoExecute().

◆ Enable()

void Log::Enable ( const std::shared_ptr< LogHandler > &  handler_sp,
std::optional< MaskType flags = std::nullopt,
uint32_t  options = 0 
)

◆ EnableLogChannel()

bool Log::EnableLogChannel ( const std::shared_ptr< LogHandler > &  log_handler_sp,
uint32_t  log_options,
llvm::StringRef  channel,
llvm::ArrayRef< const char * >  categories,
llvm::raw_ostream &  error_stream 
)
static

Definition at line 234 of file Log.cpp.

References g_channel_map, and GetFlags().

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

◆ Error()

void Log::Error ( const char *  fmt,
  ... 
)

◆ ForEachCategory()

void Log::ForEachCategory ( const Log::ChannelMap::value_type &  entry,
llvm::function_ref< void(llvm::StringRef, llvm::StringRef)>  lambda 
)
staticprivate

Definition at line 50 of file Log.cpp.

Referenced by ForEachChannelCategory(), and ListCategories().

◆ ForEachChannelCategory()

void Log::ForEachChannelCategory ( llvm::StringRef  channel,
llvm::function_ref< void(llvm::StringRef, llvm::StringRef)>  lambda 
)
static

Calls the given lambda for every category in the given channel.

If no channel with the given name exists, lambda is never called.

Definition at line 299 of file Log.cpp.

References ForEachCategory(), and g_channel_map.

Referenced by CompleteEnableDisable().

◆ Format() [1/2]

template<typename... Args>
void lldb_private::Log::Format ( llvm::StringRef  file,
llvm::StringRef  function,
const char *  format,
Args &&...  args 
)
inline

Definition at line 238 of file Log.h.

References Format().

Referenced by ObjectFilePECOFF::AppendFromExportTable(), Format(), FormatError(), and VAFormatf().

◆ Format() [2/2]

void Log::Format ( llvm::StringRef  file,
llvm::StringRef  function,
const llvm::formatv_object_base &  payload 
)
private

Definition at line 383 of file Log.cpp.

References WriteHeader(), and WriteMessage().

◆ FormatError()

template<typename... Args>
void lldb_private::Log::FormatError ( llvm::Error  error,
llvm::StringRef  file,
llvm::StringRef  function,
const char *  format,
Args &&...  args 
)
inline

Definition at line 244 of file Log.h.

References error(), and Format().

◆ Formatf()

void Log::Formatf ( llvm::StringRef  file,
llvm::StringRef  function,
const char *  format,
  ... 
)

Definition at line 169 of file Log.cpp.

References VAFormatf().

◆ GetFlags()

Log::MaskType Log::GetFlags ( llvm::raw_ostream &  stream,
const ChannelMap::value_type &  entry,
llvm::ArrayRef< const char * >  categories 
)
staticprivate

Definition at line 68 of file Log.cpp.

References ListCategories().

Referenced by DisableLogChannel(), and EnableLogChannel().

◆ GetHandler()

std::shared_ptr< LogHandler > lldb_private::Log::GetHandler ( )
inlineprivate

Definition at line 301 of file Log.h.

References m_handler, and m_mutex.

Referenced by WriteMessage().

◆ GetMask()

Log::MaskType Log::GetMask ( ) const

Definition at line 141 of file Log.cpp.

References m_mask.

Referenced by lldb_private::Log::Channel::GetLog().

◆ GetOptions()

const Flags Log::GetOptions ( ) const

Definition at line 137 of file Log.cpp.

References m_options.

Referenced by WriteHeader().

◆ GetVerbose()

bool Log::GetVerbose ( ) const

Definition at line 326 of file Log.cpp.

References LLDB_LOG_OPTION_VERBOSE, and m_options.

Referenced by CommunicationKDP::CheckForPacket(), lldb_private::process_gdb_remote::GDBRemoteCommunication::CheckForPacket(), lldb_private::ThreadPlanCallFunction::ConstructorSetup(), lldb_private::ThreadPlanCallFunction::DoTakedown(), lldb_private::DWARFExpression::Evaluate(), lldb_private::ClangASTSource::FindExternalVisibleDecls(), lldb_private::StackFrameList::GetCurrentInlinedDepth(), GetModuleConfig(), UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(), lldb_private::AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(), lldb_private::CompactUnwindInfo::GetUnwindPlan(), lldb_private::Debugger::HandleProgressEvent(), lldb_private::Module::LogMessageVerboseBacktrace(), lldb_private::AppleObjCRuntimeV2::ParseClassInfoArray(), lldb_private::process_gdb_remote::GDBRemoteRegisterContext::ReadAllRegisterValues(), UnwindAssemblyInstEmulation::ReadMemory(), UnwindAssemblyInstEmulation::ReadRegister(), lldb_private::ThreadList::RefreshStateAfterStop(), lldb_private::ThreadPlanCallFunction::ReportRegisterState(), lldb_private::StackFrameList::ResetCurrentInlinedDepth(), IRForTarget::runOnModule(), lldb_private::IRDynamicChecks::runOnModule(), lldb_private::SectionLoadList::SetSectionUnloaded(), lldb_private::process_gdb_remote::ProcessGDBRemote::StartNoticingNewThreads(), lldb_private::process_gdb_remote::ProcessGDBRemote::StopNoticingNewThreads(), lldb_private::ASTResultSynthesizer::SynthesizeFunctionResult(), lldb_private::ASTResultSynthesizer::SynthesizeObjCMethodResult(), lldb_private::ASTResultSynthesizer::TransformTopLevelDecl(), lldb_private::RegisterContextUnwind::UnwindLogMsgVerbose(), lldb_private::AppleObjCRuntimeV2::SharedCacheClassInfoExtractor::UpdateISAToDescriptorMap(), lldb_private::AppleObjCRuntimeV2::DynamicClassInfoExtractor::UpdateISAToDescriptorMap(), lldb_private::AppleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded(), Verbose(), lldb_private::ThreadList::WillResume(), lldb_private::process_gdb_remote::GDBRemoteRegisterContext::WriteAllRegisterValues(), UnwindAssemblyInstEmulation::WriteMemory(), UnwindAssemblyInstEmulation::WriteRegister(), and lldb_private::process_gdb_remote::GDBRemoteRegisterContext::WriteRegisterBytes().

◆ ListAllLogChannels()

void Log::ListAllLogChannels ( llvm::raw_ostream &  stream)
static

Definition at line 316 of file Log.cpp.

References g_channel_map, and ListCategories().

Referenced by CommandObjectLogList::DoExecute().

◆ ListCategories()

void Log::ListCategories ( llvm::raw_ostream &  stream,
const ChannelMap::value_type &  entry 
)
staticprivate

Definition at line 59 of file Log.cpp.

References ForEachCategory().

Referenced by GetFlags(), ListAllLogChannels(), and ListChannelCategories().

◆ ListChannelCategories()

bool Log::ListChannelCategories ( llvm::StringRef  channel,
llvm::raw_ostream &  stream 
)
static

Definition at line 283 of file Log.cpp.

References g_channel_map, and ListCategories().

Referenced by CommandObjectLogList::DoExecute().

◆ ListChannels()

std::vector< llvm::StringRef > Log::ListChannels ( )
static

Returns the list of log channels.

Definition at line 309 of file Log.cpp.

References g_channel_map.

Referenced by CompleteEnableDisable(), and CommandObjectLogList::HandleArgumentCompletion().

◆ operator=()

void lldb_private::Log::operator= ( const Log )
privatedelete

◆ Printf()

void Log::Printf ( const char *  format,
  ... 
)

◆ PutCString()

void Log::PutCString ( const char *  cstr)

◆ PutString()

void Log::PutString ( llvm::StringRef  str)

◆ Register()

void Log::Register ( llvm::StringRef  name,
Channel channel 
)
static

◆ Unregister()

void Log::Unregister ( llvm::StringRef  name)
static

Definition at line 227 of file Log.cpp.

References g_channel_map.

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

◆ VAError()

void Log::VAError ( const char *  format,
va_list  args 
)

Definition at line 192 of file Log.cpp.

References Printf(), and lldb_private::VASprintf().

Referenced by Error().

◆ VAFormatf()

void Log::VAFormatf ( llvm::StringRef  file,
llvm::StringRef  function,
const char *  format,
va_list  args 
)

Definition at line 177 of file Log.cpp.

References Format(), and lldb_private::VASprintf().

Referenced by Formatf().

◆ VAPrintf()

void Log::VAPrintf ( const char *  format,
va_list  args 
)

Definition at line 163 of file Log.cpp.

References PutString(), and lldb_private::VASprintf().

Referenced by Printf(), and Verbose().

◆ Verbose()

void Log::Verbose ( const char *  fmt,
  ... 
)

Definition at line 200 of file Log.cpp.

References GetVerbose(), and VAPrintf().

◆ Warning()

void Log::Warning ( const char *  fmt,
  ... 
)

◆ WriteHeader()

void Log::WriteHeader ( llvm::raw_ostream &  OS,
llvm::StringRef  file,
llvm::StringRef  function 
)
private

◆ WriteMessage()

void Log::WriteMessage ( llvm::StringRef  message)
private

Definition at line 374 of file Log.cpp.

References GetHandler().

Referenced by Format(), and PutString().

Member Data Documentation

◆ ChannelFlag

template<MaskType Bit>
constexpr MaskType lldb_private::Log::ChannelFlag = MaskType(1) << Bit
staticconstexpr

Definition at line 144 of file Log.h.

◆ g_channel_map

llvm::ManagedStatic< Log::ChannelMap > Log::g_channel_map
staticprivate

◆ m_channel

Channel& lldb_private::Log::m_channel
private

Definition at line 282 of file Log.h.

Referenced by Disable(), and Enable().

◆ m_handler

std::shared_ptr<LogHandler> lldb_private::Log::m_handler
private

Definition at line 290 of file Log.h.

Referenced by Disable(), Dump(), Enable(), and GetHandler().

◆ m_mask

std::atomic<MaskType> lldb_private::Log::m_mask {0}
private

Definition at line 292 of file Log.h.

Referenced by Disable(), Enable(), and GetMask().

◆ m_mutex

llvm::sys::RWMutex lldb_private::Log::m_mutex
private

Definition at line 288 of file Log.h.

Referenced by Disable(), Dump(), Enable(), and GetHandler().

◆ m_options

std::atomic<uint32_t> lldb_private::Log::m_options {0}
private

Definition at line 291 of file Log.h.

Referenced by Enable(), GetOptions(), and GetVerbose().


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