|
LLDB mainline
|
#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 | Verbose (const char *fmt,...) __attribute__((format(printf |
| void void void const Flags | GetOptions () const |
| MaskType | GetMask () const |
| bool | GetVerbose () const |
| void | VAPrintf (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 llvm::Error | EnableLogChannel (const std::shared_ptr< LogHandler > &log_handler_sp, uint32_t log_options, llvm::StringRef channel, llvm::ArrayRef< const char * > categories) |
| 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< Log > | ChannelMap |
Private Member Functions | |
| void | WriteHeader (llvm::raw_ostream &OS, llvm::StringRef file, llvm::StringRef function) |
| void | WriteJSONHeader (llvm::json::Object &obj, llvm::StringRef file, llvm::StringRef function) |
| void | WriteMessage (llvm::StringRef message) |
| void | EmitJSONMessage (llvm::StringRef file, llvm::StringRef function, llvm::StringRef message) |
| void | Format (llvm::StringRef file, llvm::StringRef function, const llvm::formatv_object_base &payload) |
| std::shared_ptr< LogHandler > | GetHandler () |
| 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 llvm::Expected< Log::MaskType > | GetFlags (const ChannelMap::value_type &entry, llvm::ArrayRef< const char * > categories) |
| Convert an array of category names into a set of category flags. | |
Private Attributes | |
| Channel & | m_channel |
| llvm::sys::RWMutex | m_mutex |
| std::shared_ptr< LogHandler > | m_handler |
| std::atomic< uint32_t > | m_options {0} |
| std::atomic< MaskType > | m_mask {0} |
Static Private Attributes | |
| static llvm::ManagedStatic< ChannelMap > | g_channel_map |
|
private |
| 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), };
|
inline |
|
default |
| void Log::Disable | ( | std::optional< MaskType > | flags = std::nullopt | ) |
|
static |
Definition at line 301 of file Log.cpp.
References g_channel_map.
Referenced by CommandObjectLogDisable::DoExecute(), and lldb_private::SystemInitializerCommon::Terminate().
|
static |
Definition at line 250 of file Log.cpp.
References g_channel_map, GetFlags(), and lldb_private::toString().
Referenced by CommandObjectLogDisable::DoExecute().
|
private |
|
static |
Definition at line 274 of file Log.cpp.
References g_channel_map.
Referenced by CommandObjectLogDump::DoExecute().
|
private |
Definition at line 441 of file Log.cpp.
References WriteJSONHeader(), and WriteMessage().
Referenced by Format(), and PutString().
| void Log::Enable | ( | const std::shared_ptr< LogHandler > & | handler_sp, |
| std::optional< MaskType > | flags = std::nullopt, | ||
| uint32_t | options = 0 ) |
|
static |
Definition at line 230 of file Log.cpp.
References g_channel_map, and GetFlags().
Referenced by lldb_private::Debugger::EnableLog().
|
staticprivate |
Definition at line 57 of file Log.cpp.
Referenced by ForEachChannelCategory(), and ListCategories().
|
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 306 of file Log.cpp.
References ForEachCategory(), and g_channel_map.
Referenced by CompleteEnableDisable().
|
inline |
Definition at line 241 of file Log.h.
References Format().
Referenced by Format(), FormatError(), and VAFormatf().
|
private |
Definition at line 428 of file Log.cpp.
References EmitJSONMessage(), GetOptions(), LLDB_LOG_OPTION_JSON, WriteHeader(), and WriteMessage().
|
inline |
| void Log::Formatf | ( | llvm::StringRef | file, |
| llvm::StringRef | function, | ||
| const char * | format, | ||
| ... ) |
Definition at line 190 of file Log.cpp.
References VAFormatf().
|
staticprivate |
Convert an array of category names into a set of category flags.
Returns a bitmask of categories, or an error message in the case that at least one category name was not recognised. All unknown category names are included in the error.
Definition at line 76 of file Log.cpp.
References ListCategories().
Referenced by DisableLogChannel(), and EnableLogChannel().
|
inlineprivate |
Definition at line 303 of file Log.h.
References m_handler, and m_mutex.
Referenced by WriteMessage().
| Log::MaskType Log::GetMask | ( | ) | const |
Definition at line 158 of file Log.cpp.
References m_mask.
Referenced by lldb_private::Log::Channel::GetLog().
| const Flags Log::GetOptions | ( | ) | const |
Definition at line 154 of file Log.cpp.
References m_options.
Referenced by Format(), PutString(), WriteHeader(), and WriteJSONHeader().
| bool Log::GetVerbose | ( | ) | const |
Definition at line 333 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(), DumpInstToLog(), DumpUnwindRowsToLog(), lldb_private::DWARFExpression::Evaluate(), GetModuleConfig(), lldb_private::AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(), lldb_private::CompactUnwindInfo::GetUnwindPlan(), lldb_private::Module::LogMessageVerboseBacktrace(), lldb_private::process_gdb_remote::GDBRemoteRegisterContext::ReadAllRegisterValues(), UnwindAssemblyInstEmulation::ReadMemory(), UnwindAssemblyInstEmulation::ReadRegister(), lldb_private::ThreadPlanCallFunction::ReportRegisterState(), IRForTarget::runOnModule(), lldb_private::IRDynamicChecks::runOnModule(), lldb_private::SectionLoadList::SetSectionUnloaded(), lldb_private::SectionLoadList::SetSectionUnloaded(), lldb_private::ASTResultSynthesizer::SynthesizeFunctionResult(), lldb_private::ASTResultSynthesizer::SynthesizeObjCMethodResult(), lldb_private::ASTResultSynthesizer::TransformTopLevelDecl(), Verbose(), lldb_private::process_gdb_remote::GDBRemoteRegisterContext::WriteAllRegisterValues(), UnwindAssemblyInstEmulation::WriteMemory(), UnwindAssemblyInstEmulation::WriteRegister(), and lldb_private::process_gdb_remote::GDBRemoteRegisterContext::WriteRegisterBytes().
|
static |
Definition at line 323 of file Log.cpp.
References g_channel_map, and ListCategories().
Referenced by CommandObjectLogList::DoExecute().
|
staticprivate |
Definition at line 66 of file Log.cpp.
References ForEachCategory().
Referenced by GetFlags(), ListAllLogChannels(), and ListChannelCategories().
|
static |
Definition at line 290 of file Log.cpp.
References g_channel_map, and ListCategories().
Referenced by CommandObjectLogList::DoExecute().
|
static |
Returns the list of log channels.
Definition at line 316 of file Log.cpp.
References g_channel_map.
Referenced by CompleteEnableDisable(), and CommandObjectLogList::HandleArgumentCompletion().
| void Log::Printf | ( | const char * | format, |
| ... ) |
Prefer using LLDB_LOGF whenever possible.
Definition at line 177 of file Log.cpp.
References VAPrintf().
Referenced by ProcessMachCore::LoadBinariesViaMetadata(), ObjectFileMachO::LoadCoreFileImages(), and lldb_private::formatters::NSNumberSummaryProvider().
| void Log::PutCString | ( | const char * | cstr | ) |
Definition at line 162 of file Log.cpp.
References PutString().
Referenced by lldb_private::process_gdb_remote::ProcessGDBRemote::DoDetach(), ProcessKDP::DoDetach(), lldb_private::ThreadPlanStepInRange::DoPlanExplainsStop(), lldb_private::ThreadPlanStepOverRange::DoPlanExplainsStop(), AuxVector::DumpToLog(), DYLDRendezvous::DumpToLog(), HexagonDYLDRendezvous::DumpToLog(), lldb_private::ThreadPlanStepThrough::HitOurBackstopBreakpoint(), lldb_private::MonitoringProcessLauncher::LaunchProcess(), lldb_private::Module::LogMessage(), lldb_private::Module::LogMessageVerboseBacktrace(), DynamicLoaderDarwinKernel::PutToLog(), DynamicLoaderMacOSXDYLD::PutToLog(), DynamicLoaderMacOSXDYLD::RemoveModulesUsingImageInfosAddress(), lldb_private::ThreadPlanCallFunction::ReportRegisterState(), lldb_private::Process::RunThreadPlan(), lldb_private::ThreadList::ShouldStop(), lldb_private::ThreadPlanStepInstruction::ShouldStop(), lldb_private::process_gdb_remote::GDBRemoteClientBase::Lock::SyncWithContinueThread(), lldb_private::DynamicLoaderDarwin::UnloadAllImages(), and lldb_private::DynamicLoaderDarwin::UnloadImages().
| void Log::PutString | ( | llvm::StringRef | str | ) |
Definition at line 164 of file Log.cpp.
References EmitJSONMessage(), GetOptions(), LLDB_LOG_OPTION_JSON, WriteHeader(), and WriteMessage().
Referenced by AddToLog(), lldb_private::ThreadPlanStepOverRange::DoWillResume(), lldb_private::DiagnosticManager::Dump(), DumpInstToLog(), EntityPersistentVariable::DumpToLog(), EntityRegister::DumpToLog(), EntityResultVariable::DumpToLog(), EntitySymbol::DumpToLog(), EntityVariableBase::DumpToLog(), DumpUnwindRowsToLog(), LogInitInfo(), LogInitInfo(), ABIMacOSX_arm64::PrepareTrivialCall(), ABISysV_arm64::PrepareTrivialCall(), ABISysV_mips64::PrepareTrivialCall(), ABISysV_mips::PrepareTrivialCall(), ABISysV_ppc64::PrepareTrivialCall(), ABISysV_ppc::PrepareTrivialCall(), ABISysV_s390x::PrepareTrivialCall(), ABISysV_x86_64::PrepareTrivialCall(), ABIWindows_x86_64::PrepareTrivialCall(), PutCString(), lldb_private::DataExtractor::PutToLog(), UnwindAssemblyInstEmulation::ReadMemory(), UnwindAssemblyInstEmulation::ReadRegister(), lldb_private::ThreadPlanCallFunction::ReportRegisterState(), lldb_private::Process::RunThreadPlan(), lldb_private::process_gdb_remote::GDBRemoteCommunication::SendRawPacketNoLock(), VAPrintf(), UnwindAssemblyInstEmulation::WriteMemory(), and UnwindAssemblyInstEmulation::WriteRegister().
|
static |
Definition at line 216 of file Log.cpp.
References g_channel_map, and UNUSED_IF_ASSERT_DISABLED.
Referenced by lldb_private::LLDBLogChannel::Initialize(), lldb_private::LogChannelDWARF::Initialize(), lldb_private::process_gdb_remote::ProcessGDBRemoteLog::Initialize(), lldb_private::ProcessKDPLog::Initialize(), lldb_private::ProcessPOSIXLog::Initialize(), and lldb_private::ProcessWindowsLog::Initialize().
|
static |
Definition at line 222 of file Log.cpp.
References g_channel_map.
Referenced by lldb_private::LLDBLogChannel::Terminate(), lldb_private::LogChannelDWARF::Terminate(), lldb_private::process_gdb_remote::ProcessGDBRemoteLog::Terminate(), lldb_private::ProcessKDPLog::Terminate(), lldb_private::ProcessPOSIXLog::Terminate(), and lldb_private::ProcessWindowsLog::Terminate().
| void Log::VAFormatf | ( | llvm::StringRef | file, |
| llvm::StringRef | function, | ||
| const char * | format, | ||
| va_list | args ) |
Definition at line 198 of file Log.cpp.
References Format(), and lldb_private::VASprintf().
Referenced by Formatf().
| void Log::VAPrintf | ( | const char * | format, |
| va_list | args ) |
Definition at line 184 of file Log.cpp.
References PutString(), and lldb_private::VASprintf().
| void Log::Verbose | ( | const char * | fmt, |
| ... ) |
Definition at line 206 of file Log.cpp.
References GetVerbose(), and VAPrintf().
|
private |
Definition at line 337 of file Log.cpp.
References g_sequence_id, GetOptions(), LLDB_LOG_OPTION_BACKTRACE, LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION, LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD, LLDB_LOG_OPTION_PREPEND_SEQUENCE, LLDB_LOG_OPTION_PREPEND_THREAD_NAME, LLDB_LOG_OPTION_PREPEND_TIMESTAMP, lldb_private::OS, and lldb_private::Flags::Test().
Referenced by Format(), and PutString().
|
private |
Definition at line 378 of file Log.cpp.
References g_sequence_id, GetOptions(), LLDB_LOG_OPTION_BACKTRACE, LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION, LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD, LLDB_LOG_OPTION_PREPEND_SEQUENCE, LLDB_LOG_OPTION_PREPEND_THREAD_NAME, LLDB_LOG_OPTION_PREPEND_TIMESTAMP, and lldb_private::Flags::Test().
Referenced by EmitJSONMessage().
|
private |
Definition at line 419 of file Log.cpp.
References GetHandler().
Referenced by EmitJSONMessage(), Format(), and PutString().
|
staticprivate |
Definition at line 311 of file Log.h.
Referenced by DisableAllLogChannels(), DisableLogChannel(), DumpLogChannel(), EnableLogChannel(), ForEachChannelCategory(), ListAllLogChannels(), ListChannelCategories(), ListChannels(), Register(), and Unregister().
|
private |
|
private |
|
private |
|
private |
|
private |
Definition at line 289 of file Log.h.
Referenced by Enable(), GetOptions(), and GetVerbose().