LLDB  mainline
Classes | Public Member Functions | Static Public Member Functions | 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 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 Initialize ()
 
static void Register (llvm::StringRef name, Channel &channel)
 
static void Unregister (llvm::StringRef name)
 
static bool EnableLogChannel (const std::shared_ptr< llvm::raw_ostream > &log_stream_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 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)
 

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< llvm::raw_ostream > GetStream ()
 
void Enable (const std::shared_ptr< llvm::raw_ostream > &stream_sp, uint32_t options, uint32_t flags)
 
void Disable (uint32_t flags)
 
 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)
 
static void DisableLoggingChild ()
 

Private Attributes

Channelm_channel
 
llvm::sys::RWMutex m_mutex
 
std::shared_ptr< llvm::raw_ostream > m_stream_sp
 
std::atomic< uint32_tm_options {0}
 
std::atomic< uint32_tm_mask {0}
 

Static Private Attributes

static llvm::ManagedStatic< ChannelMapg_channel_map
 

Detailed Description

Definition at line 49 of file Log.h.

Member Typedef Documentation

◆ ChannelMap

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

Definition at line 202 of file Log.h.

Constructor & Destructor Documentation

◆ Log() [1/2]

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

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

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

◆ DisableAllLogChannels()

void Log::DisableAllLogChannels ( )
static

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

References g_channel_map, GetFlags(), and UINT32_MAX.

◆ DisableLoggingChild()

void Log::DisableLoggingChild ( )
staticprivate

Definition at line 350 of file Log.cpp.

References g_channel_map.

Referenced by Initialize().

◆ Enable()

void Log::Enable ( const std::shared_ptr< llvm::raw_ostream > &  stream_sp,
uint32_t  options,
uint32_t  flags 
)
private

Definition at line 88 of file Log.cpp.

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

◆ EnableLogChannel()

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

Definition at line 202 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 40 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 249 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 140 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 341 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 146 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 58 of file Log.cpp.

References ListCategories(), and UINT32_MAX.

Referenced by DisableLogChannel(), and EnableLogChannel().

◆ GetMask()

const Flags Log::GetMask ( ) const

Definition at line 114 of file Log.cpp.

References m_mask.

Referenced by lldb_private::Log::Channel::GetLogIfAll(), and lldb_private::Log::Channel::GetLogIfAny().

◆ GetOptions()

const Flags Log::GetOptions ( ) const

Definition at line 110 of file Log.cpp.

References m_options.

Referenced by WriteHeader(), and WriteMessage().

◆ GetStream()

std::shared_ptr<llvm::raw_ostream> lldb_private::Log::GetStream ( )
inlineprivate

Definition at line 192 of file Log.h.

References m_mutex, and m_stream_sp.

Referenced by WriteMessage().

◆ GetVerbose()

bool Log::GetVerbose ( ) const

Definition at line 276 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::Host::SystemLog(), 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().

◆ Initialize()

void Log::Initialize ( )
static

◆ ListAllLogChannels()

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

Definition at line 266 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 49 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 233 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 259 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 195 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 153 of file Log.cpp.

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

Referenced by Error().

◆ VAPrintf()

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

◆ Verbose()

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

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

References GetOptions(), GetStream(), LLDB_LOG_OPTION_THREADSAFE, message(), and lldb_private::Flags::Test().

Referenced by Format(), and VAPrintf().

Member Data Documentation

◆ g_channel_map

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

◆ m_channel

Channel& lldb_private::Log::m_channel
private

Definition at line 173 of file Log.h.

Referenced by Disable(), and Enable().

◆ m_mask

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

Definition at line 183 of file Log.h.

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

◆ m_mutex

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

Definition at line 179 of file Log.h.

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

◆ m_options

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

Definition at line 182 of file Log.h.

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

◆ m_stream_sp

std::shared_ptr<llvm::raw_ostream> lldb_private::Log::m_stream_sp
private

Definition at line 181 of file Log.h.

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


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