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>

Collaboration diagram for lldb_private::Log:
Collaboration graph
[legend]

Classes

struct  Category
 
class  Channel
 

Public Types

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

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 Printf (const char *format,...) __attribute__((format(printf
 Prefer using LLDB_LOGF whenever possible. More...
 
void void Error (const char *fmt,...) __attribute__((format(printf
 
void void void Verbose (const char *fmt,...) __attribute__((format(printf
 
void void void void Warning (const char *fmt,...) __attribute__((format(printf
 
void void void void const Flags GetOptions () const
 
const Flags GetMask () const
 
bool GetVerbose () const
 
void VAPrintf (const char *format, va_list args)
 
void VAError (const char *format, va_list args)
 

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. More...
 
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. More...
 
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 (const std::string &message)
 
void Format (llvm::StringRef file, llvm::StringRef function, const llvm::formatv_object_base &payload)
 
std::shared_ptr< LogHandlerGetHandler ()
 
void Enable (const std::shared_ptr< LogHandler > &handler_sp, uint32_t options, uint32_t flags)
 
void Disable (uint32_t flags)
 
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 uint32_t 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_tm_options {0}
 
std::atomic< MaskTypem_mask {0}
 

Static Private Attributes

static llvm::ManagedStatic< ChannelMapg_channel_map
 

Detailed Description

Definition at line 115 of file Log.h.

Member Typedef Documentation

◆ ChannelMap

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

Definition at line 285 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 124 of file Log.h.

Constructor & Destructor Documentation

◆ Log() [1/2]

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

Definition at line 214 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 ( uint32_t  flags)
private

Definition at line 105 of file Log.cpp.

References lldb_private::Log::Channel::log_ptr, m_channel, m_handler, m_mask, and m_mutex.

◆ DisableAllLogChannels()

void Log::DisableAllLogChannels ( )
static

Definition at line 268 of file Log.cpp.

References g_channel_map, and UINT32_MAX.

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

◆ DisableLogChannel()

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

Definition at line 226 of file Log.cpp.

References g_channel_map, GetFlags(), and UINT32_MAX.

◆ Dump()

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

Definition at line 115 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 241 of file Log.cpp.

References g_channel_map.

◆ Enable()

void Log::Enable ( const std::shared_ptr< LogHandler > &  handler_sp,
uint32_t  options,
uint32_t  flags 
)
private

Definition at line 93 of file Log.cpp.

References lldb_private::Log::Channel::log_ptr, m_channel, m_handler, m_mask, m_mutex, and m_options.

◆ 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 210 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 45 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 273 of file Log.cpp.

References ForEachCategory(), and g_channel_map.

◆ 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 221 of file Log.h.

Referenced by FormatError().

◆ Format() [2/2]

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

Definition at line 355 of file Log.cpp.

References message(), string(), 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 227 of file Log.h.

References error(), Format(), and lldb_private::toString().

◆ GetFlags()

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

Definition at line 63 of file Log.cpp.

References ListCategories(), and UINT32_MAX.

Referenced by DisableLogChannel(), and EnableLogChannel().

◆ GetHandler()

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

Definition at line 273 of file Log.h.

References m_handler, and m_mutex.

Referenced by WriteMessage().

◆ GetMask()

const Flags Log::GetMask ( ) const

Definition at line 129 of file Log.cpp.

References m_mask.

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

◆ GetOptions()

const Flags Log::GetOptions ( ) const

Definition at line 125 of file Log.cpp.

References m_options.

Referenced by WriteHeader().

◆ GetVerbose()

bool Log::GetVerbose ( ) const

Definition at line 300 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::ClangExpressionParser::ClangExpressionParser(), 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::Module::LogMessageVerboseBacktrace(), lldb_private::AppleObjCRuntimeV2::ParseClassInfoArray(), lldb_private::process_gdb_remote::GDBRemoteRegisterContext::ReadAllRegisterValues(), UnwindAssemblyInstEmulation::ReadMemory(), lldb_private::ThreadList::RefreshStateAfterStop(), lldb_private::ThreadPlanCallFunction::ReportRegisterState(), lldb_private::StackFrameList::ResetCurrentInlinedDepth(), lldb_private::IRDynamicChecks::runOnModule(), IRForTarget::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::DynamicClassInfoExtractor::UpdateISAToDescriptorMap(), lldb_private::AppleObjCRuntimeV2::SharedCacheClassInfoExtractor::UpdateISAToDescriptorMap(), lldb_private::AppleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded(), Verbose(), lldb_private::ThreadList::WillResume(), lldb_private::process_gdb_remote::GDBRemoteRegisterContext::WriteAllRegisterValues(), UnwindAssemblyInstEmulation::WriteMemory(), and lldb_private::process_gdb_remote::GDBRemoteRegisterContext::WriteRegisterBytes().

◆ ListAllLogChannels()

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

Definition at line 290 of file Log.cpp.

References g_channel_map, and ListCategories().

◆ ListCategories()

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

Definition at line 54 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 257 of file Log.cpp.

References g_channel_map, and ListCategories().

◆ ListChannels()

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

Returns the list of log channels.

Definition at line 283 of file Log.cpp.

References g_channel_map.

◆ 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 203 of file Log.cpp.

References g_channel_map, and UINT32_MAX.

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

◆ VAError()

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

Definition at line 168 of file Log.cpp.

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

Referenced by Error().

◆ VAPrintf()

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

Definition at line 147 of file Log.cpp.

References string(), lldb_private::VASprintf(), WriteHeader(), and WriteMessage().

Referenced by Printf(), and Verbose().

◆ Verbose()

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

Definition at line 176 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 ( const std::string message)
private

Definition at line 346 of file Log.cpp.

References GetHandler(), and message().

Referenced by Format(), and VAPrintf().

Member Data Documentation

◆ ChannelFlag

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

Definition at line 127 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 254 of file Log.h.

Referenced by Disable(), and Enable().

◆ m_handler

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

Definition at line 262 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 264 of file Log.h.

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

◆ m_mutex

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

Definition at line 260 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 263 of file Log.h.

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


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