[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/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
index 18f2a18..078543a 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
@@ -38,12 +38,13 @@
         LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
 
     if (log) {
-      log->Printf("AppleObjCExternalASTSource::FindExternalVisibleDeclsByName[%"
-                  "u] on (ASTContext*)%p Looking for %s in (%sDecl*)%p",
-                  current_id,
-                  static_cast<void *>(&decl_ctx->getParentASTContext()),
-                  name.getAsString().c_str(), decl_ctx->getDeclKindName(),
-                  static_cast<const void *>(decl_ctx));
+      LLDB_LOGF(log,
+                "AppleObjCExternalASTSource::FindExternalVisibleDeclsByName[%"
+                "u] on (ASTContext*)%p Looking for %s in (%sDecl*)%p",
+                current_id,
+                static_cast<void *>(&decl_ctx->getParentASTContext()),
+                name.getAsString().c_str(), decl_ctx->getDeclKindName(),
+                static_cast<const void *>(decl_ctx));
     }
 
     do {
@@ -77,19 +78,20 @@
         LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
 
     if (log) {
-      log->Printf("AppleObjCExternalASTSource::CompleteType[%u] on "
-                  "(ASTContext*)%p Completing (TagDecl*)%p named %s",
-                  current_id, static_cast<void *>(&tag_decl->getASTContext()),
-                  static_cast<void *>(tag_decl),
-                  tag_decl->getName().str().c_str());
+      LLDB_LOGF(log,
+                "AppleObjCExternalASTSource::CompleteType[%u] on "
+                "(ASTContext*)%p Completing (TagDecl*)%p named %s",
+                current_id, static_cast<void *>(&tag_decl->getASTContext()),
+                static_cast<void *>(tag_decl),
+                tag_decl->getName().str().c_str());
 
-      log->Printf("  AOEAS::CT[%u] Before:", current_id);
+      LLDB_LOGF(log, "  AOEAS::CT[%u] Before:", current_id);
       ASTDumper dumper((clang::Decl *)tag_decl);
       dumper.ToLog(log, "    [CT] ");
     }
 
     if (log) {
-      log->Printf("  AOEAS::CT[%u] After:", current_id);
+      LLDB_LOGF(log, "  AOEAS::CT[%u] After:", current_id);
       ASTDumper dumper((clang::Decl *)tag_decl);
       dumper.ToLog(log, "    [CT] ");
     }
@@ -104,14 +106,15 @@
         LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
 
     if (log) {
-      log->Printf("AppleObjCExternalASTSource::CompleteType[%u] on "
-                  "(ASTContext*)%p Completing (ObjCInterfaceDecl*)%p named %s",
-                  current_id,
-                  static_cast<void *>(&interface_decl->getASTContext()),
-                  static_cast<void *>(interface_decl),
-                  interface_decl->getName().str().c_str());
+      LLDB_LOGF(log,
+                "AppleObjCExternalASTSource::CompleteType[%u] on "
+                "(ASTContext*)%p Completing (ObjCInterfaceDecl*)%p named %s",
+                current_id,
+                static_cast<void *>(&interface_decl->getASTContext()),
+                static_cast<void *>(interface_decl),
+                interface_decl->getName().str().c_str());
 
-      log->Printf("  AOEAS::CT[%u] Before:", current_id);
+      LLDB_LOGF(log, "  AOEAS::CT[%u] Before:", current_id);
       ASTDumper dumper((clang::Decl *)interface_decl);
       dumper.ToLog(log, "    [CT] ");
     }
@@ -119,7 +122,7 @@
     m_decl_vendor.FinishDecl(interface_decl);
 
     if (log) {
-      log->Printf("  [CT] After:");
+      LLDB_LOGF(log, "  [CT] After:");
       ASTDumper dumper((clang::Decl *)interface_decl);
       dumper.ToLog(log, "    [CT] ");
     }
@@ -462,8 +465,7 @@
     clang::ObjCMethodDecl *method_decl =
         method_type.BuildMethod(interface_decl, name, true, m_type_realizer_sp);
 
-    if (log)
-      log->Printf("[  AOTV::FD] Instance method [%s] [%s]", name, types);
+    LLDB_LOGF(log, "[  AOTV::FD] Instance method [%s] [%s]", name, types);
 
     if (method_decl)
       interface_decl->addDecl(method_decl);
@@ -481,8 +483,7 @@
     clang::ObjCMethodDecl *method_decl = method_type.BuildMethod(
         interface_decl, name, false, m_type_realizer_sp);
 
-    if (log)
-      log->Printf("[  AOTV::FD] Class method [%s] [%s]", name, types);
+    LLDB_LOGF(log, "[  AOTV::FD] Class method [%s] [%s]", name, types);
 
     if (method_decl)
       interface_decl->addDecl(method_decl);
@@ -498,10 +499,9 @@
 
     const bool for_expression = false;
 
-    if (log)
-      log->Printf(
-          "[  AOTV::FD] Instance variable [%s] [%s], offset at %" PRIx64, name,
-          type, offset_ptr);
+    LLDB_LOGF(log,
+              "[  AOTV::FD] Instance variable [%s] [%s], offset at %" PRIx64,
+              name, type, offset_ptr);
 
     CompilerType ivar_type = m_runtime.GetEncodingToType()->RealizeType(
         m_ast_ctx, type, for_expression);
@@ -527,9 +527,10 @@
   if (log) {
     ASTDumper method_dumper((clang::Decl *)interface_decl);
 
-    log->Printf("[AppleObjCDeclVendor::FinishDecl] Finishing Objective-C "
-                "interface for %s",
-                descriptor->GetClassName().AsCString());
+    LLDB_LOGF(log,
+              "[AppleObjCDeclVendor::FinishDecl] Finishing Objective-C "
+              "interface for %s",
+              descriptor->GetClassName().AsCString());
   }
 
   if (!descriptor->Describe(superclass_func, instance_method_func,
@@ -539,7 +540,8 @@
   if (log) {
     ASTDumper method_dumper((clang::Decl *)interface_decl);
 
-    log->Printf(
+    LLDB_LOGF(
+        log,
         "[AppleObjCDeclVendor::FinishDecl] Finished Objective-C interface");
 
     method_dumper.ToLog(log, "  [AOTV::FD] ");
@@ -558,10 +560,9 @@
   Log *log(GetLogIfAllCategoriesSet(
       LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
 
-  if (log)
-    log->Printf("AppleObjCDeclVendor::FindDecls [%u] ('%s', %s, %u, )",
-                current_id, (const char *)name.AsCString(),
-                append ? "true" : "false", max_matches);
+  LLDB_LOGF(log, "AppleObjCDeclVendor::FindDecls [%u] ('%s', %s, %u, )",
+            current_id, (const char *)name.AsCString(),
+            append ? "true" : "false", max_matches);
 
   if (!append)
     decls.clear();
@@ -595,24 +596,25 @@
           if (metadata)
             isa_value = metadata->GetISAPtr();
 
-          log->Printf("AOCTV::FT [%u] Found %s (isa 0x%" PRIx64
-                      ") in the ASTContext",
-                      current_id, dumper.GetCString(), isa_value);
+          LLDB_LOGF(log,
+                    "AOCTV::FT [%u] Found %s (isa 0x%" PRIx64
+                    ") in the ASTContext",
+                    current_id, dumper.GetCString(), isa_value);
         }
 
         decls.push_back(result_iface_decl);
         ret++;
         break;
       } else {
-        if (log)
-          log->Printf("AOCTV::FT [%u] There's something in the ASTContext, but "
-                      "it's not something we know about",
-                      current_id);
+        LLDB_LOGF(log,
+                  "AOCTV::FT [%u] There's something in the ASTContext, but "
+                  "it's not something we know about",
+                  current_id);
         break;
       }
     } else if (log) {
-      log->Printf("AOCTV::FT [%u] Couldn't find %s in the ASTContext",
-                  current_id, name.AsCString());
+      LLDB_LOGF(log, "AOCTV::FT [%u] Couldn't find %s in the ASTContext",
+                current_id, name.AsCString());
     }
 
     // It's not.  If it exists, we have to put it into our ASTContext.
@@ -620,8 +622,7 @@
     ObjCLanguageRuntime::ObjCISA isa = m_runtime.GetISA(name);
 
     if (!isa) {
-      if (log)
-        log->Printf("AOCTV::FT [%u] Couldn't find the isa", current_id);
+      LLDB_LOGF(log, "AOCTV::FT [%u] Couldn't find the isa", current_id);
 
       break;
     }
@@ -629,10 +630,10 @@
     clang::ObjCInterfaceDecl *iface_decl = GetDeclForISA(isa);
 
     if (!iface_decl) {
-      if (log)
-        log->Printf("AOCTV::FT [%u] Couldn't get the Objective-C interface for "
-                    "isa 0x%" PRIx64,
-                    current_id, (uint64_t)isa);
+      LLDB_LOGF(log,
+                "AOCTV::FT [%u] Couldn't get the Objective-C interface for "
+                "isa 0x%" PRIx64,
+                current_id, (uint64_t)isa);
 
       break;
     }
@@ -641,8 +642,8 @@
       clang::QualType new_iface_type =
           ast_ctx->getObjCInterfaceType(iface_decl);
       ASTDumper dumper(new_iface_type);
-      log->Printf("AOCTV::FT [%u] Created %s (isa 0x%" PRIx64 ")", current_id,
-                  dumper.GetCString(), (uint64_t)isa);
+      LLDB_LOGF(log, "AOCTV::FT [%u] Created %s (isa 0x%" PRIx64 ")",
+                current_id, dumper.GetCString(), (uint64_t)isa);
     }
 
     decls.push_back(iface_decl);
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
index c8884fd5..88bfe2c 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
@@ -395,10 +395,11 @@
                         new ClassDescriptorV1(isa, process_sp));
 
                     if (log && log->GetVerbose())
-                      log->Printf("AppleObjCRuntimeV1 added (ObjCISA)0x%" PRIx64
-                                  " from _objc_debug_class_hash to "
-                                  "isa->descriptor cache",
-                                  isa);
+                      LLDB_LOGF(log,
+                                "AppleObjCRuntimeV1 added (ObjCISA)0x%" PRIx64
+                                " from _objc_debug_class_hash to "
+                                "isa->descriptor cache",
+                                isa);
 
                     AddClass(isa, descriptor_sp);
                   }
@@ -417,7 +418,8 @@
                           new ClassDescriptorV1(isa, process_sp));
 
                       if (log && log->GetVerbose())
-                        log->Printf(
+                        LLDB_LOGF(
+                            log,
                             "AppleObjCRuntimeV1 added (ObjCISA)0x%" PRIx64
                             " from _objc_debug_class_hash to isa->descriptor "
                             "cache",
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 635eaff..cfec2de 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1209,11 +1209,11 @@
           objc_class_sp = GetClassDescriptorFromISA(isa);
           if (isa && !objc_class_sp) {
             Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-            if (log)
-              log->Printf("0x%" PRIx64
-                          ": AppleObjCRuntimeV2::GetClassDescriptor() ISA was "
-                          "not in class descriptor cache 0x%" PRIx64,
-                          isa_pointer, isa);
+            LLDB_LOGF(log,
+                      "0x%" PRIx64
+                      ": AppleObjCRuntimeV2::GetClassDescriptor() ISA was "
+                      "not in class descriptor cache 0x%" PRIx64,
+                      isa_pointer, isa);
           }
         }
       }
@@ -1317,8 +1317,7 @@
   // Read the total number of classes from the hash table
   const uint32_t num_classes = hash_table.GetCount();
   if (num_classes == 0) {
-    if (log)
-      log->Printf("No dynamic classes found in gdb_objc_realized_classes.");
+    LLDB_LOGF(log, "No dynamic classes found in gdb_objc_realized_classes.");
     return DescriptorMapUpdateResult::Success(0);
   }
 
@@ -1337,17 +1336,16 @@
         g_get_dynamic_class_info_body, eLanguageTypeObjC,
         g_get_dynamic_class_info_name, error));
     if (error.Fail()) {
-      if (log)
-        log->Printf(
-            "Failed to get Utility Function for implementation lookup: %s",
-            error.AsCString());
+      LLDB_LOGF(log,
+                "Failed to get Utility Function for implementation lookup: %s",
+                error.AsCString());
       m_get_class_info_code.reset();
     } else {
       diagnostics.Clear();
 
       if (!m_get_class_info_code->Install(diagnostics, exe_ctx)) {
         if (log) {
-          log->Printf("Failed to install implementation lookup");
+          LLDB_LOGF(log, "Failed to install implementation lookup");
           diagnostics.Dump(log);
         }
         m_get_class_info_code.reset();
@@ -1372,17 +1370,16 @@
         clang_uint32_t_type, arguments, thread_sp, error);
 
     if (error.Fail()) {
-      if (log)
-        log->Printf(
-            "Failed to make function caller for implementation lookup: %s.",
-            error.AsCString());
+      LLDB_LOGF(log,
+                "Failed to make function caller for implementation lookup: %s.",
+                error.AsCString());
       return DescriptorMapUpdateResult::Fail();
     }
   } else {
     get_class_info_function = m_get_class_info_code->GetFunctionCaller();
     if (!get_class_info_function) {
       if (log) {
-        log->Printf("Failed to get implementation lookup function caller.");
+        LLDB_LOGF(log, "Failed to get implementation lookup function caller.");
         diagnostics.Dump(log);
       }
 
@@ -1399,10 +1396,10 @@
       class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err);
 
   if (class_infos_addr == LLDB_INVALID_ADDRESS) {
-    if (log)
-      log->Printf("unable to allocate %" PRIu32
-                  " bytes in process for shared cache read",
-                  class_infos_byte_size);
+    LLDB_LOGF(log,
+              "unable to allocate %" PRIu32
+              " bytes in process for shared cache read",
+              class_infos_byte_size);
     return DescriptorMapUpdateResult::Fail();
   }
 
@@ -1451,8 +1448,7 @@
     if (results == eExpressionCompleted) {
       // The result is the number of ClassInfo structures that were filled in
       num_class_infos = return_value.GetScalar().ULong();
-      if (log)
-        log->Printf("Discovered %u ObjC classes\n", num_class_infos);
+      LLDB_LOGF(log, "Discovered %u ObjC classes\n", num_class_infos);
       if (num_class_infos > 0) {
         // Read the ClassInfo structures
         DataBufferHeap buffer(num_class_infos * class_info_byte_size, 0);
@@ -1468,13 +1464,13 @@
       success = true;
     } else {
       if (log) {
-        log->Printf("Error evaluating our find class name function.");
+        LLDB_LOGF(log, "Error evaluating our find class name function.");
         diagnostics.Dump(log);
       }
     }
   } else {
     if (log) {
-      log->Printf("Error writing function arguments.");
+      LLDB_LOGF(log, "Error writing function arguments.");
       diagnostics.Dump(log);
     }
   }
@@ -1507,17 +1503,18 @@
 
     if (isa == 0) {
       if (should_log)
-        log->Printf(
-            "AppleObjCRuntimeV2 found NULL isa, ignoring this class info");
+        LLDB_LOGF(
+            log, "AppleObjCRuntimeV2 found NULL isa, ignoring this class info");
       continue;
     }
     // Check if we already know about this ISA, if we do, the info will never
     // change, so we can just skip it.
     if (ISAIsCached(isa)) {
       if (should_log)
-        log->Printf("AppleObjCRuntimeV2 found cached isa=0x%" PRIx64
-                    ", ignoring this class info",
-                    isa);
+        LLDB_LOGF(log,
+                  "AppleObjCRuntimeV2 found cached isa=0x%" PRIx64
+                  ", ignoring this class info",
+                  isa);
       offset += 4;
     } else {
       // Read the 32 bit hash for the class name
@@ -1536,15 +1533,16 @@
         AddClass(isa, descriptor_sp, descriptor_sp->GetClassName().AsCString(nullptr));
       num_parsed++;
       if (should_log)
-        log->Printf("AppleObjCRuntimeV2 added isa=0x%" PRIx64
-                    ", hash=0x%8.8x, name=%s",
-                    isa, name_hash,
-                    descriptor_sp->GetClassName().AsCString("<unknown>"));
+        LLDB_LOGF(log,
+                  "AppleObjCRuntimeV2 added isa=0x%" PRIx64
+                  ", hash=0x%8.8x, name=%s",
+                  isa, name_hash,
+                  descriptor_sp->GetClassName().AsCString("<unknown>"));
     }
   }
   if (should_log)
-    log->Printf("AppleObjCRuntimeV2 parsed %" PRIu32 " class infos",
-                num_parsed);
+    LLDB_LOGF(log, "AppleObjCRuntimeV2 parsed %" PRIu32 " class infos",
+              num_parsed);
   return num_parsed;
 }
 
@@ -1646,17 +1644,16 @@
             shared_class_expression.c_str(), eLanguageTypeObjC,
             g_get_shared_cache_class_info_name, error));
     if (error.Fail()) {
-      if (log)
-        log->Printf(
-            "Failed to get Utility function for implementation lookup: %s.",
-            error.AsCString());
+      LLDB_LOGF(log,
+                "Failed to get Utility function for implementation lookup: %s.",
+                error.AsCString());
       m_get_shared_cache_class_info_code.reset();
     } else {
       diagnostics.Clear();
 
       if (!m_get_shared_cache_class_info_code->Install(diagnostics, exe_ctx)) {
         if (log) {
-          log->Printf("Failed to install implementation lookup.");
+          LLDB_LOGF(log, "Failed to install implementation lookup.");
           diagnostics.Dump(log);
         }
         m_get_shared_cache_class_info_code.reset();
@@ -1703,10 +1700,10 @@
       class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err);
 
   if (class_infos_addr == LLDB_INVALID_ADDRESS) {
-    if (log)
-      log->Printf("unable to allocate %" PRIu32
-                  " bytes in process for shared cache read",
-                  class_infos_byte_size);
+    LLDB_LOGF(log,
+              "unable to allocate %" PRIu32
+              " bytes in process for shared cache read",
+              class_infos_byte_size);
     return DescriptorMapUpdateResult::Fail();
   }
 
@@ -1757,9 +1754,8 @@
     if (results == eExpressionCompleted) {
       // The result is the number of ClassInfo structures that were filled in
       num_class_infos = return_value.GetScalar().ULong();
-      if (log)
-        log->Printf("Discovered %u ObjC classes in shared cache\n",
-                    num_class_infos);
+      LLDB_LOGF(log, "Discovered %u ObjC classes in shared cache\n",
+                num_class_infos);
       assert(num_class_infos <= num_classes);
       if (num_class_infos > 0) {
         if (num_class_infos > num_classes) {
@@ -1786,13 +1782,13 @@
       }
     } else {
       if (log) {
-        log->Printf("Error evaluating our find class name function.");
+        LLDB_LOGF(log, "Error evaluating our find class name function.");
         diagnostics.Dump(log);
       }
     }
   } else {
     if (log) {
-      log->Printf("Error writing function arguments.");
+      LLDB_LOGF(log, "Error writing function arguments.");
       diagnostics.Dump(log);
     }
   }
@@ -1827,9 +1823,10 @@
           new ClassDescriptorV2(*this, elt.second, elt.first.AsCString()));
 
       if (log && log->GetVerbose())
-        log->Printf("AppleObjCRuntimeV2 added (ObjCISA)0x%" PRIx64
-                    " (%s) from dynamic table to isa->descriptor cache",
-                    elt.second, elt.first.AsCString());
+        LLDB_LOGF(log,
+                  "AppleObjCRuntimeV2 added (ObjCISA)0x%" PRIx64
+                  " (%s) from dynamic table to isa->descriptor cache",
+                  elt.second, elt.first.AsCString());
 
       AddClass(elt.second, descriptor_sp, elt.first.AsCString());
     }
@@ -1912,14 +1909,14 @@
       DescriptorMapUpdateResult shared_cache_update_result =
           UpdateISAToDescriptorMapSharedCache();
 
-      if (log)
-        log->Printf("attempted to read objc class data - results: "
-                    "[dynamic_update]: ran: %s, count: %" PRIu32
-                    " [shared_cache_update]: ran: %s, count: %" PRIu32,
-                    dynamic_update_result.m_update_ran ? "yes" : "no",
-                    dynamic_update_result.m_num_found,
-                    shared_cache_update_result.m_update_ran ? "yes" : "no",
-                    shared_cache_update_result.m_num_found);
+      LLDB_LOGF(log,
+                "attempted to read objc class data - results: "
+                "[dynamic_update]: ran: %s, count: %" PRIu32
+                " [shared_cache_update]: ran: %s, count: %" PRIu32,
+                dynamic_update_result.m_update_ran ? "yes" : "no",
+                dynamic_update_result.m_num_found,
+                shared_cache_update_result.m_update_ran ? "yes" : "no",
+                shared_cache_update_result.m_num_found);
 
       // warn if:
       // - we could not run either expression
@@ -2516,8 +2513,7 @@
     ObjCISA isa, ObjCISA &ret_isa) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES));
 
-  if (log)
-    log->Printf("AOCRT::NPI Evalulate(isa = 0x%" PRIx64 ")", (uint64_t)isa);
+  LLDB_LOGF(log, "AOCRT::NPI Evalulate(isa = 0x%" PRIx64 ")", (uint64_t)isa);
 
   if ((isa & ~m_objc_debug_isa_class_mask) == 0)
     return false;
@@ -2543,10 +2539,10 @@
       // read the count again, and update the cache if the count has been
       // updated.
       if (index > m_indexed_isa_cache.size()) {
-        if (log)
-          log->Printf("AOCRT::NPI (index = %" PRIu64
-                      ") exceeds cache (size = %" PRIu64 ")",
-                      (uint64_t)index, (uint64_t)m_indexed_isa_cache.size());
+        LLDB_LOGF(log,
+                  "AOCRT::NPI (index = %" PRIu64
+                  ") exceeds cache (size = %" PRIu64 ")",
+                  (uint64_t)index, (uint64_t)m_indexed_isa_cache.size());
 
         Process *process(m_runtime.GetProcess());
 
@@ -2561,9 +2557,8 @@
         if (error.Fail())
           return false;
 
-        if (log)
-          log->Printf("AOCRT::NPI (new class count = %" PRIu64 ")",
-                      (uint64_t)objc_indexed_classes_count);
+        LLDB_LOGF(log, "AOCRT::NPI (new class count = %" PRIu64 ")",
+                  (uint64_t)objc_indexed_classes_count);
 
         if (objc_indexed_classes_count > m_indexed_isa_cache.size()) {
           // Read the class entries we don't have.  We should just read all of
@@ -2581,9 +2576,8 @@
           if (error.Fail() || bytes_read != buffer.GetByteSize())
             return false;
 
-          if (log)
-            log->Printf("AOCRT::NPI (read new classes count = %" PRIu64 ")",
-                        (uint64_t)num_new_classes);
+          LLDB_LOGF(log, "AOCRT::NPI (read new classes count = %" PRIu64 ")",
+                    (uint64_t)num_new_classes);
 
           // Append the new entries to the existing cache.
           DataExtractor data(buffer.GetBytes(), buffer.GetByteSize(),
@@ -2600,9 +2594,8 @@
       if (index > m_indexed_isa_cache.size())
         return false;
 
-      if (log)
-        log->Printf("AOCRT::NPI Evalulate(ret_isa = 0x%" PRIx64 ")",
-                    (uint64_t)m_indexed_isa_cache[index]);
+      LLDB_LOGF(log, "AOCRT::NPI Evalulate(ret_isa = 0x%" PRIx64 ")",
+                (uint64_t)m_indexed_isa_cache[index]);
 
       ret_isa = m_indexed_isa_cache[index];
       return (ret_isa != 0); // this is a pointer so 0 is not a valid value
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index b3eb09c..f46cc1f 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -593,7 +593,7 @@
     if (log) {
       StreamString s;
       m_regions.back().Dump(s);
-      log->Printf("Read vtable region: \n%s", s.GetData());
+      LLDB_LOGF(log, "Read vtable region: \n%s", s.GetData());
     }
 
     next_region = m_regions.back().GetNextRegionAddr();
@@ -779,25 +779,24 @@
             m_lookup_implementation_function_code, eLanguageTypeObjC,
             g_lookup_implementation_function_name, error));
         if (error.Fail()) {
-          if (log)
-            log->Printf(
-                "Failed to get Utility Function for implementation lookup: %s.",
-                error.AsCString());
+          LLDB_LOGF(
+              log,
+              "Failed to get Utility Function for implementation lookup: %s.",
+              error.AsCString());
           m_impl_code.reset();
           return args_addr;
         }
 
         if (!m_impl_code->Install(diagnostics, exe_ctx)) {
           if (log) {
-            log->Printf("Failed to install implementation lookup.");
+            LLDB_LOGF(log, "Failed to install implementation lookup.");
             diagnostics.Dump(log);
           }
           m_impl_code.reset();
           return args_addr;
         }
       } else {
-        if (log)
-          log->Printf("No method lookup implementation code.");
+        LLDB_LOGF(log, "No method lookup implementation code.");
         return LLDB_INVALID_ADDRESS;
       }
 
@@ -811,10 +810,9 @@
       impl_function_caller = m_impl_code->MakeFunctionCaller(
           clang_void_ptr_type, dispatch_values, thread_sp, error);
       if (error.Fail()) {
-        if (log)
-          log->Printf(
-              "Error getting function caller for dispatch lookup: \"%s\".",
-              error.AsCString());
+        LLDB_LOGF(log,
+                  "Error getting function caller for dispatch lookup: \"%s\".",
+                  error.AsCString());
         return args_addr;
       }
     } else {
@@ -833,7 +831,7 @@
   if (!impl_function_caller->WriteFunctionArguments(
           exe_ctx, args_addr, dispatch_values, diagnostics)) {
     if (log) {
-      log->Printf("Error writing function arguments.");
+      LLDB_LOGF(log, "Error writing function arguments.");
       diagnostics.Dump(log);
     }
     return args_addr;
@@ -934,9 +932,9 @@
     lldb::addr_t obj_addr =
         argument_values.GetValueAtIndex(obj_index)->GetScalar().ULongLong();
     if (obj_addr == 0x0) {
-      if (log)
-        log->Printf(
-            "Asked to step to dispatch to nil object, returning empty plan.");
+      LLDB_LOGF(
+          log,
+          "Asked to step to dispatch to nil object, returning empty plan.");
       return ret_plan_sp;
     }
 
@@ -976,13 +974,11 @@
           if (super_value.GetScalar().IsValid())
             isa_addr = super_value.GetScalar().ULongLong();
           else {
-            if (log)
-              log->Printf("Failed to extract the super class value from the "
-                          "class in objc_super.");
+            LLDB_LOGF(log, "Failed to extract the super class value from the "
+                           "class in objc_super.");
           }
         } else {
-          if (log)
-            log->Printf("Failed to extract the class value from objc_super.");
+          LLDB_LOGF(log, "Failed to extract the class value from objc_super.");
         }
       } else {
         // In the objc_msgSendSuper case, we don't get the object
@@ -998,8 +994,7 @@
         if (super_value.GetScalar().IsValid()) {
           isa_addr = super_value.GetScalar().ULongLong();
         } else {
-          if (log)
-            log->Printf("Failed to extract the class value from objc_super.");
+          LLDB_LOGF(log, "Failed to extract the class value from objc_super.");
         }
       }
     } else {
@@ -1022,8 +1017,7 @@
       if (isa_value.GetScalar().IsValid()) {
         isa_addr = isa_value.GetScalar().ULongLong();
       } else {
-        if (log)
-          log->Printf("Failed to extract the isa value from object.");
+        LLDB_LOGF(log, "Failed to extract the isa value from object.");
       }
     }
 
@@ -1033,9 +1027,10 @@
 
     if (isa_addr != LLDB_INVALID_ADDRESS) {
       if (log) {
-        log->Printf("Resolving call for class - 0x%" PRIx64
-                    " and selector - 0x%" PRIx64,
-                    isa_addr, sel_addr);
+        LLDB_LOGF(log,
+                  "Resolving call for class - 0x%" PRIx64
+                  " and selector - 0x%" PRIx64,
+                  isa_addr, sel_addr);
       }
       ObjCLanguageRuntime *objc_runtime =
           ObjCLanguageRuntime::Get(*thread.GetProcess());
@@ -1047,9 +1042,8 @@
     if (impl_addr != LLDB_INVALID_ADDRESS) {
       // Yup, it was in the cache, so we can run to that address directly.
 
-      if (log)
-        log->Printf("Found implementation address in cache: 0x%" PRIx64,
-                    impl_addr);
+      LLDB_LOGF(log, "Found implementation address in cache: 0x%" PRIx64,
+                impl_addr);
 
       ret_plan_sp = std::make_shared<ThreadPlanRunToAddress>(thread, impl_addr,
                                                              stop_others);
@@ -1137,7 +1131,7 @@
       if (log) {
         StreamString s;
         ret_plan_sp->GetDescription(&s, eDescriptionLevelFull);
-        log->Printf("Using ObjC step plan: %s.\n", s.GetData());
+        LLDB_LOGF(log, "Using ObjC step plan: %s.\n", s.GetData());
       }
     }
   }
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
index d18435c..af630ee 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -141,17 +141,15 @@
     target_so_addr.SetOpcodeLoadAddress(target_addr, exc_ctx.GetTargetPtr());
     Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
     if (target_addr == 0) {
-      if (log)
-        log->Printf("Got target implementation of 0x0, stopping.");
+      LLDB_LOGF(log, "Got target implementation of 0x0, stopping.");
       SetPlanComplete();
       return true;
     }
     if (m_trampoline_handler->AddrIsMsgForward(target_addr)) {
-      if (log)
-        log->Printf(
-            "Implementation lookup returned msgForward function: 0x%" PRIx64
-            ", stopping.",
-            target_addr);
+      LLDB_LOGF(log,
+                "Implementation lookup returned msgForward function: 0x%" PRIx64
+                ", stopping.",
+                target_addr);
 
       SymbolContext sc = m_thread.GetStackFrameAtIndex(0)->GetSymbolContext(
           eSymbolContextEverything);
@@ -167,18 +165,17 @@
       return false;
     }
 
-    if (log)
-      log->Printf("Running to ObjC method implementation: 0x%" PRIx64,
-                  target_addr);
+    LLDB_LOGF(log, "Running to ObjC method implementation: 0x%" PRIx64,
+              target_addr);
 
     ObjCLanguageRuntime *objc_runtime =
         ObjCLanguageRuntime::Get(*GetThread().GetProcess());
     assert(objc_runtime != nullptr);
     objc_runtime->AddToMethodCache(m_isa_addr, m_sel_addr, target_addr);
-    if (log)
-      log->Printf("Adding {isa-addr=0x%" PRIx64 ", sel-addr=0x%" PRIx64
-                  "} = addr=0x%" PRIx64 " to cache.",
-                  m_isa_addr, m_sel_addr, target_addr);
+    LLDB_LOGF(log,
+              "Adding {isa-addr=0x%" PRIx64 ", sel-addr=0x%" PRIx64
+              "} = addr=0x%" PRIx64 " to cache.",
+              m_isa_addr, m_sel_addr, target_addr);
 
     // Extract the target address from the value:
 
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
index 631c15c..1e39ff1 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
@@ -64,9 +64,10 @@
                                            lldb::addr_t impl_addr) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
   if (log) {
-    log->Printf("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, lldb::addr_t>(
       ClassAndSel(class_addr, selector), impl_addr));