[Logging] Replace Log::Printf with LLDB_LOG macro (NFC)
This patch replaces explicit calls to log::Printf with the new LLDB_LOGF
macro. The macro is similar to LLDB_LOG but supports printf-style format
strings, instead of formatv-style format strings.
So instead of writing:
if (log)
log->Printf("%s\n", str);
You'd write:
LLDB_LOG(log, "%s\n", str);
This change was done mechanically with the command below. I replaced the
spurious if-checks with vim, since I know how to do multi-line
replacements with it.
find . -type f -name '*.cpp' -exec \
sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" +
Differential revision: https://reviews.llvm.org/D65128
llvm-svn: 366936
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp
index 172d2b3..35510a2 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -271,13 +271,13 @@
if (data_sp)
m_data.SetData(data_sp, data_offset, length);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p ObjectFile::ObjectFile() module = %p (%s), file = %s, "
- "file_offset = 0x%8.8" PRIx64 ", size = %" PRIu64,
- static_cast<void *>(this), static_cast<void *>(module_sp.get()),
- module_sp->GetSpecificationDescription().c_str(),
- m_file ? m_file.GetPath().c_str() : "<NULL>", m_file_offset,
- m_length);
+ LLDB_LOGF(log,
+ "%p ObjectFile::ObjectFile() module = %p (%s), file = %s, "
+ "file_offset = 0x%8.8" PRIx64 ", size = %" PRIu64,
+ static_cast<void *>(this), static_cast<void *>(module_sp.get()),
+ module_sp->GetSpecificationDescription().c_str(),
+ m_file ? m_file.GetPath().c_str() : "<NULL>", m_file_offset,
+ m_length);
}
ObjectFile::ObjectFile(const lldb::ModuleSP &module_sp,
@@ -290,18 +290,17 @@
if (header_data_sp)
m_data.SetData(header_data_sp, 0, header_data_sp->GetByteSize());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p ObjectFile::ObjectFile() module = %p (%s), process = %p, "
- "header_addr = 0x%" PRIx64,
- static_cast<void *>(this), static_cast<void *>(module_sp.get()),
- module_sp->GetSpecificationDescription().c_str(),
- static_cast<void *>(process_sp.get()), m_memory_addr);
+ LLDB_LOGF(log,
+ "%p ObjectFile::ObjectFile() module = %p (%s), process = %p, "
+ "header_addr = 0x%" PRIx64,
+ static_cast<void *>(this), static_cast<void *>(module_sp.get()),
+ module_sp->GetSpecificationDescription().c_str(),
+ static_cast<void *>(process_sp.get()), m_memory_addr);
}
ObjectFile::~ObjectFile() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p ObjectFile::~ObjectFile ()\n", static_cast<void *>(this));
+ LLDB_LOGF(log, "%p ObjectFile::~ObjectFile ()\n", static_cast<void *>(this));
}
bool ObjectFile::SetModulesArchitecture(const ArchSpec &new_arch) {
@@ -595,10 +594,9 @@
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p ObjectFile::ClearSymtab () symtab = %p",
- static_cast<void *>(this),
- static_cast<void *>(m_symtab_up.get()));
+ LLDB_LOGF(log, "%p ObjectFile::ClearSymtab () symtab = %p",
+ static_cast<void *>(this),
+ static_cast<void *>(m_symtab_up.get()));
m_symtab_up.reset();
}
}