Index: include/lldb/Core/Log.h =================================================================== --- include/lldb/Core/Log.h +++ include/lldb/Core/Log.h @@ -200,4 +200,11 @@ log_private->Format(__FILE__, __FUNCTION__, __VA_ARGS__); \ } while (0) +#define LLDB_LOGV(log, ...) \ + do { \ + ::lldb_private::Log *log_private = (log); \ + if (log_private && log_private->GetVerbose()) \ + log_private->Format(__FILE__, __FUNCTION__, __VA_ARGS__); \ + } while (0) + #endif // liblldb_Log_h_ Index: include/lldb/Core/Logging.h =================================================================== --- include/lldb/Core/Logging.h +++ include/lldb/Core/Logging.h @@ -19,7 +19,6 @@ //---------------------------------------------------------------------- // Log Bits specific to logging in lldb //---------------------------------------------------------------------- -#define LIBLLDB_LOG_VERBOSE (1u << 0) #define LIBLLDB_LOG_PROCESS (1u << 1) #define LIBLLDB_LOG_THREAD (1u << 2) #define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 3) @@ -69,8 +68,6 @@ uint32_t GetLogMask(); -bool IsLogVerbose(); - void DisableLog(const char **categories, Stream *feedback_strm); Log *EnableLog(lldb::StreamSP &log_stream_sp, uint32_t log_options, Index: source/API/SBBroadcaster.cpp =================================================================== --- source/API/SBBroadcaster.cpp +++ source/API/SBBroadcaster.cpp @@ -22,25 +22,15 @@ SBBroadcaster::SBBroadcaster(const char *name) : m_opaque_sp(new Broadcaster(NULL, name)), m_opaque_ptr(NULL) { m_opaque_ptr = m_opaque_sp.get(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API | - LIBLLDB_LOG_VERBOSE)); - - if (log) - log->Printf( - "SBBroadcaster::SBBroadcaster (name=\"%s\") => SBBroadcaster(%p)", name, - static_cast(m_opaque_ptr)); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API )); + LLDB_LOGV(log, "(name=\"{0}\") => SBBroadcaster({1})", name, m_opaque_ptr); } SBBroadcaster::SBBroadcaster(lldb_private::Broadcaster *broadcaster, bool owns) : m_opaque_sp(owns ? broadcaster : NULL), m_opaque_ptr(broadcaster) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API | - LIBLLDB_LOG_VERBOSE)); - - if (log) - log->Printf("SBBroadcaster::SBBroadcaster (broadcaster=%p, bool owns=%i) " - "=> SBBroadcaster(%p)", - static_cast(broadcaster), owns, - static_cast(m_opaque_ptr)); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_LOGV(log, "(broadcaster={0}, owns={1}) => SBBroadcaster({2})", + broadcaster, owns, m_opaque_ptr); } SBBroadcaster::SBBroadcaster(const SBBroadcaster &rhs) Index: source/API/SBEvent.cpp =================================================================== --- source/API/SBEvent.cpp +++ source/API/SBEvent.cpp @@ -109,13 +109,9 @@ // For logging, this gets a little chatty so only enable this when verbose // logging is on - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API | - LIBLLDB_LOG_VERBOSE)); - if (log) - log->Printf( - "SBEvent(%p)::BroadcasterMatchesRef (SBBroadcaster(%p): %s) => %i", - static_cast(get()), static_cast(broadcaster.get()), - broadcaster.GetName(), success); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_LOGV(log, "({0}) (SBBroadcaster({1}): {2}) => {3}", get(), + broadcaster.get(), broadcaster.GetName(), success); return success; } Index: source/Core/DataBufferMemoryMap.cpp =================================================================== --- source/Core/DataBufferMemoryMap.cpp +++ source/Core/DataBufferMemoryMap.cpp @@ -175,14 +175,10 @@ bool fd_is_file) { Clear(); if (fd >= 0) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MMAP | - LIBLLDB_LOG_VERBOSE)); - if (log) { - log->Printf("DataBufferMemoryMap::MemoryMapFromFileDescriptor(fd=%i, " - "offset=0x%" PRIx64 ", length=0x%" PRIx64 - ", writeable=%i, fd_is_file=%i)", - fd, offset, (uint64_t)length, writeable, fd_is_file); - } + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MMAP)); + LLDB_LOGV(log, "(fd={0}, offset={1:x}, length={2:x}, " + "writeable={3}, fd_is_file={4})", + fd, offset, length, writeable, fd_is_file); #ifdef _WIN32 HANDLE handle = (HANDLE)_get_osfhandle(fd); DWORD file_size_low, file_size_high; @@ -291,13 +287,8 @@ m_data = m_mmap_addr; m_size = length; } - - if (log) { - log->Printf( - "DataBufferMemoryMap::MemoryMapFromFileSpec() m_mmap_addr = " - "%p, m_mmap_size = %" PRIu64 ", error = %s", - (void *)m_mmap_addr, (uint64_t)m_mmap_size, error.AsCString()); - } + LLDB_LOGV(log, "m_mmap_addr = {0}, m_mmap_size = {1}, error = {2}", + m_mmap_addr, m_mmap_size, error); } } } Index: source/Core/Logging.cpp =================================================================== --- source/Core/Logging.cpp +++ source/Core/Logging.cpp @@ -44,11 +44,6 @@ return 0; } -bool lldb_private::IsLogVerbose() { - uint32_t mask = GetLogMask(); - return (mask & LIBLLDB_LOG_VERBOSE); -} - Log *lldb_private::GetLogIfAllCategoriesSet(uint32_t mask) { Log *log(GetLog()); if (log && mask) { @@ -130,8 +125,6 @@ flag_bits &= ~LIBLLDB_LOG_THREAD; else if (0 == ::strcasecmp(arg, "target")) flag_bits &= ~LIBLLDB_LOG_TARGET; - else if (0 == ::strcasecmp(arg, "verbose")) - flag_bits &= ~LIBLLDB_LOG_VERBOSE; else if (0 == ::strncasecmp(arg, "watch", 5)) flag_bits &= ~LIBLLDB_LOG_WATCHPOINTS; else if (0 == ::strncasecmp(arg, "temp", 4)) @@ -257,8 +250,6 @@ flag_bits |= LIBLLDB_LOG_TYPES; else if (0 == ::strncasecmp(arg, "unwind", 6)) flag_bits |= LIBLLDB_LOG_UNWIND; - else if (0 == ::strcasecmp(arg, "verbose")) - flag_bits |= LIBLLDB_LOG_VERBOSE; else if (0 == ::strncasecmp(arg, "watch", 5)) flag_bits |= LIBLLDB_LOG_WATCHPOINTS; else if (0 == ::strcasecmp(arg, "jit")) Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp @@ -501,10 +501,9 @@ if (m_filled) return; std::lock_guard guard(m_mutex); - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_VERBOSE)); - if (log) - log->Printf("[ClassDescriptorV2::iVarsStorage::fill] class_name = %s", - descriptor.GetClassName().AsCString(" bool { const bool for_expression = false; const bool stop_loop = false; - if (log) - log->Printf("[ClassDescriptorV2::iVarsStorage::fill] name = %s, encoding " - "= %s, offset_ptr = %" PRIx64 ", size = %" PRIu64, - name, type, offset_ptr, size); + LLDB_LOGV(log, "name = {0}, encoding = {1}, offset_ptr = {2:x}, size = {3}", + name, type, offset_ptr, size); CompilerType ivar_type = encoding_to_type_sp->RealizeType(type, for_expression); if (ivar_type) { - if (log) - log->Printf("[ClassDescriptorV2::iVarsStorage::fill] name = %s, " - "encoding = %s, offset_ptr = %" PRIx64 ", size = %" PRIu64 - " , type_size = %" PRIu64, - name, type, offset_ptr, size, - ivar_type.GetByteSize(nullptr)); + LLDB_LOGV(log, "name = {0}, encoding = {1}, offset_ptr = {2:x}, size = " + "{3}, type_size = {4}", + name, type, offset_ptr, size, ivar_type.GetByteSize(nullptr)); Scalar offset_scalar; Error error; const int offset_ptr_size = 4; @@ -539,18 +533,13 @@ size_t read = process->ReadScalarIntegerFromMemory( offset_ptr, offset_ptr_size, is_signed, offset_scalar, error); if (error.Success() && 4 == read) { - if (log) - log->Printf( - "[ClassDescriptorV2::iVarsStorage::fill] offset_ptr = %" PRIx64 - " --> %" PRIu32, - offset_ptr, offset_scalar.SInt()); + LLDB_LOGV(log, "offset_ptr = {0:x} --> {1}", offset_ptr, + offset_scalar.SInt()); m_ivars.push_back( {ConstString(name), ivar_type, size, offset_scalar.SInt()}); - } else if (log) - log->Printf( - "[ClassDescriptorV2::iVarsStorage::fill] offset_ptr = %" PRIx64 - " --> read fail, read = %zu", - offset_ptr, read); + } else + LLDB_LOGV(log, "offset_ptr = {0:x} --> read fail, read = %{1}", + offset_ptr, read); } return stop_loop; }); Index: source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp +++ source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp @@ -497,18 +497,15 @@ uint32_t PlatformRemoteAppleTV::FindFileInAllSDKs(const char *platform_file_path, FileSpecList &file_list) { - Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | - LIBLLDB_LOG_VERBOSE); + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (platform_file_path && platform_file_path[0] && UpdateSDKDirectoryInfosIfNeeded()) { const uint32_t num_sdk_infos = m_sdk_directory_infos.size(); lldb_private::FileSpec local_file; // First try for an exact match of major, minor and update for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) { - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file_path, + m_sdk_directory_infos[sdk_idx].directory); if (GetFileInSDK(platform_file_path, sdk_idx, local_file)) { file_list.Append(local_file); } @@ -619,8 +616,8 @@ // then we attempt to get a shared module for the right architecture // with the right UUID. const FileSpec &platform_file = module_spec.GetFileSpec(); - Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | - LIBLLDB_LOG_VERBOSE); + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST + ); Error error; char platform_file_path[PATH_MAX]; @@ -637,12 +634,8 @@ // using the OS build. const uint32_t connected_sdk_idx = GetConnectedSDKIndex(); if (connected_sdk_idx < num_sdk_infos) { - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[connected_sdk_idx] - .directory.GetPath() - .c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, + m_sdk_directory_infos[connected_sdk_idx].directory); if (GetFileInSDK(platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); @@ -658,12 +651,8 @@ // Try the last SDK index if it is set as most files from an SDK // will tend to be valid in that same SDK. if (m_last_module_sdk_idx < num_sdk_infos) { - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[m_last_module_sdk_idx] - .directory.GetPath() - .c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file_path, + m_sdk_directory_infos[m_last_module_sdk_idx].directory); if (GetFileInSDK(platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); @@ -682,10 +671,8 @@ // it above continue; } - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file_path, + m_sdk_directory_infos[sdk_idx].directory); if (GetFileInSDK(platform_file_path, sdk_idx, platform_module_spec.GetFileSpec())) { // printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str()); Index: source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp +++ source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp @@ -511,18 +511,15 @@ uint32_t PlatformRemoteAppleWatch::FindFileInAllSDKs(const char *platform_file_path, FileSpecList &file_list) { - Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | - LIBLLDB_LOG_VERBOSE); + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (platform_file_path && platform_file_path[0] && UpdateSDKDirectoryInfosIfNeeded()) { const uint32_t num_sdk_infos = m_sdk_directory_infos.size(); lldb_private::FileSpec local_file; // First try for an exact match of major, minor and update for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) { - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file_path, + m_sdk_directory_infos[sdk_idx].directory); if (GetFileInSDK(platform_file_path, sdk_idx, local_file)) { file_list.Append(local_file); } @@ -633,8 +630,7 @@ // then we attempt to get a shared module for the right architecture // with the right UUID. const FileSpec &platform_file = module_spec.GetFileSpec(); - Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | - LIBLLDB_LOG_VERBOSE); + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); Error error; char platform_file_path[PATH_MAX]; @@ -651,12 +647,8 @@ // using the OS build. const uint32_t connected_sdk_idx = GetConnectedSDKIndex(); if (connected_sdk_idx < num_sdk_infos) { - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[connected_sdk_idx] - .directory.GetPath() - .c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, + m_sdk_directory_infos[connected_sdk_idx].directory); if (GetFileInSDK(platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); @@ -672,12 +664,8 @@ // Try the last SDK index if it is set as most files from an SDK // will tend to be valid in that same SDK. if (m_last_module_sdk_idx < num_sdk_infos) { - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[m_last_module_sdk_idx] - .directory.GetPath() - .c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, + m_sdk_directory_infos[m_last_module_sdk_idx].directory); if (GetFileInSDK(platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); @@ -696,10 +684,8 @@ // it above continue; } - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, + m_sdk_directory_infos[sdk_idx].directory); if (GetFileInSDK(platform_file_path, sdk_idx, platform_module_spec.GetFileSpec())) { // printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str()); Index: source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -481,18 +481,15 @@ uint32_t PlatformRemoteiOS::FindFileInAllSDKs(const char *platform_file_path, FileSpecList &file_list) { - Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | - LIBLLDB_LOG_VERBOSE); + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (platform_file_path && platform_file_path[0] && UpdateSDKDirectoryInfosIfNeeded()) { const uint32_t num_sdk_infos = m_sdk_directory_infos.size(); lldb_private::FileSpec local_file; // First try for an exact match of major, minor and update for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) { - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file_path, + m_sdk_directory_infos[sdk_idx].directory); if (GetFileInSDK(platform_file_path, sdk_idx, local_file)) { file_list.Append(local_file); } @@ -605,8 +602,7 @@ // then we attempt to get a shared module for the right architecture // with the right UUID. const FileSpec &platform_file = module_spec.GetFileSpec(); - Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | - LIBLLDB_LOG_VERBOSE); + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); Error error; char platform_file_path[PATH_MAX]; @@ -623,12 +619,8 @@ // using the OS build. const uint32_t connected_sdk_idx = GetConnectedSDKIndex(); if (connected_sdk_idx < num_sdk_infos) { - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[connected_sdk_idx] - .directory.GetPath() - .c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, + m_sdk_directory_infos[connected_sdk_idx].directory); if (GetFileInSDK(platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); @@ -644,12 +636,8 @@ // Try the last SDK index if it is set as most files from an SDK // will tend to be valid in that same SDK. if (m_last_module_sdk_idx < num_sdk_infos) { - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[m_last_module_sdk_idx] - .directory.GetPath() - .c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, + m_sdk_directory_infos[m_last_module_sdk_idx].directory); if (GetFileInSDK(platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); @@ -670,11 +658,8 @@ GetSDKIndexBySDKDirectoryInfo(current_sdk_info); if (current_sdk_idx < num_sdk_infos && current_sdk_idx != m_last_module_sdk_idx) { - if (log) { - log->Printf( - "Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[current_sdk_idx].directory.GetPath().c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, + m_sdk_directory_infos[current_sdk_idx].directory); if (GetFileInSDK(platform_file_path, current_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); @@ -694,10 +679,8 @@ // it above continue; } - if (log) { - log->Printf("Searching for %s in sdk path %s", platform_file_path, - m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str()); - } + LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, + m_sdk_directory_infos[sdk_idx].directory); if (GetFileInSDK(platform_file_path, sdk_idx, platform_module_spec.GetFileSpec())) { // printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str()); @@ -749,10 +732,8 @@ size_t num_module_search_paths = module_search_paths_ptr->GetSize(); for (size_t i = 0; i < num_module_search_paths; ++i) { - Log *log_verbose = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | - LIBLLDB_LOG_VERBOSE); - if (log_verbose) - log_verbose->Printf ("PlatformRemoteiOS::GetSharedModule searching for binary in search-path %s", module_search_paths_ptr->GetFileSpecAtIndex(i).GetPath().c_str()); + LLDB_LOGV(log, "searching for binary in search-path {0}", + module_search_paths_ptr->GetFileSpecAtIndex(i)); // Create a new FileSpec with this module_search_paths_ptr // plus just the filename ("UIFoundation"), then the parent // dir plus filename ("UIFoundation.framework/UIFoundation") Index: source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp =================================================================== --- source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -142,14 +142,9 @@ ~InitializePythonRAII() { if (m_was_already_initialized) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT | - LIBLLDB_LOG_VERBOSE)); - - if (log) { - log->Printf("Releasing PyGILState. Returning to state = %slocked\n", - m_was_already_initialized == PyGILState_UNLOCKED ? "un" - : ""); - } + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT)); + LLDB_LOGV(log, "Releasing PyGILState. Returning to state = {0}locked", + m_was_already_initialized == PyGILState_UNLOCKED ? "un" : ""); PyGILState_Release(m_gil_state); } else { // We initialized the threads in this function, just unlock the GIL. @@ -174,15 +169,12 @@ void InitializeThreadsPrivate() { if (PyEval_ThreadsInitialized()) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT | - LIBLLDB_LOG_VERBOSE)); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT)); m_was_already_initialized = true; m_gil_state = PyGILState_Ensure(); - if (log) { - log->Printf("Ensured PyGILState. Previous state = %slocked\n", - m_gil_state == PyGILState_UNLOCKED ? "un" : ""); - } + LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked\n", + m_gil_state == PyGILState_UNLOCKED ? "un" : ""); return; } @@ -212,12 +204,10 @@ } bool ScriptInterpreterPython::Locker::DoAcquireLock() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT | - LIBLLDB_LOG_VERBOSE)); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT)); m_GILState = PyGILState_Ensure(); - if (log) - log->Printf("Ensured PyGILState. Previous state = %slocked\n", - m_GILState == PyGILState_UNLOCKED ? "un" : ""); + LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked", + m_GILState == PyGILState_UNLOCKED ? "un" : ""); // we need to save the thread state when we first start the command // because we might decide to interrupt it while some action is taking @@ -239,10 +229,8 @@ } bool ScriptInterpreterPython::Locker::DoFreeLock() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT | - LIBLLDB_LOG_VERBOSE)); - if (log) - log->Printf("Releasing PyGILState. Returning to state = %slocked\n", + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT)); + LLDB_LOGV(log, "Releasing PyGILState. Returning to state = {0}locked", m_GILState == PyGILState_UNLOCKED ? "un" : ""); PyGILState_Release(m_GILState); m_python_interpreter->DecrementLockCount(); Index: source/Target/Memory.cpp =================================================================== --- source/Target/Memory.cpp +++ source/Target/Memory.cpp @@ -263,16 +263,15 @@ lldb::addr_t AllocatedBlock::ReserveBlock(uint32_t size) { addr_t addr = LLDB_INVALID_ADDRESS; - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE)); + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); if (size <= m_byte_size) { const uint32_t needed_chunks = CalculateChunksNeededForSize(size); if (m_offset_to_chunk_size.empty()) { m_offset_to_chunk_size[0] = needed_chunks; - if (log) - log->Printf("[1] AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) " - "=> offset = 0x%x, %u %u bit chunks", - (void *)this, size, size, 0, needed_chunks, m_chunk_size); + LLDB_LOGV(log, "[1] ({0}) (size = {1} ({1:x})) => offset = {2:x}, {3} " + "{4} bit chunks", + this, size, 0, needed_chunks, m_chunk_size); addr = m_addr; } else { uint32_t last_offset = 0; @@ -285,12 +284,10 @@ CalculateChunksNeededForSize(bytes_available); if (num_chunks >= needed_chunks) { m_offset_to_chunk_size[last_offset] = needed_chunks; - if (log) - log->Printf("[2] AllocatedBlock::ReserveBlock(%p) (size = %u " - "(0x%x)) => offset = 0x%x, %u %u bit chunks - " - "num_chunks %zu", - (void *)this, size, size, last_offset, needed_chunks, - m_chunk_size, m_offset_to_chunk_size.size()); + LLDB_LOGV(log, "[2] ({0}) (size = {1} ({1:x})) => offset = {2:x}, " + "{3} {4} bit chunks- num_chunks {5}", + this, size, last_offset, needed_chunks, m_chunk_size, + m_offset_to_chunk_size.size()); addr = m_addr + last_offset; break; } @@ -304,12 +301,10 @@ CalculateChunksNeededForSize(m_byte_size - last_offset); if (chunks_left >= needed_chunks) { m_offset_to_chunk_size[last_offset] = needed_chunks; - if (log) - log->Printf("[3] AllocatedBlock::ReserveBlock(%p) (size = %u " - "(0x%x)) => offset = 0x%x, %u %u bit chunks - " - "num_chunks %zu", - (void *)this, size, size, last_offset, needed_chunks, - m_chunk_size, m_offset_to_chunk_size.size()); + LLDB_LOGV(log, "[3] ({0}) (size = {1} ({1:x})) => offset = {2:x}, " + "{3} {4} bit chunks- num_chunks {5}", + this, size, last_offset, needed_chunks, m_chunk_size, + m_offset_to_chunk_size.size()); addr = m_addr + last_offset; break; } @@ -371,10 +366,7 @@ // } } - if (log) - log->Printf("AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) => " - "0x%16.16" PRIx64, - (void *)this, size, size, (uint64_t)addr); + LLDB_LOGV(log, "({0}) (size = {1} ({1:x})) => {2:x}", this, size, addr); return addr; } @@ -386,12 +378,9 @@ m_offset_to_chunk_size.erase(pos); success = true; } - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE)); - if (log) - log->Printf("AllocatedBlock::FreeBlock(%p) (addr = 0x%16.16" PRIx64 - ") => %i, num_chunks: %zu", - (void *)this, (uint64_t)addr, success, - m_offset_to_chunk_size.size()); + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); + LLDB_LOGV(log, "({0}) (addr = {1:x}) => {2}, num_chunks: {3}", this, addr, + success, m_offset_to_chunk_size.size()); return success; } Index: source/Target/SectionLoadList.cpp =================================================================== --- source/Target/SectionLoadList.cpp +++ source/Target/SectionLoadList.cpp @@ -67,21 +67,13 @@ bool SectionLoadList::SetSectionLoadAddress(const lldb::SectionSP §ion, addr_t load_addr, bool warn_multiple) { - Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER | - LIBLLDB_LOG_VERBOSE)); - + Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); ModuleSP module_sp(section->GetModule()); if (module_sp) { - if (log) { - const FileSpec &module_file_spec(module_sp->GetFileSpec()); - log->Printf("SectionLoadList::%s (section = %p (%s.%s), load_addr = " - "0x%16.16" PRIx64 ") module = %p", - __FUNCTION__, static_cast(section.get()), - module_file_spec.GetPath().c_str(), - section->GetName().AsCString(), load_addr, - static_cast(module_sp.get())); - } + LLDB_LOGV(log, "(section = {0} ({1}.{2}), load_addr = {3:x}) module = {4}", + section.get(), module_sp->GetFileSpec(), + section->GetName().AsCString(), load_addr, module_sp.get()); if (section->GetByteSize() == 0) return false; // No change @@ -147,10 +139,9 @@ size_t unload_count = 0; if (section_sp) { - Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER | - LIBLLDB_LOG_VERBOSE)); + Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); - if (log) { + if (log && log->GetVerbose()) { ModuleSP module_sp = section_sp->GetModule(); std::string module_name(""); if (module_sp) { @@ -183,10 +174,9 @@ bool SectionLoadList::SetSectionUnloaded(const lldb::SectionSP §ion_sp, addr_t load_addr) { - Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER | - LIBLLDB_LOG_VERBOSE)); + Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); - if (log) { + if (log && log->GetVerbose()) { ModuleSP module_sp = section_sp->GetModule(); std::string module_name(""); if (module_sp) { Index: source/Target/ThreadPlanCallFunction.cpp =================================================================== --- source/Target/ThreadPlanCallFunction.cpp +++ source/Target/ThreadPlanCallFunction.cpp @@ -174,9 +174,8 @@ } void ThreadPlanCallFunction::ReportRegisterState(const char *message) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP | - LIBLLDB_LOG_VERBOSE)); - if (log) { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP)); + if (log && log->GetVerbose()) { StreamString strm; RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();