diff --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h index 1529178cb83b..85977f53909a 100644 --- a/lldb/include/lldb/Utility/Log.h +++ b/lldb/include/lldb/Utility/Log.h @@ -373,6 +373,13 @@ Log *GetLLDBErrorLog(); log_private->Format(__FILE__, __func__, __VA_ARGS__); \ } while (0) +#define LLDB_LOG_VERBOSE(log, ...) \ + do { \ + ::lldb_private::Log *log_private = (log); \ + if (log_private && log_private->GetVerbose()) \ + log_private->Format(__FILE__, __func__, __VA_ARGS__); \ + } while (0) + #define LLDB_LOGF(log, ...) \ do { \ ::lldb_private::Log *log_private = (log); \ @@ -380,11 +387,11 @@ Log *GetLLDBErrorLog(); log_private->Formatf(__FILE__, __func__, __VA_ARGS__); \ } while (0) -#define LLDB_LOGV(log, ...) \ +#define LLDB_LOGF_VERBOSE(log, ...) \ do { \ ::lldb_private::Log *log_private = (log); \ if (log_private && log_private->GetVerbose()) \ - log_private->Format(__FILE__, __func__, __VA_ARGS__); \ + log_private->Formatf(__FILE__, __func__, __VA_ARGS__); \ } while (0) // Write message to log, if error is set. In the log message refer to the error diff --git a/lldb/source/Breakpoint/WatchpointAlgorithms.cpp b/lldb/source/Breakpoint/WatchpointAlgorithms.cpp index d65de13db1da..8c505b150294 100644 --- a/lldb/source/Breakpoint/WatchpointAlgorithms.cpp +++ b/lldb/source/Breakpoint/WatchpointAlgorithms.cpp @@ -44,12 +44,14 @@ WatchpointAlgorithms::AtomizeWatchpointRequest( } Log *log = GetLog(LLDBLog::Watchpoints); - LLDB_LOGV(log, "AtomizeWatchpointRequest user request addr {0:x} size {1}", - addr, size); + LLDB_LOG_VERBOSE(log, + "AtomizeWatchpointRequest user request addr {0:x} size {1}", + addr, size); std::vector resources; for (Region &ent : entries) { - LLDB_LOGV(log, "AtomizeWatchpointRequest creating resource {0:x} size {1}", - ent.addr, ent.size); + LLDB_LOG_VERBOSE( + log, "AtomizeWatchpointRequest creating resource {0:x} size {1}", + ent.addr, ent.size); WatchpointResourceSP wp_res_sp = std::make_shared(ent.addr, ent.size, read, write); resources.push_back(wp_res_sp); @@ -78,11 +80,11 @@ WatchpointAlgorithms::PowerOf2Watchpoints(addr_t user_addr, size_t user_size, uint32_t address_byte_size) { Log *log = GetLog(LLDBLog::Watchpoints); - LLDB_LOGV(log, - "AtomizeWatchpointRequest user request addr {0:x} size {1} " - "min_byte_size {2}, max_byte_size {3}, address_byte_size {4}", - user_addr, user_size, min_byte_size, max_byte_size, - address_byte_size); + LLDB_LOG_VERBOSE( + log, + "AtomizeWatchpointRequest user request addr {0:x} size {1} " + "min_byte_size {2}, max_byte_size {3}, address_byte_size {4}", + user_addr, user_size, min_byte_size, max_byte_size, address_byte_size); // Can't watch zero bytes. if (user_size == 0) diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index e4f0679a7d88..64b9500b2363 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -1047,13 +1047,10 @@ protected: const char *to = command.GetArgumentAtIndex(i + 1); if (from[0] && to[0]) { - Log *log = GetLog(LLDBLog::Host); - if (log) { - LLDB_LOGF(log, - "target modules search path adding ImageSearchPath " - "pair: '%s' -> '%s'", - from, to); - } + LLDB_LOGF(GetLog(LLDBLog::Host), + "target modules search path adding ImageSearchPath " + "pair: '%s' -> '%s'", + from, to); bool last_pair = ((argc - i) == 2); target.GetImageSearchPathList().Append( from, to, last_pair); // Notify if this is the last pair diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 61c7e271c2d9..c641acedc3d5 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -142,14 +142,13 @@ Module::Module(const ModuleSpec &module_spec) } Log *log(GetLog(LLDBLog::Object | LLDBLog::Modules)); - if (log != nullptr) - LLDB_LOGF(log, "%p Module::Module((%s) '%s%s%s%s')", - static_cast(this), - module_spec.GetArchitecture().GetArchitectureName(), - module_spec.GetFileSpec().GetPath().c_str(), - module_spec.GetObjectName().IsEmpty() ? "" : "(", - module_spec.GetObjectName().AsCString(""), - module_spec.GetObjectName().IsEmpty() ? "" : ")"); + LLDB_LOGF(log, "%p Module::Module((%s) '%s%s%s%s')", + static_cast(this), + module_spec.GetArchitecture().GetArchitectureName(), + module_spec.GetFileSpec().GetPath().c_str(), + module_spec.GetObjectName().IsEmpty() ? "" : "(", + module_spec.GetObjectName().AsCString(""), + module_spec.GetObjectName().IsEmpty() ? "" : ")"); auto extractor_sp = module_spec.GetExtractor(); lldb::offset_t file_size = 0; @@ -174,9 +173,7 @@ Module::Module(const ModuleSpec &module_spec) ModuleSpec matching_module_spec; if (!modules_specs.FindMatchingModuleSpec(module_spec, matching_module_spec)) { - if (log) { - LLDB_LOGF(log, "Found local object file but the specs didn't match"); - } + LLDB_LOGF(log, "Found local object file but the specs didn't match"); return; } @@ -252,11 +249,10 @@ Module::Module(const FileSpec &file_spec, const ArchSpec &arch, } Log *log(GetLog(LLDBLog::Object | LLDBLog::Modules)); - if (log != nullptr) - LLDB_LOGF(log, "%p Module::Module((%s) '%s%s%s%s')", - static_cast(this), m_arch.GetArchitectureName(), - m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(", - m_object_name.AsCString(""), m_object_name.IsEmpty() ? "" : ")"); + LLDB_LOGF(log, "%p Module::Module((%s) '%s%s%s%s')", + static_cast(this), m_arch.GetArchitectureName(), + m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(", + m_object_name.AsCString(""), m_object_name.IsEmpty() ? "" : ")"); } Module::Module() @@ -282,11 +278,10 @@ Module::~Module() { modules.erase(pos); } Log *log(GetLog(LLDBLog::Object | LLDBLog::Modules)); - if (log != nullptr) - LLDB_LOGF(log, "%p Module::~Module((%s) '%s%s%s%s')", - static_cast(this), m_arch.GetArchitectureName(), - m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(", - m_object_name.AsCString(""), m_object_name.IsEmpty() ? "" : ")"); + LLDB_LOGF(log, "%p Module::~Module((%s) '%s%s%s%s')", + static_cast(this), m_arch.GetArchitectureName(), + m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(", + m_object_name.AsCString(""), m_object_name.IsEmpty() ? "" : ")"); // Release any auto pointers before we start tearing down our member // variables since the object file and symbol files might need to make // function calls back into this module object. The ordering is important diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 608d13c2a9fe..b54d787de351 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -1088,11 +1088,10 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp, old_modules->push_back(module_sp); Log *log = GetLog(LLDBLog::Modules); - if (log != nullptr) - LLDB_LOGF( - log, "%p '%s' module changed: removing from global module list", - static_cast(module_sp.get()), - module_sp->GetFileSpec().GetFilename().GetCString()); + LLDB_LOGF(log, + "%p '%s' module changed: removing from global module list", + static_cast(module_sp.get()), + module_sp->GetFileSpec().GetFilename().GetCString()); shared_module_list.Remove(module_sp); module_sp.reset(); diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 476420c87a62..4984e8756c23 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -658,12 +658,10 @@ ImplSP FormatManager::GetCached(FormattersMatchData &match_data) { LLDB_LOGF(log, "\n\n" FORMAT_LOG("Looking into cache for type %s"), match_data.GetTypeForCache().AsCString("")); if (m_format_cache.Get(match_data.GetTypeForCache(), retval_sp)) { - if (log) { - LLDB_LOGF(log, FORMAT_LOG("Cache search success. Returning.")); - LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}", - m_format_cache.GetCacheHits(), - m_format_cache.GetCacheMisses()); - } + LLDB_LOGF(log, FORMAT_LOG("Cache search success. Returning.")); + LLDB_LOG_VERBOSE(log, "Cache hits: {0} - Cache Misses: {1}", + m_format_cache.GetCacheHits(), + m_format_cache.GetCacheMisses()); return retval_sp; } LLDB_LOGF(log, FORMAT_LOG("Cache search failed. Going normal route")); @@ -676,8 +674,9 @@ ImplSP FormatManager::GetCached(FormattersMatchData &match_data) { match_data.GetTypeForCache().AsCString("")); m_format_cache.Set(match_data.GetTypeForCache(), retval_sp); } - LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}", - m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses()); + LLDB_LOG_VERBOSE(log, "Cache hits: {0} - Cache Misses: {1}", + m_format_cache.GetCacheHits(), + m_format_cache.GetCacheMisses()); return retval_sp; } diff --git a/lldb/source/DataFormatters/FormatterBytecode.cpp b/lldb/source/DataFormatters/FormatterBytecode.cpp index 9a1e74e4afa6..ab6d826d5ff8 100644 --- a/lldb/source/DataFormatters/FormatterBytecode.cpp +++ b/lldb/source/DataFormatters/FormatterBytecode.cpp @@ -222,9 +222,10 @@ llvm::Error Interpret(ControlStack &control, DataStack &data, Signatures sig) { if (control.empty() || !pc) return pc.takeError(); - LLDB_LOGV(GetLog(LLDBLog::DataFormatters), - "[eval {0}] opcode={1}, control={2}, data={3}", toString(sig), - toString(opcode), control.size(), toString(data)); + LLDB_LOG_VERBOSE(GetLog(LLDBLog::DataFormatters), + "[eval {0}] opcode={1}, control={2}, data={3}", + toString(sig), toString(opcode), control.size(), + toString(data)); // Various shorthands to improve the readability of error handling. #define TYPE_CHECK(...) \ diff --git a/lldb/source/Expression/FunctionCaller.cpp b/lldb/source/Expression/FunctionCaller.cpp index 6c93d94f691c..6ea3faee9868 100644 --- a/lldb/source/Expression/FunctionCaller.cpp +++ b/lldb/source/Expression/FunctionCaller.cpp @@ -387,18 +387,16 @@ lldb::ExpressionResults FunctionCaller::ExecuteFunction( return_value = exe_ctx.GetProcessRef().RunThreadPlan( exe_ctx, call_plan_sp, real_options, diagnostic_manager); - if (log) { - if (return_value != lldb::eExpressionCompleted) { - LLDB_LOGF(log, - "== [FunctionCaller::ExecuteFunction] Execution of \"%s\" " - "completed abnormally: %s ==", - m_name.c_str(), toString(return_value).c_str()); - } else { - LLDB_LOGF(log, - "== [FunctionCaller::ExecuteFunction] Execution of \"%s\" " - "completed normally ==", - m_name.c_str()); - } + if (return_value != lldb::eExpressionCompleted) { + LLDB_LOGF(log, + "== [FunctionCaller::ExecuteFunction] Execution of \"%s\" " + "completed abnormally: %s ==", + m_name.c_str(), toString(return_value).c_str()); + } else { + LLDB_LOGF(log, + "== [FunctionCaller::ExecuteFunction] Execution of \"%s\" " + "completed normally ==", + m_name.c_str()); } if (exe_ctx.GetProcessPtr()) diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp index 9b3936d065cb..69e7d0b32780 100644 --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -356,13 +356,10 @@ public: lldb_private::Log *log(GetLog(LLDBLog::Expressions)); - if (log) { - LLDB_LOGF(log, "Made an allocation for argument %s", - PrintValue(value).c_str()); - LLDB_LOGF(log, " Data region : %llx", (unsigned long long)address); - LLDB_LOGF(log, " Ref region : %llx", - (unsigned long long)data_address); - } + LLDB_LOGF(log, "Made an allocation for argument %s", + PrintValue(value).c_str()); + LLDB_LOGF(log, " Data region : %llx", (unsigned long long)address); + LLDB_LOGF(log, " Ref region : %llx", (unsigned long long)data_address); return true; } @@ -889,12 +886,10 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, result, module); - if (log) { - LLDB_LOGF(log, "Interpreted a %s", inst->getOpcodeName()); - LLDB_LOGF(log, " L : %s", frame.SummarizeValue(lhs).c_str()); - LLDB_LOGF(log, " R : %s", frame.SummarizeValue(rhs).c_str()); - LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); - } + LLDB_LOGF(log, "Interpreted a %s", inst->getOpcodeName()); + LLDB_LOGF(log, " L : %s", frame.SummarizeValue(lhs).c_str()); + LLDB_LOGF(log, " R : %s", frame.SummarizeValue(rhs).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } break; case Instruction::Alloca: { const AllocaInst *alloca_inst = cast(inst); @@ -949,11 +944,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.m_values[alloca_inst] = P; - if (log) { - LLDB_LOGF(log, "Interpreted an AllocaInst"); - LLDB_LOGF(log, " R : 0x%" PRIx64, R); - LLDB_LOGF(log, " P : 0x%" PRIx64, P); - } + LLDB_LOGF(log, "Interpreted an AllocaInst"); + LLDB_LOGF(log, " R : 0x%" PRIx64, R); + LLDB_LOGF(log, " P : 0x%" PRIx64, P); } break; case Instruction::BitCast: case Instruction::ZExt: { @@ -992,9 +985,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, } break; case Instruction::UncondBr: frame.Jump(cast(inst)->getSuccessor()); - if (log) { - LLDB_LOGF(log, "Interpreted an UncondBrInst"); - } + LLDB_LOGF(log, "Interpreted an UncondBrInst"); continue; case Instruction::CondBr: { const CondBrInst *br_inst = cast(inst); @@ -1014,10 +1005,8 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, else frame.Jump(br_inst->getSuccessor(1)); - if (log) { - LLDB_LOGF(log, "Interpreted a CondBrInst"); - LLDB_LOGF(log, " cond : %s", frame.SummarizeValue(condition).c_str()); - } + LLDB_LOGF(log, "Interpreted a CondBrInst"); + LLDB_LOGF(log, " cond : %s", frame.SummarizeValue(condition).c_str()); } continue; case Instruction::PHI: { @@ -1040,11 +1029,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, } frame.AssignValue(inst, result, module); - if (log) { - LLDB_LOGF(log, "Interpreted a %s", inst->getOpcodeName()); - LLDB_LOGF(log, " Incoming value : %s", - frame.SummarizeValue(value).c_str()); - } + LLDB_LOGF(log, "Interpreted a %s", inst->getOpcodeName()); + LLDB_LOGF(log, " Incoming value : %s", + frame.SummarizeValue(value).c_str()); } break; case Instruction::GetElementPtr: { const GetElementPtrInst *gep_inst = cast(inst); @@ -1099,12 +1086,10 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, Poffset, module); - if (log) { - LLDB_LOGF(log, "Interpreted a GetElementPtrInst"); - LLDB_LOGF(log, " P : %s", - frame.SummarizeValue(pointer_operand).c_str()); - LLDB_LOGF(log, " Poffset : %s", frame.SummarizeValue(inst).c_str()); - } + LLDB_LOGF(log, "Interpreted a GetElementPtrInst"); + LLDB_LOGF(log, " P : %s", + frame.SummarizeValue(pointer_operand).c_str()); + LLDB_LOGF(log, " Poffset : %s", frame.SummarizeValue(inst).c_str()); } break; case Instruction::FCmp: case Instruction::ICmp: { @@ -1199,12 +1184,10 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, result, module); - if (log) { - LLDB_LOGF(log, "Interpreted an ICmpInst"); - LLDB_LOGF(log, " L : %s", frame.SummarizeValue(lhs).c_str()); - LLDB_LOGF(log, " R : %s", frame.SummarizeValue(rhs).c_str()); - LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); - } + LLDB_LOGF(log, "Interpreted an ICmpInst"); + LLDB_LOGF(log, " L : %s", frame.SummarizeValue(lhs).c_str()); + LLDB_LOGF(log, " R : %s", frame.SummarizeValue(rhs).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } break; case Instruction::IntToPtr: { const IntToPtrInst *int_to_ptr_inst = cast(inst); @@ -1221,11 +1204,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, I, module); - if (log) { - LLDB_LOGF(log, "Interpreted an IntToPtr"); - LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); - LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); - } + LLDB_LOGF(log, "Interpreted an IntToPtr"); + LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } break; case Instruction::PtrToInt: { const PtrToIntInst *ptr_to_int_inst = cast(inst); @@ -1242,11 +1223,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, I, module); - if (log) { - LLDB_LOGF(log, "Interpreted a PtrToInt"); - LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); - LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); - } + LLDB_LOGF(log, "Interpreted a PtrToInt"); + LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } break; case Instruction::Trunc: { const TruncInst *trunc_inst = cast(inst); @@ -1263,11 +1242,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, I, module); - if (log) { - LLDB_LOGF(log, "Interpreted a Trunc"); - LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); - LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); - } + LLDB_LOGF(log, "Interpreted a Trunc"); + LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } break; case Instruction::FPToUI: case Instruction::FPToSI: { @@ -1305,11 +1282,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::Scalar R(result); frame.AssignValue(inst, R, module); - if (log) { - LLDB_LOGF(log, "Interpreted a %s", inst->getOpcodeName()); - LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); - LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); - } + LLDB_LOGF(log, "Interpreted a %s", inst->getOpcodeName()); + LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } break; case Instruction::UIToFP: case Instruction::SIToFP: @@ -1335,11 +1310,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, R = S.Double(); frame.AssignValue(inst, R, module); - if (log) { - LLDB_LOGF(log, "Interpreted a %s", inst->getOpcodeName()); - LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); - LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); - } + LLDB_LOGF(log, "Interpreted a %s", inst->getOpcodeName()); + LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } break; case Instruction::Load: { const LoadInst *load_inst = cast(inst); @@ -1399,12 +1372,10 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, return false; } - if (log) { - LLDB_LOGF(log, "Interpreted a LoadInst"); - LLDB_LOGF(log, " P : 0x%" PRIx64, P); - LLDB_LOGF(log, " R : 0x%" PRIx64, R); - LLDB_LOGF(log, " D : 0x%" PRIx64, D); - } + LLDB_LOGF(log, "Interpreted a LoadInst"); + LLDB_LOGF(log, " P : 0x%" PRIx64, P); + LLDB_LOGF(log, " R : 0x%" PRIx64, R); + LLDB_LOGF(log, " D : 0x%" PRIx64, D); } break; case Instruction::Ret: { return true; @@ -1468,12 +1439,10 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, return false; } - if (log) { - LLDB_LOGF(log, "Interpreted a StoreInst"); - LLDB_LOGF(log, " D : 0x%" PRIx64, D); - LLDB_LOGF(log, " P : 0x%" PRIx64, P); - LLDB_LOGF(log, " R : 0x%" PRIx64, R); - } + LLDB_LOGF(log, "Interpreted a StoreInst"); + LLDB_LOGF(log, " D : 0x%" PRIx64, D); + LLDB_LOGF(log, " P : 0x%" PRIx64, P); + LLDB_LOGF(log, " R : 0x%" PRIx64, R); } break; case Instruction::Call: { const CallInst *call_inst = cast(inst); diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 771a9ab84a20..98c921493d97 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -164,14 +164,12 @@ public: const lldb::addr_t load_addr = process_address + m_offset; - if (log) { - LLDB_LOGF(log, - "EntityPersistentVariable::Materialize [address = 0x%" PRIx64 - ", m_name = %s, m_flags = 0x%hx]", - (uint64_t)load_addr, - m_persistent_variable_sp->GetName().AsCString(), - m_persistent_variable_sp->m_flags); - } + LLDB_LOGF(log, + "EntityPersistentVariable::Materialize [address = 0x%" PRIx64 + ", m_name = %s, m_flags = 0x%hx]", + (uint64_t)load_addr, + m_persistent_variable_sp->GetName().AsCString(), + m_persistent_variable_sp->m_flags); if (m_persistent_variable_sp->m_flags & ExpressionVariable::EVNeedsAllocation) { @@ -216,14 +214,12 @@ public: const lldb::addr_t load_addr = process_address + m_offset; - if (log) { - LLDB_LOGF(log, - "EntityPersistentVariable::Dematerialize [address = 0x%" PRIx64 - ", m_name = %s, m_flags = 0x%hx]", - (uint64_t)process_address + m_offset, - m_persistent_variable_sp->GetName().AsCString(), - m_persistent_variable_sp->m_flags); - } + LLDB_LOGF(log, + "EntityPersistentVariable::Dematerialize [address = 0x%" PRIx64 + ", m_name = %s, m_flags = 0x%hx]", + (uint64_t)process_address + m_offset, + m_persistent_variable_sp->GetName().AsCString(), + m_persistent_variable_sp->m_flags); if (m_delegate) { m_delegate->DidDematerialize(m_persistent_variable_sp); @@ -449,12 +445,10 @@ public: Log *log = GetLog(LLDBLog::Expressions); const lldb::addr_t load_addr = process_address + m_offset; - if (log) { - LLDB_LOGF(log, - "EntityVariable::Materialize [address = 0x%" PRIx64 - ", m_variable_sp = %s]", - (uint64_t)load_addr, GetName().GetCString()); - } + LLDB_LOGF(log, + "EntityVariable::Materialize [address = 0x%" PRIx64 + ", m_variable_sp = %s]", + (uint64_t)load_addr, GetName().GetCString()); ExecutionContextScope *scope = frame_sp.get(); @@ -612,12 +606,10 @@ public: Log *log = GetLog(LLDBLog::Expressions); const lldb::addr_t load_addr = process_address + m_offset; - if (log) { - LLDB_LOGF(log, - "EntityVariable::Dematerialize [address = 0x%" PRIx64 - ", m_variable_sp = %s]", - (uint64_t)load_addr, GetName().AsCString()); - } + LLDB_LOGF(log, + "EntityVariable::Dematerialize [address = 0x%" PRIx64 + ", m_variable_sp = %s]", + (uint64_t)load_addr, GetName().AsCString()); if (m_temporary_allocation != LLDB_INVALID_ADDRESS) { ExecutionContextScope *scope = frame_sp.get(); @@ -1234,12 +1226,10 @@ public: const lldb::addr_t load_addr = process_address + m_offset; - if (log) { - LLDB_LOGF(log, - "EntitySymbol::Materialize [address = 0x%" PRIx64 - ", m_symbol = %s]", - (uint64_t)load_addr, m_symbol.GetName().AsCString()); - } + LLDB_LOGF(log, + "EntitySymbol::Materialize [address = 0x%" PRIx64 + ", m_symbol = %s]", + (uint64_t)load_addr, m_symbol.GetName().AsCString()); const Address sym_address = m_symbol.GetAddress(); @@ -1283,12 +1273,10 @@ public: const lldb::addr_t load_addr = process_address + m_offset; - if (log) { - LLDB_LOGF(log, - "EntitySymbol::Dematerialize [address = 0x%" PRIx64 - ", m_symbol = %s]", - (uint64_t)load_addr, m_symbol.GetName().AsCString()); - } + LLDB_LOGF(log, + "EntitySymbol::Dematerialize [address = 0x%" PRIx64 + ", m_symbol = %s]", + (uint64_t)load_addr, m_symbol.GetName().AsCString()); // no work needs to be done } @@ -1353,12 +1341,10 @@ public: const lldb::addr_t load_addr = process_address + m_offset; - if (log) { - LLDB_LOGF(log, - "EntityRegister::Materialize [address = 0x%" PRIx64 - ", m_register_info = %s]", - (uint64_t)load_addr, m_register_info.name); - } + LLDB_LOGF(log, + "EntityRegister::Materialize [address = 0x%" PRIx64 + ", m_register_info = %s]", + (uint64_t)load_addr, m_register_info.name); RegisterValue reg_value; @@ -1413,12 +1399,10 @@ public: const lldb::addr_t load_addr = process_address + m_offset; - if (log) { - LLDB_LOGF(log, - "EntityRegister::Dematerialize [address = 0x%" PRIx64 - ", m_register_info = %s]", - (uint64_t)load_addr, m_register_info.name); - } + LLDB_LOGF(log, + "EntityRegister::Dematerialize [address = 0x%" PRIx64 + ", m_register_info = %s]", + (uint64_t)load_addr, m_register_info.name); Status extract_error; diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index eb333f7e7439..48191b4d1ca8 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -329,16 +329,13 @@ Status Socket::Read(void *buf, size_t &num_bytes) { } else num_bytes = bytes_received; - Log *log = GetLog(LLDBLog::Communication); - if (log) { - LLDB_LOGF(log, - "%p Socket::Read() (socket = %" PRIu64 - ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64 - " (error = %s)", - static_cast(this), static_cast(m_socket), buf, - static_cast(num_bytes), - static_cast(bytes_received), error.AsCString()); - } + LLDB_LOGF(GetLog(LLDBLog::Communication), + "%p Socket::Read() (socket = %" PRIu64 + ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64 + " (error = %s)", + static_cast(this), static_cast(m_socket), buf, + static_cast(num_bytes), + static_cast(bytes_received), error.AsCString()); return error; } @@ -357,16 +354,13 @@ Status Socket::Write(const void *buf, size_t &num_bytes) { } else num_bytes = bytes_sent; - Log *log = GetLog(LLDBLog::Communication); - if (log) { - LLDB_LOGF(log, - "%p Socket::Write() (socket = %" PRIu64 - ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64 - " (error = %s)", - static_cast(this), static_cast(m_socket), buf, - static_cast(src_len), static_cast(bytes_sent), - error.AsCString()); - } + LLDB_LOGF(GetLog(LLDBLog::Communication), + "%p Socket::Write() (socket = %" PRIu64 + ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64 + " (error = %s)", + static_cast(this), static_cast(m_socket), buf, + static_cast(src_len), static_cast(bytes_sent), + error.AsCString()); return error; } diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm index d60b551765d9..fd0c11197fc6 100644 --- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -831,13 +831,10 @@ static DataExtractorSP map_shared_cache_binary_segments(void *image) { "map_shared_cache_binary_segments() mapping segments of " "dyld_image_t %p into lldb address space", image); - bool log_verbosely = log && log->GetVerbose(); for (const segment &seg : segments) { - if (log_verbosely) - LLDB_LOGF( - log, - "image %p %s vmaddr 0x%llx vmsize 0x%zx mapped to lldb vm addr %p", - image, seg.name.c_str(), seg.vmaddr, seg.vmsize, seg.data); + LLDB_LOGF_VERBOSE( + log, "image %p %s vmaddr 0x%llx vmsize 0x%zx mapped to lldb vm addr %p", + image, seg.name.c_str(), seg.vmaddr, seg.vmsize, seg.data); } // Calculate the virtual address range in lldb's @@ -915,9 +912,8 @@ bool SharedCacheInfo::CreateSharedCacheImageList(UUID sc_uuid, // ensure lifetime. ConstString installname(dyld_image_get_installname(image)); Log *log = GetLog(LLDBLog::Modules); - if (log && log->GetVerbose()) - LLDB_LOGF(log, "sc file %s image %p", installname.GetCString(), - (void *)image); + LLDB_LOGF_VERBOSE(log, "sc file %s image %p", installname.GetCString(), + (void *)image); m_dyld_image_retain_4HWTrace(image); m_file_infos[sc_uuid].push_back(SharedCacheImageInfo( diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index b5831f013ba6..e65a67fe1bd1 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -210,7 +210,7 @@ ConnectionStatus ConnectionFileDescriptor::Disconnect(Status *error_ptr) { "{0}: Couldn't get the lock, sent 'q' to {1}, error = '{2}'.", this, m_pipe.GetWriteFileDescriptor(), err); consumeError(std::move(err)); - } else if (log) { + } else { LLDB_LOGF(log, "%p ConnectionFileDescriptor::Disconnect(): Couldn't get the " "lock, but no command pipe is available.", @@ -271,13 +271,11 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, size_t bytes_read = dst_len; error = m_io_sp->Read(dst, bytes_read); - if (log) { - LLDB_LOG(log, - "{0} ConnectionFileDescriptor::Read() fd = {1}" - ", dst = {2}, dst_len = {3}) => {4}, error = {5}", - this, m_io_sp->GetWaitableHandle(), dst, dst_len, bytes_read, - error.AsCString()); - } + LLDB_LOG(log, + "{0} ConnectionFileDescriptor::Read() fd = {1}" + ", dst = {2}, dst_len = {3}) => {4}, error = {5}", + this, m_io_sp->GetWaitableHandle(), dst, dst_len, bytes_read, + error.AsCString()); if (bytes_read == 0) { error.Clear(); // End-of-file. Do not automatically close; pass along for @@ -373,13 +371,11 @@ size_t ConnectionFileDescriptor::Write(const void *src, size_t src_len, size_t bytes_sent = src_len; error = m_io_sp->Write(src, bytes_sent); - if (log) { - LLDB_LOG(log, - "{0} ConnectionFileDescriptor::Write(fd = {1}" - ", src = {2}, src_len = {3}) => {4} (error = {5})", - this, m_io_sp->GetWaitableHandle(), src, src_len, bytes_sent, - error.AsCString()); - } + LLDB_LOG(log, + "{0} ConnectionFileDescriptor::Write(fd = {1}" + ", src = {2}, src_len = {3}) => {4} (error = {5})", + this, m_io_sp->GetWaitableHandle(), src, src_len, bytes_sent, + error.AsCString()); if (error_ptr) *error_ptr = error.Clone(); diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 4e9b1389a11a..5d8c430e6922 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -690,14 +690,12 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule( // something has gone wrong and we should discard it. if (m_uuid.IsValid()) { if (m_uuid != memory_module_sp->GetUUID()) { - if (log) { - LLDB_LOGF(log, - "KextImageInfo::ReadMemoryModule the kernel said to find " - "uuid %s at 0x%" PRIx64 - " but instead we found uuid %s, throwing it away", - m_uuid.GetAsString().c_str(), m_load_address, - memory_module_sp->GetUUID().GetAsString().c_str()); - } + LLDB_LOGF(log, + "KextImageInfo::ReadMemoryModule the kernel said to find " + "uuid %s at 0x%" PRIx64 + " but instead we found uuid %s, throwing it away", + m_uuid.GetAsString().c_str(), m_load_address, + memory_module_sp->GetUUID().GetAsString().c_str()); return false; } } @@ -710,12 +708,9 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule( m_memory_module_sp = memory_module_sp; m_kernel_image = this_is_kernel; if (this_is_kernel) { - if (log) { - // This is unusual and probably not intended - LLDB_LOGF(log, - "KextImageInfo::ReadMemoryModule read the kernel binary out " - "of memory"); - } + // This is unusual and probably not intended + LLDB_LOGF(log, "KextImageInfo::ReadMemoryModule read the kernel binary out " + "of memory"); if (memory_module_sp->GetArchitecture().IsValid()) { process->GetTarget().SetArchitecture(memory_module_sp->GetArchitecture()); } @@ -1362,20 +1357,18 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries( } } - if (log) { - if (load_kexts) { - LLDB_LOGF(log, - "DynamicLoaderDarwinKernel::ParseKextSummaries: %d kexts " - "added, %d kexts removed", - number_of_new_kexts_being_added, - number_of_old_kexts_being_removed); - } else { - LLDB_LOGF(log, - "DynamicLoaderDarwinKernel::ParseKextSummaries kext loading is " - "disabled, else would have %d kexts added, %d kexts removed", - number_of_new_kexts_being_added, - number_of_old_kexts_being_removed); - } + if (load_kexts) { + LLDB_LOGF(log, + "DynamicLoaderDarwinKernel::ParseKextSummaries: %d kexts " + "added, %d kexts removed", + number_of_new_kexts_being_added, + number_of_old_kexts_being_removed); + } else { + LLDB_LOGF(log, + "DynamicLoaderDarwinKernel::ParseKextSummaries kext loading is " + "disabled, else would have %d kexts added, %d kexts removed", + number_of_new_kexts_being_added, + number_of_old_kexts_being_removed); } // Build up a list of for any kexts that fail to load diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp index 66860f829add..2d010db96070 100644 --- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp @@ -364,13 +364,11 @@ void DynamicLoaderHexagonDYLD::RefreshModules() { new_modules.Append(module_sp); } - if (log) { - LLDB_LOGF(log, "Target is loading '%s'", I->path.c_str()); - if (!module_sp.get()) - LLDB_LOGF(log, "LLDB failed to load '%s'", I->path.c_str()); - else - LLDB_LOGF(log, "LLDB successfully loaded '%s'", I->path.c_str()); - } + LLDB_LOGF(log, "Target is loading '%s'", I->path.c_str()); + if (!module_sp.get()) + LLDB_LOGF(log, "LLDB failed to load '%s'", I->path.c_str()); + else + LLDB_LOGF(log, "LLDB successfully loaded '%s'", I->path.c_str()); } m_process->GetTarget().ModulesDidLoad(new_modules); } diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index eb9f49aef206..f03e5bdf4276 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -655,7 +655,7 @@ std::optional DynamicLoaderDarwin::GetStartAddress() { Log *log = GetLog(LLDBLog::DynamicLoader); auto log_err = [log](llvm::StringLiteral err_msg) -> std::nullopt_t { - LLDB_LOGV(log, "{}", err_msg); + LLDB_LOG_VERBOSE(log, "{}", err_msg); return std::nullopt; }; @@ -846,17 +846,14 @@ bool DynamicLoaderDarwin::AlwaysRelyOnEHUnwindInfo(SymbolContext &sym_ctx) { // Dump a Segment to the file handle provided. void DynamicLoaderDarwin::Segment::PutToLog(Log *log, lldb::addr_t slide) const { - if (log) { - if (slide == 0) - LLDB_LOGF(log, "\t\t%16s [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 ")", - name.AsCString(""), vmaddr + slide, vmaddr + slide + vmsize); - else - LLDB_LOGF(log, - "\t\t%16s [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 - ") slide = 0x%" PRIx64, - name.AsCString(""), vmaddr + slide, vmaddr + slide + vmsize, - slide); - } + if (slide == 0) + LLDB_LOGF(log, "\t\t%16s [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 ")", + name.AsCString(""), vmaddr + slide, vmaddr + slide + vmsize); + else + LLDB_LOGF( + log, + "\t\t%16s [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 ") slide = 0x%" PRIx64, + name.AsCString(""), vmaddr + slide, vmaddr + slide + vmsize, slide); } lldb_private::ArchSpec DynamicLoaderDarwin::ImageInfo::GetArchitecture() const { diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index 65c8d3e1305a..78a9e9e35a4e 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -193,8 +193,9 @@ TagDecl *ClangASTSource::FindCompleteType(const TagDecl *decl) { if (!namespace_map) return nullptr; - LLDB_LOGV(log, " CTD Inspecting namespace map{0:x} ({1} entries)", - namespace_map.get(), namespace_map->size()); + LLDB_LOG_VERBOSE(log, + " CTD Inspecting namespace map{0:x} ({1} entries)", + namespace_map.get(), namespace_map->size()); for (const ClangASTImporter::NamespaceMapItem &item : *namespace_map) { LLDB_LOG(log, " CTD Searching namespace {0} in module {1}", @@ -262,15 +263,13 @@ TagDecl *ClangASTSource::FindCompleteType(const TagDecl *decl) { void ClangASTSource::CompleteType(TagDecl *tag_decl) { Log *log = GetLog(LLDBLog::Expressions); - if (log) { - LLDB_LOG(log, - " CompleteTagDecl on (ASTContext*){0} Completing " - "(TagDecl*){1:x} named {2}", - m_clang_ast_context->getDisplayName(), tag_decl, - tag_decl->getName()); + LLDB_LOG(log, + " CompleteTagDecl on (ASTContext*){0} Completing " + "(TagDecl*){1:x} named {2}", + m_clang_ast_context->getDisplayName(), tag_decl, + tag_decl->getName()); - LLDB_LOG(log, " CTD Before:\n{0}", ClangUtil::DumpDecl(tag_decl)); - } + LLDB_LOG(log, " CTD Before:\n{0}", ClangUtil::DumpDecl(tag_decl)); auto iter = m_active_lexical_decls.find(tag_decl); if (iter != m_active_lexical_decls.end()) @@ -541,9 +540,9 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) { } if (!context.m_namespace_map->empty()) { - if (log && log->GetVerbose()) - LLDB_LOG(log, " CAS::FEVD Registering namespace map {0:x} ({1} entries)", - context.m_namespace_map.get(), context.m_namespace_map->size()); + LLDB_LOG_VERBOSE( + log, " CAS::FEVD Registering namespace map {0:x} ({1} entries)", + context.m_namespace_map.get(), context.m_namespace_map->size()); NamespaceDecl *clang_namespace_decl = AddNamespace(context); @@ -1329,8 +1328,9 @@ void ClangASTSource::LookupInNamespace(NameSearchContext &context) { ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer_sp->GetNamespaceMap(namespace_context); - LLDB_LOGV(log, " CAS::FEVD Inspecting namespace map {0:x} ({1} entries)", - namespace_map.get(), namespace_map->size()); + LLDB_LOG_VERBOSE(log, + " CAS::FEVD Inspecting namespace map {0:x} ({1} entries)", + namespace_map.get(), namespace_map->size()); if (!namespace_map) return; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index de6bec592df5..d04981191e6c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -705,8 +705,9 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( if (!namespace_map) return; - LLDB_LOGV(log, " CEDM::FEVD Inspecting (NamespaceMap*){0:x} ({1} entries)", - namespace_map.get(), namespace_map->size()); + LLDB_LOG_VERBOSE( + log, " CEDM::FEVD Inspecting (NamespaceMap*){0:x} ({1} entries)", + namespace_map.get(), namespace_map->size()); for (ClangASTImporter::NamespaceMapItem &n : *namespace_map) { LLDB_LOG(log, " CEDM::FEVD Searching namespace {0} in module {1}", diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 176eddf65e91..5ee209a73195 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -776,18 +776,15 @@ ClangExpressionParser::ClangExpressionParser( if (auto *target_info = TargetInfo::CreateTargetInfo( m_compiler->getDiagnostics(), m_compiler->getInvocation().getTargetOpts())) { - if (log) { - LLDB_LOGF(log, "Target datalayout string: '%s'", - target_info->getDataLayoutString()); - LLDB_LOGF(log, "Target ABI: '%s'", target_info->getABI().str().c_str()); - LLDB_LOGF(log, "Target vector alignment: %d", - target_info->getMaxVectorAlign()); - } + LLDB_LOGF(log, "Target datalayout string: '%s'", + target_info->getDataLayoutString()); + LLDB_LOGF(log, "Target ABI: '%s'", target_info->getABI().str().c_str()); + LLDB_LOGF(log, "Target vector alignment: %d", + target_info->getMaxVectorAlign()); m_compiler->setTarget(target_info); } else { - if (log) - LLDB_LOGF(log, "Failed to create TargetInfo for '%s'", - m_compiler->getTargetOpts().Triple.c_str()); + LLDB_LOGF(log, "Failed to create TargetInfo for '%s'", + m_compiler->getTargetOpts().Triple.c_str()); lldbassert(false && "Failed to create TargetInfo."); } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index 03ef2116bcae..f830aad45ec9 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -506,8 +506,8 @@ CppModuleConfiguration GetModuleConfig(lldb::LanguageType language, files.GetSize()); if (log && log->GetVerbose()) { for (auto &f : files) - LLDB_LOGV(log, "[C++ module config] Analyzing support file: {0}", - f.GetPath()); + LLDB_LOG_VERBOSE(log, "[C++ module config] Analyzing support file: {0}", + f.GetPath()); } // Try to create a configuration from the files. If there is no valid diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp index 4259b100e09f..797abd8b0aa1 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp @@ -130,14 +130,12 @@ ItaniumABIRuntime::GetTypeInfo(ValueObject &in_value, } } - if (log) { - LLDB_LOGF(log, - "0x%16.16" PRIx64 - ": static-type = '%s' has multiple matching dynamic " - "types, didn't find a C++ match\n", - in_value.GetPointerValue().address, - in_value.GetTypeName().AsCString()); - } + LLDB_LOGF(log, + "0x%16.16" PRIx64 + ": static-type = '%s' has multiple matching dynamic " + "types, didn't find a C++ match\n", + in_value.GetPointerValue().address, + in_value.GetTypeName().AsCString()); } if (type_info) SetDynamicTypeInfo(vtable_info.addr, type_info); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp index 430f4f0ebc21..d994cb4ab13d 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp @@ -747,7 +747,7 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime, return; std::lock_guard guard(m_mutex); Log *log = GetLog(LLDBLog::Types); - LLDB_LOGV(log, "class_name = {0}", descriptor.GetClassName()); + LLDB_LOG_VERBOSE(log, "class_name = {0}", descriptor.GetClassName()); m_filled = true; ObjCLanguageRuntime::EncodingToTypeSP encoding_to_type_sp( runtime.GetEncodingToType()); @@ -762,16 +762,18 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime, uint64_t size) -> bool { const bool for_expression = false; const bool stop_loop = false; - LLDB_LOGV(log, "name = {0}, encoding = {1}, offset_ptr = {2:x}, size = {3}", - name, type, offset_ptr, size); + LLDB_LOG_VERBOSE( + 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) { - LLDB_LOGV(log, - "name = {0}, encoding = {1}, offset_ptr = {2:x}, size = " - "{3}, type_size = {4}", - name, type, offset_ptr, size, - expectedToOptional(ivar_type.GetByteSize(nullptr)).value_or(0)); + LLDB_LOG_VERBOSE( + log, + "name = {0}, encoding = {1}, offset_ptr = {2:x}, size = " + "{3}, type_size = {4}", + name, type, offset_ptr, size, + expectedToOptional(ivar_type.GetByteSize(nullptr)).value_or(0)); Scalar offset_scalar; Status error; const int offset_ptr_size = 4; @@ -779,13 +781,13 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime, size_t read = process->ReadScalarIntegerFromMemory( offset_ptr, offset_ptr_size, is_signed, offset_scalar, error); if (error.Success() && 4 == read) { - LLDB_LOGV(log, "offset_ptr = {0:x} --> {1}", offset_ptr, - offset_scalar.SInt()); + LLDB_LOG_VERBOSE(log, "offset_ptr = {0:x} --> {1}", offset_ptr, + offset_scalar.SInt()); m_ivars.push_back( {ConstString(name), ivar_type, size, offset_scalar.SInt()}); } else - LLDB_LOGV(log, "offset_ptr = {0:x} --> read fail, read = %{1}", - offset_ptr, read); + LLDB_LOG_VERBOSE(log, "offset_ptr = {0:x} --> read fail, read = %{1}", + offset_ptr, read); } return stop_loop; }); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp index c2c1bbfb41b2..5302a17d8bf5 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp @@ -36,14 +36,12 @@ public: Log *log(GetLog( LLDBLog::Expressions)); // FIXME - a more appropriate log channel? - if (log) { - LLDB_LOGF(log, - "AppleObjCExternalASTSource::FindExternalVisibleDeclsByName" - " on (ASTContext*)%p Looking for %s in (%sDecl*)%p", - static_cast(&decl_ctx->getParentASTContext()), - name.getAsString().c_str(), decl_ctx->getDeclKindName(), - static_cast(decl_ctx)); - } + LLDB_LOGF(log, + "AppleObjCExternalASTSource::FindExternalVisibleDeclsByName" + " on (ASTContext*)%p Looking for %s in (%sDecl*)%p", + static_cast(&decl_ctx->getParentASTContext()), + name.getAsString().c_str(), decl_ctx->getDeclKindName(), + static_cast(decl_ctx)); do { const clang::ObjCInterfaceDecl *interface_decl = @@ -89,24 +87,20 @@ public: Log *log(GetLog( LLDBLog::Expressions)); // FIXME - a more appropriate log channel? - if (log) { - LLDB_LOGF(log, - "AppleObjCExternalASTSource::CompleteType on " - "(ASTContext*)%p Completing (ObjCInterfaceDecl*)%p named %s", - static_cast(&interface_decl->getASTContext()), - static_cast(interface_decl), - interface_decl->getName().str().c_str()); + LLDB_LOGF(log, + "AppleObjCExternalASTSource::CompleteType on " + "(ASTContext*)%p Completing (ObjCInterfaceDecl*)%p named %s", + static_cast(&interface_decl->getASTContext()), + static_cast(interface_decl), + interface_decl->getName().str().c_str()); - LLDB_LOGF(log, " AOEAS::CT Before:"); - LLDB_LOG(log, " [CT] {0}", ClangUtil::DumpDecl(interface_decl)); - } + LLDB_LOGF(log, " AOEAS::CT Before:"); + LLDB_LOG(log, " [CT] {0}", ClangUtil::DumpDecl(interface_decl)); m_decl_vendor.FinishDecl(interface_decl); - if (log) { - LLDB_LOGF(log, " [CT] After:"); - LLDB_LOG(log, " [CT] {0}", ClangUtil::DumpDecl(interface_decl)); - } + LLDB_LOGF(log, " [CT] After:"); + LLDB_LOG(log, " [CT] {0}", ClangUtil::DumpDecl(interface_decl)); } bool layoutRecordType( @@ -512,13 +506,10 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { class_method_func, ivar_func)) return false; - if (log) { - LLDB_LOGF( - log, - "[AppleObjCDeclVendor::FinishDecl] Finished Objective-C interface"); + LLDB_LOGF(log, + "[AppleObjCDeclVendor::FinishDecl] Finished Objective-C interface"); - LLDB_LOG(log, " [AOTV::FD] {0}", ClangUtil::DumpDecl(interface_decl)); - } + LLDB_LOG(log, " [AOTV::FD] {0}", ClangUtil::DumpDecl(interface_decl)); return true; } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp index b1f2a661c4af..2eac7bd8a4a5 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -380,12 +380,12 @@ void AppleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded() { ClassDescriptorSP descriptor_sp( new ClassDescriptorV1(isa, process_sp)); - if (log && log->GetVerbose()) - LLDB_LOGF(log, - "AppleObjCRuntimeV1 added (ObjCISA)0x%" PRIx64 - " from _objc_debug_class_hash to " - "isa->descriptor cache", - isa); + LLDB_LOGF_VERBOSE( + log, + "AppleObjCRuntimeV1 added (ObjCISA)0x%" PRIx64 + " from _objc_debug_class_hash to " + "isa->descriptor cache", + isa); AddClass(isa, descriptor_sp); } @@ -403,13 +403,12 @@ void AppleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded() { ClassDescriptorSP descriptor_sp( new ClassDescriptorV1(isa, process_sp)); - if (log && log->GetVerbose()) - LLDB_LOGF( - log, - "AppleObjCRuntimeV1 added (ObjCISA)0x%" PRIx64 - " from _objc_debug_class_hash to isa->descriptor " - "cache", - isa); + LLDB_LOGF_VERBOSE( + log, + "AppleObjCRuntimeV1 added (ObjCISA)0x%" PRIx64 + " from _objc_debug_class_hash to isa->descriptor " + "cache", + isa); AddClass(isa, descriptor_sp); } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp index 2b2ca080c7f5..ad163347b14c 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp @@ -65,12 +65,10 @@ void ObjCLanguageRuntime::AddToMethodCache(lldb::addr_t class_addr, lldb::addr_t selector, lldb::addr_t impl_addr) { Log *log = GetLog(LLDBLog::Step); - if (log) { - LLDB_LOGF(log, - "Caching: class 0x%" PRIx64 " selector 0x%" PRIx64 - " implementation 0x%" PRIx64 ".", - class_addr, selector, impl_addr); - } + LLDB_LOGF(log, + "Caching: class 0x%" PRIx64 " selector 0x%" PRIx64 + " implementation 0x%" PRIx64 ".", + class_addr, selector, impl_addr); m_impl_cache.insert(std::pair( ClassAndSel(class_addr, selector), impl_addr)); } diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index c36108773082..8fca95512ace 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp @@ -325,10 +325,8 @@ Status MinidumpFileBuilder::AddModuleList() { Log *log = GetLog(LLDBLog::Object); llvm::handleAllErrors( std::move(mod_size_err), [&](const llvm::ErrorInfoBase &E) { - if (log) { - LLDB_LOGF(log, "Unable to get the size of module %s: %s", - module_name.c_str(), E.message().c_str()); - } + LLDB_LOGF(log, "Unable to get the size of module %s: %s", + module_name.c_str(), E.message().c_str()); }); continue; } diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp index 26a507bbe131..393f3a3b7983 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp @@ -40,21 +40,17 @@ bool PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { FileSystem::Instance().Resolve(sdk_sysroot_fspec); const SDKDirectoryInfo sdk_sysroot_directory_info(sdk_sysroot_fspec); m_sdk_directory_infos.push_back(sdk_sysroot_directory_info); - if (log) { - LLDB_LOGF(log, - "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded added " - "--sysroot SDK directory %s", - m_sdk_sysroot.c_str()); - } + LLDB_LOGF(log, + "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded added " + "--sysroot SDK directory %s", + m_sdk_sysroot.c_str()); return true; } const char *device_support_dir = GetDeviceSupportDirectory(); - if (log) { - LLDB_LOGF(log, - "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded Got " - "DeviceSupport directory %s", - device_support_dir); - } + LLDB_LOGF(log, + "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded Got " + "DeviceSupport directory %s", + device_support_dir); if (device_support_dir) { const bool find_directories = true; const bool find_files = false; @@ -75,12 +71,10 @@ bool PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { sdk_symbols_symlink_fspec.AppendPathComponent("Symbols"); if (FileSystem::Instance().Exists(sdk_symbols_symlink_fspec)) { m_sdk_directory_infos.push_back(sdk_directory_info); - if (log) { - LLDB_LOGF(log, - "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded " - "added builtin SDK directory %s", - sdk_symbols_symlink_fspec.GetPath().c_str()); - } + LLDB_LOGF(log, + "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded " + "added builtin SDK directory %s", + sdk_symbols_symlink_fspec.GetPath().c_str()); } } @@ -91,12 +85,10 @@ bool PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { FileSpec local_sdk_cache(local_sdk_cache_str.c_str()); FileSystem::Instance().Resolve(local_sdk_cache); if (FileSystem::Instance().Exists(local_sdk_cache)) { - if (log) { - LLDB_LOGF(log, - "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded " - "searching %s for additional SDKs", - local_sdk_cache.GetPath().c_str()); - } + LLDB_LOGF(log, + "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded " + "searching %s for additional SDKs", + local_sdk_cache.GetPath().c_str()); char path[PATH_MAX]; if (local_sdk_cache.GetPath(path, sizeof(path))) { FileSystem::Instance().EnumerateDirectory( @@ -107,13 +99,11 @@ bool PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { // First try for an exact match of major, minor and update for (uint32_t i = num_installed; i < num_sdk_infos; ++i) { m_sdk_directory_infos[i].user_cached = true; - if (log) { - LLDB_LOGF(log, - "PlatformDarwinDevice::" - "UpdateSDKDirectoryInfosIfNeeded " - "user SDK directory %s", - m_sdk_directory_infos[i].directory.GetPath().c_str()); - } + LLDB_LOGF(log, + "PlatformDarwinDevice::" + "UpdateSDKDirectoryInfosIfNeeded " + "user SDK directory %s", + m_sdk_directory_infos[i].directory.GetPath().c_str()); } } } @@ -131,12 +121,10 @@ bool PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { sdk_symbols_symlink_fspec.AppendPathComponent("Symbols"); if (FileSystem::Instance().Exists(sdk_symbols_symlink_fspec)) { m_sdk_directory_infos.push_back(sdk_directory_info); - if (log) { - LLDB_LOGF(log, - "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded " - "added env var SDK directory %s", - sdk_symbols_symlink_fspec.GetPath().c_str()); - } + LLDB_LOGF(log, + "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded " + "added env var SDK directory %s", + sdk_symbols_symlink_fspec.GetPath().c_str()); } } } diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp index b19ddcc19e58..70c6380942ef 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -485,7 +485,7 @@ PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper( Log *log = GetLog(LLDBLog::Platform); - LLDB_LOGV(log, "PlatformDarwinKernel examining '{0}'", file_spec); + LLDB_LOG_VERBOSE(log, "PlatformDarwinKernel examining '{0}'", file_spec); PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton; @@ -564,8 +564,8 @@ PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper( // Don't recurse into dSYM/kext/bundle directories if (recurse && file_spec_extension != g_dsym_suffix && file_spec_extension != g_kext_suffix) { - LLDB_LOGV(log, "PlatformDarwinKernel descending into directory '{0}'", - file_spec); + LLDB_LOG_VERBOSE( + log, "PlatformDarwinKernel descending into directory '{0}'", file_spec); return FileSystem::eEnumerateDirectoryResultEnter; } else { return FileSystem::eEnumerateDirectoryResultNext; diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp index 2babfa0517ab..c519561b9e08 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp @@ -111,10 +111,8 @@ Status PlatformRemoteDarwinDevice::GetSymbolFile(const FileSpec &platform_file, local_file.SetFile(resolved_path, FileSpec::Style::native); FileSystem::Instance().Resolve(local_file); if (FileSystem::Instance().Exists(local_file)) { - if (log) { - LLDB_LOGF(log, "Found a copy of %s in the DeviceSupport dir %s", - platform_file_path, os_version_dir); - } + LLDB_LOGF(log, "Found a copy of %s in the DeviceSupport dir %s", + platform_file_path, os_version_dir); return error; } @@ -179,8 +177,8 @@ Status PlatformRemoteDarwinDevice::GetSharedModule( // directory using the OS build. const uint32_t connected_sdk_idx = GetConnectedSDKIndex(); if (connected_sdk_idx < num_sdk_infos) { - LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, - m_sdk_directory_infos[connected_sdk_idx].directory); + LLDB_LOG_VERBOSE(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(); @@ -196,8 +194,8 @@ Status PlatformRemoteDarwinDevice::GetSharedModule( // 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) { - LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, - m_sdk_directory_infos[m_last_module_sdk_idx].directory); + LLDB_LOG_VERBOSE(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(); @@ -218,8 +216,8 @@ Status PlatformRemoteDarwinDevice::GetSharedModule( GetSDKIndexBySDKDirectoryInfo(current_sdk_info); if (current_sdk_idx < num_sdk_infos && current_sdk_idx != m_last_module_sdk_idx) { - LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, - m_sdk_directory_infos[current_sdk_idx].directory); + LLDB_LOG_VERBOSE(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(); @@ -238,8 +236,8 @@ Status PlatformRemoteDarwinDevice::GetSharedModule( // Skip the last module SDK index if we already searched it above continue; } - LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file, - m_sdk_directory_infos[sdk_idx].directory); + LLDB_LOG_VERBOSE(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()); diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index e01bdee2f252..fe8e56b527a6 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -154,38 +154,38 @@ static void PtraceDisplayBytes(int &req, void *data, size_t data_size) { switch (req) { case PTRACE_POKETEXT: { DisplayBytes(buf, &data, 8); - LLDB_LOGV(log, "PTRACE_POKETEXT {0}", buf.GetData()); + LLDB_LOG_VERBOSE(log, "PTRACE_POKETEXT {0}", buf.GetData()); break; } case PTRACE_POKEDATA: { DisplayBytes(buf, &data, 8); - LLDB_LOGV(log, "PTRACE_POKEDATA {0}", buf.GetData()); + LLDB_LOG_VERBOSE(log, "PTRACE_POKEDATA {0}", buf.GetData()); break; } case PTRACE_POKEUSER: { DisplayBytes(buf, &data, 8); - LLDB_LOGV(log, "PTRACE_POKEUSER {0}", buf.GetData()); + LLDB_LOG_VERBOSE(log, "PTRACE_POKEUSER {0}", buf.GetData()); break; } case PTRACE_SETREGS: { DisplayBytes(buf, data, data_size); - LLDB_LOGV(log, "PTRACE_SETREGS {0}", buf.GetData()); + LLDB_LOG_VERBOSE(log, "PTRACE_SETREGS {0}", buf.GetData()); break; } case PTRACE_SETFPREGS: { DisplayBytes(buf, data, data_size); - LLDB_LOGV(log, "PTRACE_SETFPREGS {0}", buf.GetData()); + LLDB_LOG_VERBOSE(log, "PTRACE_SETFPREGS {0}", buf.GetData()); break; } case PTRACE_SETSIGINFO: { DisplayBytes(buf, data, sizeof(siginfo_t)); - LLDB_LOGV(log, "PTRACE_SETSIGINFO {0}", buf.GetData()); + LLDB_LOG_VERBOSE(log, "PTRACE_SETSIGINFO {0}", buf.GetData()); break; } case PTRACE_SETREGSET: { // Extract iov_base from data, which is a pointer to the struct iovec DisplayBytes(buf, *(void **)data, data_size); - LLDB_LOGV(log, "PTRACE_SETREGSET {0}", buf.GetData()); + LLDB_LOG_VERBOSE(log, "PTRACE_SETREGSET {0}", buf.GetData()); break; } default: {} diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp index f6aaff2fb4e9..96f54d63bc2a 100644 --- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -140,12 +140,10 @@ bool NativeThreadLinux::GetStopReason(ThreadStopInfo &stop_info, case eStateRunning: case eStateStepping: case eStateDetached: - if (log) { - LLDB_LOGF(log, - "NativeThreadLinux::%s tid %" PRIu64 - " in state %s cannot answer stop reason", - __FUNCTION__, GetID(), StateAsCString(m_state)); - } + LLDB_LOGF(log, + "NativeThreadLinux::%s tid %" PRIu64 + " in state %s cannot answer stop reason", + __FUNCTION__, GetID(), StateAsCString(m_state)); return false; } llvm_unreachable("unhandled StateType!"); diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index 623a2ea24a6a..0813204453a3 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -193,11 +193,12 @@ size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock( : std::chrono::microseconds(timeout_usec), status, &error); - LLDB_LOGV(log, - "Read (buffer, sizeof(buffer), timeout_usec = 0x{0:x}, " - "status = {1}, error = {2}) => bytes_read = {4}", - timeout_usec, Communication::ConnectionStatusAsString(status), - error, bytes_read); + LLDB_LOG_VERBOSE(log, + "Read (buffer, sizeof(buffer), timeout_usec = 0x{0:x}, " + "status = {1}, error = {2}) => bytes_read = {4}", + timeout_usec, + Communication::ConnectionStatusAsString(status), error, + bytes_read); if (bytes_read > 0) { if (CheckForPacket(buffer, bytes_read, packet)) diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index ac5e3a7ef491..e81a5dea193a 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -495,7 +495,7 @@ bool ProcessKDP::DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) { // locker will keep a mutex locked until it goes out of scope Log *log = GetLog(KDPLog::Thread); - LLDB_LOGV(log, "pid = {0}", GetID()); + LLDB_LOG_VERBOSE(log, "pid = {0}", GetID()); // Even though there is a CPU mask, it doesn't mean we can see each CPU // individually, there is really only one. Lets call this thread 1. diff --git a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp index b637238007b8..6359a63dfef9 100644 --- a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp @@ -233,9 +233,9 @@ void DebuggerThread::DebugLoop() { Log *log = GetLog(WindowsLog::Event); DEBUG_EVENT dbe = {}; bool should_debug = true; - LLDB_LOGV(log, "Entering WaitForDebugEvent loop"); + LLDB_LOG_VERBOSE(log, "Entering WaitForDebugEvent loop"); while (should_debug) { - LLDB_LOGV(log, "Calling WaitForDebugEvent"); + LLDB_LOG_VERBOSE(log, "Calling WaitForDebugEvent"); BOOL wait_result = WaitForDebugEvent(&dbe, INFINITE); if (wait_result) { DWORD continue_status = DBG_CONTINUE; @@ -287,9 +287,10 @@ void DebuggerThread::DebugLoop() { break; } - LLDB_LOGV(log, "calling ContinueDebugEvent({0}, {1}, {2}) on thread {3}.", - dbe.dwProcessId, dbe.dwThreadId, continue_status, - ::GetCurrentThreadId()); + LLDB_LOG_VERBOSE( + log, "calling ContinueDebugEvent({0}, {1}, {2}) on thread {3}.", + dbe.dwProcessId, dbe.dwThreadId, continue_status, + ::GetCurrentThreadId()); ::ContinueDebugEvent(dbe.dwProcessId, dbe.dwThreadId, continue_status); diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp index a0f622fd6990..234b99a6466d 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp @@ -470,11 +470,11 @@ Status ProcessDebugger::GetMemoryRegionInfo(lldb::addr_t vm_addr, info.SetMapped(MemoryRegionInfo::eNo); } - LLDB_LOGV(log, - "Memory region info for address {0}: readable={1}, " - "executable={2}, writable={3}", - vm_addr, info.GetReadable(), info.GetExecutable(), - info.GetWritable()); + LLDB_LOG_VERBOSE(log, + "Memory region info for address {0}: readable={1}, " + "executable={2}, writable={3}", + vm_addr, info.GetReadable(), info.GetExecutable(), + info.GetWritable()); return error; } diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp index b845744aed8f..730b944c1ddc 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -556,10 +556,11 @@ bool ProcessWindows::DoUpdateThreadList(ThreadList &old_thread_list, new_thread_list.AddThread(old_thread); ++new_size; ++continued_threads; - LLDB_LOGV(log, "Thread {0} was running and is still running.", - old_thread_id); + LLDB_LOG_VERBOSE(log, "Thread {0} was running and is still running.", + old_thread_id); } else { - LLDB_LOGV(log, "Thread {0} was running and has exited.", old_thread_id); + LLDB_LOG_VERBOSE(log, "Thread {0} was running and has exited.", + old_thread_id); ++exited_threads; } } @@ -570,7 +571,8 @@ bool ProcessWindows::DoUpdateThreadList(ThreadList &old_thread_list, new_thread_list.AddThread(thread_info.second); ++new_size; ++new_threads; - LLDB_LOGV(log, "Thread {0} is new since last update.", thread_info.first); + LLDB_LOG_VERBOSE(log, "Thread {0} is new since last update.", + thread_info.first); } LLDB_LOG(log, "{0} new threads, {1} old threads, {2} exited threads.", diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp index 59583c8039fc..448c4f752758 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -306,10 +306,9 @@ void ProcessElfCore::UpdateBuildIdForNTFileEntries() { // Assert that either the path is not in the map or the UUID matches assert(m_uuids.count(entry.path) == 0 || m_uuids[entry.path] == uuid); m_uuids[entry.path] = uuid; - if (log) - LLDB_LOGF(log, "%s found UUID @ %16.16" PRIx64 ": %s \"%s\"", - __FUNCTION__, entry.start, uuid.GetAsString().c_str(), - entry.path.c_str()); + LLDB_LOGF(log, "%s found UUID @ %16.16" PRIx64 ": %s \"%s\"", + __FUNCTION__, entry.start, uuid.GetAsString().c_str(), + entry.path.c_str()); } } } @@ -547,10 +546,8 @@ static void ParseFreeBSDPrStatus(ThreadData &thread_data, int pr_version = data.GetU32(&offset); Log *log = GetLog(LLDBLog::Process); - if (log) { - if (pr_version > 1) - LLDB_LOGF(log, "FreeBSD PRSTATUS unexpected version %d", pr_version); - } + if (pr_version > 1) + LLDB_LOGF(log, "FreeBSD PRSTATUS unexpected version %d", pr_version); // Skip padding, pr_statussz, pr_gregsetsz, pr_fpregsetsz, pr_osreldate if (lp64) @@ -575,10 +572,8 @@ static void ParseFreeBSDPrPsInfo(ProcessElfCore &process, int pr_version = data.GetU32(&offset); Log *log = GetLog(LLDBLog::Process); - if (log) { - if (pr_version > 1) - LLDB_LOGF(log, "FreeBSD PRPSINFO unexpected version %d", pr_version); - } + if (pr_version > 1) + LLDB_LOGF(log, "FreeBSD PRPSINFO unexpected version %d", pr_version); // Skip pr_psinfosz, pr_fname, pr_psargs offset += 108; diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index d7e4b2b9546b..9b4549a1a1cf 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -245,11 +245,11 @@ GDBRemoteCommunication::WaitForPacketNoLock(StringExtractorGDBRemote &packet, lldb::ConnectionStatus status = eConnectionStatusNoConnection; size_t bytes_read = Read(buffer, sizeof(buffer), timeout, status, &error); - LLDB_LOGV(log, - "Read(buffer, sizeof(buffer), timeout = {0}, " - "status = {1}, error = {2}) => bytes_read = {3}", - timeout, Communication::ConnectionStatusAsString(status), error, - bytes_read); + LLDB_LOG_VERBOSE(log, + "Read(buffer, sizeof(buffer), timeout = {0}, " + "status = {1}, error = {2}) => bytes_read = {3}", + timeout, Communication::ConnectionStatusAsString(status), + error, bytes_read); if (bytes_read > 0) { if (CheckForPacket(buffer, bytes_read, packet) != PacketType::Invalid) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 5e2624c00842..c8b0acfe5909 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -466,13 +466,11 @@ void GDBRemoteCommunicationServerLLGS::InitializeDelegate( NativeProcessProtocol *process) { assert(process && "process cannot be NULL"); Log *log = GetLog(LLDBLog::Process); - if (log) { - LLDB_LOGF(log, - "GDBRemoteCommunicationServerLLGS::%s called with " - "NativeProcessProtocol pid %" PRIu64 ", current state: %s", - __FUNCTION__, process->GetID(), - StateAsCString(process->GetState())); - } + LLDB_LOGF(log, + "GDBRemoteCommunicationServerLLGS::%s called with " + "NativeProcessProtocol pid %" PRIu64 ", current state: %s", + __FUNCTION__, process->GetID(), + StateAsCString(process->GetState())); } GDBRemoteCommunication::PacketResult @@ -804,14 +802,12 @@ GetJSONThreadsInfo(NativeProcessProtocol &process, bool abridged) { return llvm::createStringError("failed to get stop reason"); const int signum = tid_stop_info.signo; - if (log) { - LLDB_LOGF(log, - "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 - " tid %" PRIu64 - " got signal signo = %d, reason = %d, exc_type = %" PRIu64, - __FUNCTION__, process.GetID(), tid, signum, - tid_stop_info.reason, tid_stop_info.details.exception.type); - } + LLDB_LOGF(log, + "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 + " tid %" PRIu64 + " got signal signo = %d, reason = %d, exc_type = %" PRIu64, + __FUNCTION__, process.GetID(), tid, signum, tid_stop_info.reason, + tid_stop_info.details.exception.type); json::Object thread_obj; @@ -1157,12 +1153,10 @@ void GDBRemoteCommunicationServerLLGS::ProcessStateChanged( NativeProcessProtocol *process, lldb::StateType state) { assert(process && "process cannot be NULL"); Log *log = GetLog(LLDBLog::Process); - if (log) { - LLDB_LOGF(log, - "GDBRemoteCommunicationServerLLGS::%s called with " - "NativeProcessProtocol pid %" PRIu64 ", state: %s", - __FUNCTION__, process->GetID(), StateAsCString(state)); - } + LLDB_LOGF(log, + "GDBRemoteCommunicationServerLLGS::%s called with " + "NativeProcessProtocol pid %" PRIu64 ", state: %s", + __FUNCTION__, process->GetID(), StateAsCString(state)); switch (state) { case StateType::eStateRunning: @@ -1188,12 +1182,10 @@ void GDBRemoteCommunicationServerLLGS::ProcessStateChanged( break; default: - if (log) { - LLDB_LOGF(log, - "GDBRemoteCommunicationServerLLGS::%s didn't handle state " - "change for pid %" PRIu64 ", new state: %s", - __FUNCTION__, process->GetID(), StateAsCString(state)); - } + LLDB_LOGF(log, + "GDBRemoteCommunicationServerLLGS::%s didn't handle state " + "change for pid %" PRIu64 ", new state: %s", + __FUNCTION__, process->GetID(), StateAsCString(state)); break; } } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index f65b485e0e4a..631bda1d2453 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -714,20 +714,17 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module, stderr_file_spec = file_action->GetFileSpec(); } - if (log) { - if (stdin_file_spec || stdout_file_spec || stderr_file_spec) - LLDB_LOGF(log, - "ProcessGDBRemote::%s provided with STDIO paths via " - "launch_info: stdin=%s, stdout=%s, stderr=%s", - __FUNCTION__, - stdin_file_spec ? stdin_file_spec.GetPath().c_str() : "", - stdout_file_spec ? stdout_file_spec.GetPath().c_str() : "", - stderr_file_spec ? stderr_file_spec.GetPath().c_str() : ""); - else - LLDB_LOGF(log, - "ProcessGDBRemote::%s no STDIO paths given via launch_info", - __FUNCTION__); - } + if (stdin_file_spec || stdout_file_spec || stderr_file_spec) + LLDB_LOGF(log, + "ProcessGDBRemote::%s provided with STDIO paths via " + "launch_info: stdin=%s, stdout=%s, stderr=%s", + __FUNCTION__, + stdin_file_spec ? stdin_file_spec.GetPath().c_str() : "", + stdout_file_spec ? stdout_file_spec.GetPath().c_str() : "", + stderr_file_spec ? stderr_file_spec.GetPath().c_str() : ""); + else + LLDB_LOGF(log, "ProcessGDBRemote::%s no STDIO paths given via launch_info", + __FUNCTION__); const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0; if (stdin_file_spec || disable_stdio) { @@ -1639,7 +1636,7 @@ bool ProcessGDBRemote::DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) { // locker will keep a mutex locked until it goes out of scope Log *log = GetLog(GDBRLog::Thread); - LLDB_LOGV(log, "pid = {0}", GetID()); + LLDB_LOG_VERBOSE(log, "pid = {0}", GetID()); size_t num_thread_ids = m_thread_ids.size(); // The "m_thread_ids" thread ID list should always be updated after each stop @@ -1658,11 +1655,11 @@ bool ProcessGDBRemote::DoUpdateThreadList(ThreadList &old_thread_list, old_thread_list_copy.RemoveThreadByProtocolID(tid, false)); if (!thread_sp) { thread_sp = CreateThread(tid); - LLDB_LOGV(log, "Making new thread: {0} for thread ID: {1:x}.", - thread_sp.get(), thread_sp->GetID()); + LLDB_LOG_VERBOSE(log, "Making new thread: {0} for thread ID: {1:x}.", + thread_sp.get(), thread_sp->GetID()); } else { - LLDB_LOGV(log, "Found old thread: {0} for thread ID: {1:x}.", - thread_sp.get(), thread_sp->GetID()); + LLDB_LOG_VERBOSE(log, "Found old thread: {0} for thread ID: {1:x}.", + thread_sp.get(), thread_sp->GetID()); } SetThreadPc(thread_sp, i); @@ -4131,8 +4128,7 @@ Status ProcessGDBRemote::UpdateAutomaticSignalFiltering() { bool ProcessGDBRemote::StartNoticingNewThreads() { Log *log = GetLog(LLDBLog::Step); if (m_thread_create_bp_sp) { - if (log && log->GetVerbose()) - LLDB_LOGF(log, "Enabled noticing new thread breakpoint."); + LLDB_LOGF_VERBOSE(log, "Enabled noticing new thread breakpoint."); m_thread_create_bp_sp->SetEnabled(true); } else { PlatformSP platform_sp(GetTarget().GetPlatform()); @@ -4140,10 +4136,9 @@ bool ProcessGDBRemote::StartNoticingNewThreads() { m_thread_create_bp_sp = platform_sp->SetThreadCreationBreakpoint(GetTarget()); if (m_thread_create_bp_sp) { - if (log && log->GetVerbose()) - LLDB_LOGF( - log, "Successfully created new thread notification breakpoint %i", - m_thread_create_bp_sp->GetID()); + LLDB_LOGF_VERBOSE( + log, "Successfully created new thread notification breakpoint %i", + m_thread_create_bp_sp->GetID()); m_thread_create_bp_sp->SetCallback( ProcessGDBRemote::NewThreadNotifyBreakpointHit, this, true); } else { @@ -4156,8 +4151,7 @@ bool ProcessGDBRemote::StartNoticingNewThreads() { bool ProcessGDBRemote::StopNoticingNewThreads() { Log *log = GetLog(LLDBLog::Step); - if (log && log->GetVerbose()) - LLDB_LOGF(log, "Disabling new thread notification breakpoint."); + LLDB_LOGF_VERBOSE(log, "Disabling new thread notification breakpoint."); if (m_thread_create_bp_sp) m_thread_create_bp_sp->SetEnabled(false); @@ -5349,9 +5343,8 @@ llvm::Expected ProcessGDBRemote::GetLoadedModuleList() { // node }); - if (log) - LLDB_LOGF(log, "found %" PRId32 " modules in total", - (int)list.m_list.size()); + LLDB_LOGF(log, "found %" PRId32 " modules in total", + (int)list.m_list.size()); return list; } else if (comm.GetQXferLibrariesReadSupported()) { // request the loaded library list @@ -5409,9 +5402,8 @@ llvm::Expected ProcessGDBRemote::GetLoadedModuleList() { // node }); - if (log) - LLDB_LOGF(log, "found %" PRId32 " modules in total", - (int)list.m_list.size()); + LLDB_LOGF(log, "found %" PRId32 " modules in total", + (int)list.m_list.size()); return list; } else { return llvm::createStringError(llvm::inconvertibleErrorCode(), @@ -5738,15 +5730,13 @@ ParseStructuredDataPacket(llvm::StringRef packet) { Log *log = GetLog(GDBRLog::Process); if (!packet.consume_front(s_async_json_packet_prefix)) { - if (log) { - LLDB_LOGF( - log, - "GDBRemoteCommunicationClientBase::%s() received $J packet " - "but was not a StructuredData packet: packet starts with " - "%s", - __FUNCTION__, - packet.slice(0, strlen(s_async_json_packet_prefix)).str().c_str()); - } + LLDB_LOGF( + log, + "GDBRemoteCommunicationClientBase::%s() received $J packet " + "but was not a StructuredData packet: packet starts with " + "%s", + __FUNCTION__, + packet.slice(0, strlen(s_async_json_packet_prefix)).str().c_str()); return StructuredData::ObjectSP(); } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 3de30713ad76..e021e5dab886 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -134,16 +134,17 @@ public: m_was_already_initialized = true; m_gil_state = gil_state; - LLDB_LOGV(GetLog(LLDBLog::Script), - "Ensured PyGILState. Previous state = {0}", - m_gil_state == PyGILState_UNLOCKED ? "unlocked" : "locked"); + LLDB_LOG_VERBOSE( + GetLog(LLDBLog::Script), "Ensured PyGILState. Previous state = {0}", + m_gil_state == PyGILState_UNLOCKED ? "unlocked" : "locked"); } ~InitializePythonRAII() { if (m_was_already_initialized) { - LLDB_LOGV(GetLog(LLDBLog::Script), - "Releasing PyGILState. Returning to state = {0}", - m_gil_state == PyGILState_UNLOCKED ? "unlocked" : "locked"); + LLDB_LOG_VERBOSE(GetLog(LLDBLog::Script), + "Releasing PyGILState. Returning to state = {0}", + m_gil_state == PyGILState_UNLOCKED ? "unlocked" + : "locked"); PyGILState_Release(m_gil_state); } else { // We initialized the threads in this function, just unlock the GIL. @@ -330,8 +331,9 @@ ScriptInterpreterPythonImpl::Locker::Locker( bool ScriptInterpreterPythonImpl::Locker::DoAcquireLock() { m_GILState = PyGILState_Ensure(); - LLDB_LOGV(GetLog(LLDBLog::Script), "Ensured PyGILState. Previous state = {0}", - m_GILState == PyGILState_UNLOCKED ? "unlocked" : "locked"); + LLDB_LOG_VERBOSE(GetLog(LLDBLog::Script), + "Ensured PyGILState. Previous state = {0}", + m_GILState == PyGILState_UNLOCKED ? "unlocked" : "locked"); // 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 place outside @@ -352,9 +354,9 @@ bool ScriptInterpreterPythonImpl::Locker::DoInitSession(uint16_t on_entry_flags, } bool ScriptInterpreterPythonImpl::Locker::DoFreeLock() { - LLDB_LOGV(GetLog(LLDBLog::Script), - "Releasing PyGILState. Returning to state = {0}", - m_GILState == PyGILState_UNLOCKED ? "unlocked" : "locked"); + LLDB_LOG_VERBOSE(GetLog(LLDBLog::Script), + "Releasing PyGILState. Returning to state = {0}", + m_GILState == PyGILState_UNLOCKED ? "unlocked" : "locked"); PyGILState_Release(m_GILState); m_python_interpreter->DecrementLockCount(); return true; diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp index 130bff7a99f3..9cc43f38dadf 100644 --- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -1804,18 +1804,16 @@ void StructuredDataDarwinLog::EnableNow() { // care of the rest. auto &interpreter = debugger_sp->GetCommandInterpreter(); const bool success = RunEnableCommand(interpreter); - if (log) { - if (success) - LLDB_LOGF(log, - "StructuredDataDarwinLog::%s() ran enable command " - "successfully for (process uid %u)", - __FUNCTION__, process_sp->GetUniqueID()); - else - LLDB_LOGF(log, - "StructuredDataDarwinLog::%s() error: running " - "enable command failed (process uid %u)", - __FUNCTION__, process_sp->GetUniqueID()); - } + if (success) + LLDB_LOGF(log, + "StructuredDataDarwinLog::%s() ran enable command " + "successfully for (process uid %u)", + __FUNCTION__, process_sp->GetUniqueID()); + else + LLDB_LOGF(log, + "StructuredDataDarwinLog::%s() error: running " + "enable command failed (process uid %u)", + __FUNCTION__, process_sp->GetUniqueID()); Debugger::ReportError("failed to configure DarwinLog support", debugger_sp->GetID()); return; diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp index 6bbe8fc20a0f..2f6235ea5e76 100644 --- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp +++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp @@ -1013,8 +1013,8 @@ lldb_private::Type *SymbolFileCTF::ResolveTypeUID(lldb::user_id_t type_uid) { if (log) { StreamString ss; type_sp->Dump(&ss, true); - LLDB_LOGV(log, "Adding type {0}: {1}", type_sp->GetID(), - llvm::StringRef(ss.GetString()).rtrim()); + LLDB_LOG_VERBOSE(log, "Adding type {0}: {1}", type_sp->GetID(), + llvm::StringRef(ss.GetString()).rtrim()); } m_types[type_uid] = type_sp; diff --git a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp index 8173f611c1c8..e209ddeb1cc2 100644 --- a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp +++ b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp @@ -480,10 +480,8 @@ static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec, if (exec_fspec) { if (::LookForDsymNextToExecutablePath(module_spec, exec_fspec, dsym_fspec)) { - if (log) { - LLDB_LOGF(log, "dSYM with matching UUID & arch found at %s", - dsym_fspec.GetPath().c_str()); - } + LLDB_LOGF(log, "dSYM with matching UUID & arch found at %s", + dsym_fspec.GetPath().c_str()); return true; } else { FileSpec parent_dirs = exec_fspec; @@ -512,10 +510,8 @@ static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec, if (::strchr(fn, '.') != nullptr) { if (::LookForDsymNextToExecutablePath(module_spec, parent_dirs, dsym_fspec)) { - if (log) { - LLDB_LOGF(log, "dSYM with matching UUID & arch found at %s", - dsym_fspec.GetPath().c_str()); - } + LLDB_LOGF(log, "dSYM with matching UUID & arch found at %s", + dsym_fspec.GetPath().c_str()); return true; } } diff --git a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp index 14f5a6cbc8fa..e28e74ba67bf 100644 --- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp +++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp @@ -194,9 +194,9 @@ GetFileForModule(const ModuleSpec &module_spec, Log *log = GetLog(LLDBLog::Symbols); auto err_message = llvm::toString(result.takeError()); - LLDB_LOGV(log, - "Debuginfod failed to download symbol artifact {0} with error {1}", - url_path, err_message); + LLDB_LOG_VERBOSE( + log, "Debuginfod failed to download symbol artifact {0} with error {1}", + url_path, err_message); return {}; } diff --git a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp index d008a7d3e8e9..6d1119b998e4 100644 --- a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp +++ b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp @@ -120,14 +120,15 @@ std::optional SymbolLocatorSymStore::LocateExecutableSymbolFile( std::string pdb_name = module_spec.GetSymbolFileSpec().GetFilename().GetStringRef().str(); if (pdb_name.empty()) { - LLDB_LOGV(log, "Failed to resolve symbol PDB module: PDB name empty"); + LLDB_LOG_VERBOSE(log, + "Failed to resolve symbol PDB module: PDB name empty"); return {}; } - LLDB_LOGV(log, "LocateExecutableSymbolFile {0} with UUID {1}", pdb_name, - uuid.GetAsString()); + LLDB_LOG_VERBOSE(log, "LocateExecutableSymbolFile {0} with UUID {1}", + pdb_name, uuid.GetAsString()); if (uuid.GetBytes().size() != 20) { - LLDB_LOGV(log, "Failed to resolve symbol PDB module: UUID invalid"); + LLDB_LOG_VERBOSE(log, "Failed to resolve symbol PDB module: UUID invalid"); return {}; } @@ -138,7 +139,7 @@ std::optional SymbolLocatorSymStore::LocateExecutableSymbolFile( llvm::sys::path::append(path, url.ref(), pdb_name, key, pdb_name); FileSpec spec(path); if (FileSystem::Instance().Exists(spec)) { - LLDB_LOGV(log, "Found {0} in SymStore {1}", pdb_name, url.ref()); + LLDB_LOG_VERBOSE(log, "Found {0} in SymStore {1}", pdb_name, url.ref()); return spec; } } diff --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp index a23a50718712..d0aa67f66d20 100644 --- a/lldb/source/Target/Memory.cpp +++ b/lldb/source/Target/Memory.cpp @@ -318,13 +318,14 @@ lldb::addr_t AllocatedBlock::ReserveBlock(uint32_t size) { free_block.SetRangeBase(reserved_block.GetRangeEnd()); free_block.SetByteSize(bytes_left); } - LLDB_LOGV(log, "({0}) (size = {1} ({1:x})) => {2:x}", this, size, addr); + LLDB_LOG_VERBOSE(log, "({0}) (size = {1} ({1:x})) => {2:x}", this, size, + addr); return addr; } } - LLDB_LOGV(log, "({0}) (size = {1} ({1:x})) => {2:x}", this, size, - LLDB_INVALID_ADDRESS); + LLDB_LOG_VERBOSE(log, "({0}) (size = {1} ({1:x})) => {2:x}", this, size, + LLDB_INVALID_ADDRESS); return LLDB_INVALID_ADDRESS; } @@ -338,7 +339,7 @@ bool AllocatedBlock::FreeBlock(addr_t addr) { success = true; } Log *log = GetLog(LLDBLog::Process); - LLDB_LOGV(log, "({0}) (addr = {1:x}) => {2}", this, addr, success); + LLDB_LOG_VERBOSE(log, "({0}) (addr = {1:x}) => {2}", this, addr, success); return success; } @@ -368,13 +369,11 @@ AllocatedMemoryCache::AllocatePage(uint32_t byte_size, uint32_t permissions, addr_t addr = m_process.DoAllocateMemory(page_byte_size, permissions, error); Log *log = GetLog(LLDBLog::Process); - if (log) { - LLDB_LOGF(log, - "Process::DoAllocateMemory (byte_size = 0x%8.8" PRIx32 - ", permissions = %s) => 0x%16.16" PRIx64, - (uint32_t)page_byte_size, GetPermissionsAsCString(permissions), - (uint64_t)addr); - } + LLDB_LOGF(log, + "Process::DoAllocateMemory (byte_size = 0x%8.8" PRIx32 + ", permissions = %s) => 0x%16.16" PRIx64, + (uint32_t)page_byte_size, GetPermissionsAsCString(permissions), + (uint64_t)addr); if (addr != LLDB_INVALID_ADDRESS) { block_sp = std::make_shared(addr, page_byte_size, diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 5e364b493290..587d9f6408ae 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -957,14 +957,11 @@ Event *Process::PeekAtStateChangedEvents() { Event *event_ptr; event_ptr = GetPrimaryListener()->PeekAtNextEventForBroadcasterWithType( this, eBroadcastBitStateChanged); - if (log) { - if (event_ptr) { - LLDB_LOGF(log, "Process::%s (event_ptr) => %s", __FUNCTION__, - StateAsCString(ProcessEventData::GetStateFromEvent(event_ptr))); - } else { - LLDB_LOGF(log, "Process::%s no events found", __FUNCTION__); - } - } + if (event_ptr) + LLDB_LOGF(log, "Process::%s (event_ptr) => %s", __FUNCTION__, + StateAsCString(ProcessEventData::GetStateFromEvent(event_ptr))); + else + LLDB_LOGF(log, "Process::%s no events found", __FUNCTION__); return event_ptr; } @@ -4078,14 +4075,11 @@ void Process::HandlePrivateEvent(EventSP &event_sp) { if (should_broadcast) { const bool is_hijacked = IsHijackedForEvent(eBroadcastBitStateChanged); - if (log) { - LLDB_LOGF(log, - "Process::%s (pid = %" PRIu64 - ") broadcasting new state %s (old state %s) to %s", - __FUNCTION__, GetID(), StateAsCString(new_state), - StateAsCString(GetState()), - is_hijacked ? "hijacked" : "public"); - } + LLDB_LOGF(log, + "Process::%s (pid = %" PRIu64 + ") broadcasting new state %s (old state %s) to %s", + __FUNCTION__, GetID(), StateAsCString(new_state), + StateAsCString(GetState()), is_hijacked ? "hijacked" : "public"); Process::ProcessEventData::SetUpdateStateOnRemoval(event_sp.get()); if (StateIsRunningState(new_state)) { // Only push the input handler if we aren't fowarding events, as this @@ -4137,14 +4131,12 @@ void Process::HandlePrivateEvent(EventSP &event_sp) { BroadcastEvent(event_sp); } else { - if (log) { - LLDB_LOGF( - log, - "Process::%s (pid = %" PRIu64 - ") suppressing state %s (old state %s): should_broadcast == false", - __FUNCTION__, GetID(), StateAsCString(new_state), - StateAsCString(GetState())); - } + LLDB_LOGF( + log, + "Process::%s (pid = %" PRIu64 + ") suppressing state %s (old state %s): should_broadcast == false", + __FUNCTION__, GetID(), StateAsCString(new_state), + StateAsCString(GetState())); } } @@ -4264,7 +4256,7 @@ thread_result_t Process::RunPrivateStateThread() { ProcessEventData::SetInterruptedInEvent(event_sp.get(), true); } interrupt_requested = false; - } else if (log) { + } else { LLDB_LOGF(log, "Process::%s interrupt_requested, but a non-stopped " "state '%s' received.", diff --git a/lldb/source/Target/SectionLoadList.cpp b/lldb/source/Target/SectionLoadList.cpp index d4bf0573b229..d72069d0a71d 100644 --- a/lldb/source/Target/SectionLoadList.cpp +++ b/lldb/source/Target/SectionLoadList.cpp @@ -68,9 +68,10 @@ bool SectionLoadList::SetSectionLoadAddress(const lldb::SectionSP §ion, ModuleSP module_sp(section->GetModule()); if (module_sp) { - LLDB_LOGV(log, "(section = {0} ({1}.{2}), load_addr = {3:x}) module = {4}", - section.get(), module_sp->GetFileSpec(), section->GetName(), - load_addr, module_sp.get()); + LLDB_LOG_VERBOSE( + log, "(section = {0} ({1}.{2}), load_addr = {3:x}) module = {4}", + section.get(), module_sp->GetFileSpec(), section->GetName(), load_addr, + module_sp.get()); if (section->GetByteSize() == 0) return false; // No change @@ -131,14 +132,12 @@ bool SectionLoadList::SetSectionLoadAddress(const lldb::SectionSP §ion, return true; // Changed } else { - if (log) { - LLDB_LOGF( - log, - "SectionLoadList::%s (section = %p (%s), load_addr = 0x%16.16" PRIx64 - ") error: module has been deleted", - __FUNCTION__, static_cast(section.get()), - section->GetName().AsCString(), load_addr); - } + LLDB_LOGF( + log, + "SectionLoadList::%s (section = %p (%s), load_addr = 0x%16.16" PRIx64 + ") error: module has been deleted", + __FUNCTION__, static_cast(section.get()), + section->GetName().AsCString(), load_addr); } return false; } diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp index 84500b888356..ca333b532438 100644 --- a/lldb/source/Target/StackFrameList.cpp +++ b/lldb/source/Target/StackFrameList.cpp @@ -118,11 +118,9 @@ uint32_t StackFrameList::GetCurrentInlinedDepth() { if (cur_pc != m_current_inlined_pc) { m_current_inlined_pc = LLDB_INVALID_ADDRESS; m_current_inlined_depth = UINT32_MAX; - Log *log = GetLog(LLDBLog::Step); - if (log && log->GetVerbose()) - LLDB_LOGF( - log, - "GetCurrentInlinedDepth: invalidating current inlined depth.\n"); + LLDB_LOGF_VERBOSE( + GetLog(LLDBLog::Step), + "GetCurrentInlinedDepth: invalidating current inlined depth.\n"); } return m_current_inlined_depth; } else { @@ -147,19 +145,16 @@ void StackFrameList::ResetCurrentInlinedDepth() { m_current_inlined_depth = *inline_depth; m_current_inlined_pc = m_thread.GetRegisterContext()->GetPC(); - if (log && log->GetVerbose()) - LLDB_LOGF(log, - "ResetCurrentInlinedDepth: setting inlined " - "depth: %d 0x%" PRIx64 ".\n", - m_current_inlined_depth, m_current_inlined_pc); + LLDB_LOGF_VERBOSE(log, + "ResetCurrentInlinedDepth: setting inlined " + "depth: %d 0x%" PRIx64 ".\n", + m_current_inlined_depth, m_current_inlined_pc); } else { std::lock_guard guard(m_inlined_depth_mutex); m_current_inlined_pc = LLDB_INVALID_ADDRESS; m_current_inlined_depth = UINT32_MAX; - if (log && log->GetVerbose()) - LLDB_LOGF( - log, - "ResetCurrentInlinedDepth: Invalidating current inlined depth.\n"); + LLDB_LOGF_VERBOSE( + log, "ResetCurrentInlinedDepth: Invalidating current inlined depth.\n"); } } @@ -210,31 +205,33 @@ static void FindInterveningFrames(Function &begin, Function &end, ExecutionContext &exe_ctx, Target &target, addr_t return_pc, CallSequence &path, ModuleList &images, Log *log) { - LLDB_LOGV(log, "Finding frames between {0} and {1}, retn-pc={2:x}", - begin.GetDisplayName(), end.GetDisplayName(), return_pc); + LLDB_LOG_VERBOSE(log, "Finding frames between {0} and {1}, retn-pc={2:x}", + begin.GetDisplayName(), end.GetDisplayName(), return_pc); // Find a non-tail calling edge with the correct return PC. if (log) for (const auto &edge : begin.GetCallEdges()) - LLDB_LOGV(log, "FindInterveningFrames: found call with retn-PC = {0:x}", - edge->GetReturnPCAddress(begin, target)); + LLDB_LOG_VERBOSE(log, + "FindInterveningFrames: found call with retn-PC = {0:x}", + edge->GetReturnPCAddress(begin, target)); CallEdge *first_edge = begin.GetCallEdgeForReturnAddress(return_pc, target); if (!first_edge) { - LLDB_LOGV(log, "No call edge outgoing from {0} with retn-PC == {1:x}", - begin.GetDisplayName(), return_pc); + LLDB_LOG_VERBOSE(log, + "No call edge outgoing from {0} with retn-PC == {1:x}", + begin.GetDisplayName(), return_pc); return; } // The first callee may not be resolved, or there may be nothing to fill in. Function *first_callee = first_edge->GetCallee(images, exe_ctx); if (!first_callee) { - LLDB_LOGV(log, "Could not resolve callee"); + LLDB_LOG_VERBOSE(log, "Could not resolve callee"); return; } if (first_callee == &end) { - LLDB_LOGV(log, - "Not searching further, first callee is {0} (retn-PC: {1:x})", - end.GetDisplayName(), return_pc); + LLDB_LOG_VERBOSE( + log, "Not searching further, first callee is {0} (retn-PC: {1:x})", + end.GetDisplayName(), return_pc); return; } diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp index e9e534a57973..5110ed16edc9 100644 --- a/lldb/source/Target/StopInfo.cpp +++ b/lldb/source/Target/StopInfo.cpp @@ -329,9 +329,7 @@ protected: if (!thread_sp->IsValid()) { // This shouldn't ever happen, but just in case, don't do more harm. - if (log) { - LLDB_LOGF(log, "PerformAction got called with an invalid thread."); - } + LLDB_LOGF(log, "PerformAction got called with an invalid thread."); m_should_stop = true; m_should_stop_is_valid = true; return; @@ -485,13 +483,11 @@ protected: // not all of them valid for this thread. Skip the ones that // aren't: if (!bp_loc_sp->ValidForThisThread(*thread_sp)) { - if (log) { - LLDB_LOGF(log, - "Breakpoint %s hit on thread 0x%llx but it was not " - "for this thread, continuing.", - loc_desc.GetData(), - static_cast(thread_sp->GetID())); - } + LLDB_LOGF(log, + "Breakpoint %s hit on thread 0x%llx but it was not " + "for this thread, continuing.", + loc_desc.GetData(), + static_cast(thread_sp->GetID())); continue; } diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index aa005a2b9b3d..8bc109340c61 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -1142,10 +1142,8 @@ void Thread::PushPlan(ThreadPlanSP thread_plan_sp) { void Thread::PopPlan() { Log *log = GetLog(LLDBLog::Step); ThreadPlanSP popped_plan_sp = GetPlans().PopPlan(); - if (log) { - LLDB_LOGF(log, "Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".", - popped_plan_sp->GetName(), popped_plan_sp->GetThread().GetID()); - } + LLDB_LOGF(log, "Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".", + popped_plan_sp->GetName(), popped_plan_sp->GetThread().GetID()); } void Thread::DiscardPlan() { @@ -1260,12 +1258,10 @@ void Thread::DiscardThreadPlansUpToPlan(ThreadPlan *up_to_plan_ptr) { void Thread::DiscardThreadPlans(bool force) { Log *log = GetLog(LLDBLog::Step); - if (log) { - LLDB_LOGF(log, - "Discarding thread plans for thread (tid = 0x%4.4" PRIx64 - ", force %d)", - GetID(), force); - } + LLDB_LOGF(log, + "Discarding thread plans for thread (tid = 0x%4.4" PRIx64 + ", force %d)", + GetID(), force); if (force) { GetPlans().DiscardAllPlans(); diff --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp index b6fb54b16334..b47f848b3699 100644 --- a/lldb/source/Target/ThreadList.cpp +++ b/lldb/source/Target/ThreadList.cpp @@ -476,11 +476,10 @@ void ThreadList::RefreshStateAfterStop() { m_process.UpdateThreadListIfNeeded(); - Log *log = GetLog(LLDBLog::Step); - if (log && log->GetVerbose()) - LLDB_LOGF(log, - "Turning off notification of new threads while single stepping " - "a thread."); + LLDB_LOGF_VERBOSE( + GetLog(LLDBLog::Step), + "Turning off notification of new threads while single stepping " + "a thread."); collection::iterator pos, end = m_threads.end(); for (pos = m_threads.begin(); pos != end; ++pos) @@ -692,16 +691,14 @@ bool ThreadList::WillResume(RunDirection &direction) { } if (thread_to_run != nullptr) { - Log *log = GetLog(LLDBLog::Step); - if (log && log->GetVerbose()) - LLDB_LOGF(log, "Turning on notification of new threads while single " - "stepping a thread."); + LLDB_LOGF_VERBOSE(GetLog(LLDBLog::Step), + "Turning on notification of new threads while single " + "stepping a thread."); m_process.StartNoticingNewThreads(); } else { - Log *log = GetLog(LLDBLog::Step); - if (log && log->GetVerbose()) - LLDB_LOGF(log, "Turning off notification of new threads while single " - "stepping a thread."); + LLDB_LOGF_VERBOSE(GetLog(LLDBLog::Step), + "Turning off notification of new threads while single " + "stepping a thread."); m_process.StopNoticingNewThreads(); } diff --git a/lldb/source/Target/ThreadPlanStepInRange.cpp b/lldb/source/Target/ThreadPlanStepInRange.cpp index 0e93691de68a..88e1b5888345 100644 --- a/lldb/source/Target/ThreadPlanStepInRange.cpp +++ b/lldb/source/Target/ThreadPlanStepInRange.cpp @@ -182,14 +182,12 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) { // Otherwise check the ShouldStopHere for step out: m_sub_plan_sp = CheckShouldStopHereAndQueueStepOut(frame_order, m_status); - if (log) { - if (m_sub_plan_sp) - LLDB_LOGF(log, - "ShouldStopHere found plan to step out of this frame."); - else - LLDB_LOGF(log, "ShouldStopHere no plan to step out of this frame."); - } - } else if (log) { + if (m_sub_plan_sp) + LLDB_LOGF(log, + "ShouldStopHere found plan to step out of this frame."); + else + LLDB_LOGF(log, "ShouldStopHere no plan to step out of this frame."); + } else { LLDB_LOGF( log, "Thought I stepped out, but in fact arrived at a trampoline."); } @@ -223,13 +221,10 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) { m_sub_plan_sp = thread.QueueThreadPlanForStepThrough( m_stack_id, false, stop_others, m_status); - if (log) { - if (m_sub_plan_sp) - LLDB_LOGF(log, "Found a step through plan: %s", - m_sub_plan_sp->GetName()); - else - LLDB_LOGF(log, "No step through plan found."); - } + if (m_sub_plan_sp) + LLDB_LOGF(log, "Found a step through plan: %s", m_sub_plan_sp->GetName()); + else + LLDB_LOGF(log, "No step through plan found."); // If not, give the "should_stop" callback a chance to push a plan to get // us out of here. But only do that if we actually have stepped in. diff --git a/lldb/source/Target/ThreadPlanStepInstruction.cpp b/lldb/source/Target/ThreadPlanStepInstruction.cpp index 42bee79c42bb..e9db3171a5be 100644 --- a/lldb/source/Target/ThreadPlanStepInstruction.cpp +++ b/lldb/source/Target/ThreadPlanStepInstruction.cpp @@ -116,11 +116,8 @@ bool ThreadPlanStepInstruction::IsPlanStale() { // done. return !m_step_over; } else { - if (log) { - LLDB_LOGF(log, - "ThreadPlanStepInstruction::IsPlanStale - Current frame is " - "older than start frame, plan is stale."); - } + LLDB_LOGF(log, "ThreadPlanStepInstruction::IsPlanStale - Current frame is " + "older than start frame, plan is stale."); return true; } } @@ -171,11 +168,8 @@ bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) { parent_frame_sp->GetConcreteFrameIndex() == cur_frame_sp->GetConcreteFrameIndex()) { SetPlanComplete(); - if (log) { - LLDB_LOGF(log, - "Frame we stepped into is inlined into the frame " - "we were stepping from, stopping."); - } + LLDB_LOGF(log, "Frame we stepped into is inlined into the frame " + "we were stepping from, stopping."); return true; } } diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp b/lldb/source/Target/ThreadPlanStepOut.cpp index 0307b38d7d94..7af4de6e71ec 100644 --- a/lldb/source/Target/ThreadPlanStepOut.cpp +++ b/lldb/source/Target/ThreadPlanStepOut.cpp @@ -466,8 +466,7 @@ bool ThreadPlanStepOut::MischiefManaged() { // we're done with this step out operation. Log *log = GetLog(LLDBLog::Step); - if (log) - LLDB_LOGF(log, "Completed step out plan."); + LLDB_LOGF(log, "Completed step out plan."); if (m_return_bp_id != LLDB_INVALID_BREAK_ID) { GetTarget().RemoveBreakpointByID(m_return_bp_id); m_return_bp_id = LLDB_INVALID_BREAK_ID; diff --git a/lldb/source/Target/ThreadPlanStepRange.cpp b/lldb/source/Target/ThreadPlanStepRange.cpp index 3a9deb6f5c6f..b57754a180e7 100644 --- a/lldb/source/Target/ThreadPlanStepRange.cpp +++ b/lldb/source/Target/ThreadPlanStepRange.cpp @@ -537,10 +537,8 @@ bool ThreadPlanStepRange::IsPlanStale() { FrameComparison frame_order = CompareCurrentFrameToStartFrame(); if (frame_order == eFrameCompareOlder) { - if (log) { - LLDB_LOGF(log, "ThreadPlanStepRange::IsPlanStale returning true, we've " - "stepped out."); - } + LLDB_LOGF(log, "ThreadPlanStepRange::IsPlanStale returning true, we've " + "stepped out."); return true; } else if (frame_order == eFrameCompareEqual && InSymbol()) { // If we are not in a place we should step through, we've gotten stale. One diff --git a/lldb/source/Target/ThreadPlanStepThrough.cpp b/lldb/source/Target/ThreadPlanStepThrough.cpp index e15635e40700..886a17e26b0b 100644 --- a/lldb/source/Target/ThreadPlanStepThrough.cpp +++ b/lldb/source/Target/ThreadPlanStepThrough.cpp @@ -62,10 +62,8 @@ ThreadPlanStepThrough::ThreadPlanStepThrough(Thread &thread, return_bp->SetBreakpointKind("step-through-backstop"); } Log *log = GetLog(LLDBLog::Step); - if (log) { - LLDB_LOGF(log, "Setting backstop breakpoint %d at address: 0x%" PRIx64, - m_backstop_bkpt_id, m_backstop_addr); - } + LLDB_LOGF(log, "Setting backstop breakpoint %d at address: 0x%" PRIx64, + m_backstop_bkpt_id, m_backstop_addr); } } } diff --git a/lldb/source/Target/UnwindLLDB.cpp b/lldb/source/Target/UnwindLLDB.cpp index 4d3f23948b48..180e062d297b 100644 --- a/lldb/source/Target/UnwindLLDB.cpp +++ b/lldb/source/Target/UnwindLLDB.cpp @@ -103,10 +103,8 @@ bool UnwindLLDB::AddFirstFrame() { unwind_done: Log *log = GetLog(LLDBLog::Unwind); - if (log) { - LLDB_LOGF(log, "th%d Unwind of this thread is complete.", - m_thread.GetIndexID()); - } + LLDB_LOGF(log, "th%d Unwind of this thread is complete.", + m_thread.GetIndexID()); m_unwind_complete = true; return false; } diff --git a/lldb/source/Utility/Listener.cpp b/lldb/source/Utility/Listener.cpp index d4ce3bf25ec5..57755e1ac5c8 100644 --- a/lldb/source/Utility/Listener.cpp +++ b/lldb/source/Utility/Listener.cpp @@ -71,12 +71,11 @@ uint32_t Listener::StartListeningForEvents(Broadcaster *broadcaster, broadcaster->AddListener(this->shared_from_this(), event_mask); Log *log = GetLog(LLDBLog::Events); - if (log != nullptr) - LLDB_LOGF(log, - "%p Listener::StartListeningForEvents (broadcaster = %p, " - "mask = 0x%8.8x) acquired_mask = 0x%8.8x for %s", - static_cast(this), static_cast(broadcaster), - event_mask, acquired_mask, m_name.c_str()); + LLDB_LOGF(log, + "%p Listener::StartListeningForEvents (broadcaster = %p, " + "mask = 0x%8.8x) acquired_mask = 0x%8.8x for %s", + static_cast(this), static_cast(broadcaster), + event_mask, acquired_mask, m_name.c_str()); return acquired_mask; } @@ -166,10 +165,9 @@ void Listener::BroadcasterManagerWillDestruct(BroadcasterManagerSP manager_sp) { void Listener::AddEvent(EventSP &event_sp) { Log *log = GetLog(LLDBLog::Events); - if (log != nullptr) - LLDB_LOGF(log, "%p Listener('%s')::AddEvent (event_sp = {%p})", - static_cast(this), m_name.c_str(), - static_cast(event_sp.get())); + LLDB_LOGF(log, "%p Listener('%s')::AddEvent (event_sp = {%p})", + static_cast(this), m_name.c_str(), + static_cast(event_sp.get())); std::lock_guard guard(m_events_mutex); m_events.push_back(event_sp); @@ -205,14 +203,13 @@ bool Listener::FindNextEventInternal( if (pos != m_events.end()) { event_sp = *pos; - if (log != nullptr) - LLDB_LOGF(log, - "%p '%s' Listener::FindNextEventInternal(broadcaster=%p, " - "event_type_mask=0x%8.8x, " - "remove=%i) event %p", - static_cast(this), GetName(), - static_cast(broadcaster), event_type_mask, remove, - static_cast(event_sp.get())); + LLDB_LOGF(log, + "%p '%s' Listener::FindNextEventInternal(broadcaster=%p, " + "event_type_mask=0x%8.8x, " + "remove=%i) event %p", + static_cast(this), GetName(), + static_cast(broadcaster), event_type_mask, remove, + static_cast(event_sp.get())); if (remove) { m_events.erase(pos); diff --git a/lldb/source/Utility/StringList.cpp b/lldb/source/Utility/StringList.cpp index 3c7c0c047125..11977dd49043 100644 --- a/lldb/source/Utility/StringList.cpp +++ b/lldb/source/Utility/StringList.cpp @@ -243,5 +243,5 @@ void StringList::LogDump(Log *log, const char *name) { if (name) strm.Printf("End %s.\n", name); - LLDB_LOGV(log, "{0}", strm.GetData()); + LLDB_LOG_VERBOSE(log, "{0}", strm.GetData()); } diff --git a/lldb/unittests/Utility/LogTest.cpp b/lldb/unittests/Utility/LogTest.cpp index edcdd84cd3a3..602d019adac5 100644 --- a/lldb/unittests/Utility/LogTest.cpp +++ b/lldb/unittests/Utility/LogTest.cpp @@ -371,7 +371,7 @@ TEST_F(LogChannelEnabledTest, LogVerboseThread) { // Start logging on one thread. Concurrently, try enabling the log channel // (with different log options). - std::thread log_thread([this] { LLDB_LOGV(getLog(), "Hello World"); }); + std::thread log_thread([this] { LLDB_LOG_VERBOSE(getLog(), "Hello World"); }); EXPECT_TRUE( EnableChannel(getLogHandler(), LLDB_LOG_OPTION_VERBOSE, "chan", {}, err)); log_thread.join();