[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/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
index c97eb98..63600b3 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
@@ -150,23 +150,21 @@
                 g_get_item_info_function_code, eLanguageTypeObjC,
                 g_get_item_info_function_name, error));
         if (error.Fail()) {
-          if (log)
-            log->Printf("Failed to get utility function: %s.",
-                        error.AsCString());
+          LLDB_LOGF(log, "Failed to get utility function: %s.",
+                    error.AsCString());
           return args_addr;
         }
 
         if (!m_get_item_info_impl_code->Install(diagnostics, exe_ctx)) {
           if (log) {
-            log->Printf("Failed to install get-item-info introspection.");
+            LLDB_LOGF(log, "Failed to install get-item-info introspection.");
             diagnostics.Dump(log);
           }
           m_get_item_info_impl_code.reset();
           return args_addr;
         }
       } else {
-        if (log)
-          log->Printf("No get-item-info introspection code found.");
+        LLDB_LOGF(log, "No get-item-info introspection code found.");
         return LLDB_INVALID_ADDRESS;
       }
 
@@ -183,17 +181,15 @@
           get_item_info_return_type, get_item_info_arglist,
           thread.shared_from_this(), error);
       if (error.Fail() || get_item_info_caller == nullptr) {
-        if (log)
-          log->Printf("Error Inserting get-item-info function: \"%s\".",
-                      error.AsCString());
+        LLDB_LOGF(log, "Error Inserting get-item-info function: \"%s\".",
+                  error.AsCString());
         return args_addr;
       }
     } else {
       // If it's already made, then we can just retrieve the caller:
       get_item_info_caller = m_get_item_info_impl_code->GetFunctionCaller();
       if (!get_item_info_caller) {
-        if (log)
-          log->Printf("Failed to get get-item-info introspection caller.");
+        LLDB_LOGF(log, "Failed to get get-item-info introspection caller.");
         m_get_item_info_impl_code.reset();
         return args_addr;
       }
@@ -210,7 +206,7 @@
   if (!get_item_info_caller->WriteFunctionArguments(
           exe_ctx, args_addr, get_item_info_arglist, diagnostics)) {
     if (log) {
-      log->Printf("Error writing get-item-info function arguments.");
+      LLDB_LOGF(log, "Error writing get-item-info function arguments.");
       diagnostics.Dump(log);
     }
 
@@ -238,9 +234,8 @@
   error.Clear();
 
   if (!thread.SafeToCallFunctions()) {
-    if (log)
-      log->Printf("Not safe to call functions on thread 0x%" PRIx64,
-                  thread.GetID());
+    LLDB_LOGF(log, "Not safe to call functions on thread 0x%" PRIx64,
+              thread.GetID());
     error.SetErrorString("Not safe to call functions on this thread.");
     return return_value;
   }
@@ -297,9 +292,8 @@
     addr_t bufaddr = process_sp->AllocateMemory(
         32, ePermissionsReadable | ePermissionsWritable, error);
     if (!error.Success() || bufaddr == LLDB_INVALID_ADDRESS) {
-      if (log)
-        log->Printf("Failed to allocate memory for return buffer for get "
-                    "current queues func call");
+      LLDB_LOGF(log, "Failed to allocate memory for return buffer for get "
+                     "current queues func call");
       return return_value;
     }
     m_get_item_info_return_buffer_addr = bufaddr;
@@ -348,9 +342,8 @@
   Value results;
   FunctionCaller *func_caller = m_get_item_info_impl_code->GetFunctionCaller();
   if (!func_caller) {
-    if (log)
-      log->Printf("Could not retrieve function caller for "
-                  "__introspection_dispatch_queue_item_get_info.");
+    LLDB_LOGF(log, "Could not retrieve function caller for "
+                   "__introspection_dispatch_queue_item_get_info.");
     error.SetErrorString("Could not retrieve function caller for "
                          "__introspection_dispatch_queue_item_get_info.");
     return return_value;
@@ -359,11 +352,11 @@
   func_call_ret = func_caller->ExecuteFunction(exe_ctx, &args_addr, options,
                                                diagnostics, results);
   if (func_call_ret != eExpressionCompleted || !error.Success()) {
-    if (log)
-      log->Printf("Unable to call "
-                  "__introspection_dispatch_queue_item_get_info(), got "
-                  "ExpressionResults %d, error contains %s",
-                  func_call_ret, error.AsCString(""));
+    LLDB_LOGF(log,
+              "Unable to call "
+              "__introspection_dispatch_queue_item_get_info(), got "
+              "ExpressionResults %d, error contains %s",
+              func_call_ret, error.AsCString(""));
     error.SetErrorString("Unable to call "
                          "__introspection_dispatch_queue_get_item_info() for "
                          "list of queues");
@@ -385,13 +378,13 @@
     return_value.item_buffer_ptr = LLDB_INVALID_ADDRESS;
     return return_value;
   }
-  if (log)
-    log->Printf("AppleGetItemInfoHandler called "
-                "__introspection_dispatch_queue_item_get_info (page_to_free == "
-                "0x%" PRIx64 ", size = %" PRId64
-                "), returned page is at 0x%" PRIx64 ", size %" PRId64,
-                page_to_free, page_to_free_size, return_value.item_buffer_ptr,
-                return_value.item_buffer_size);
+  LLDB_LOGF(log,
+            "AppleGetItemInfoHandler called "
+            "__introspection_dispatch_queue_item_get_info (page_to_free == "
+            "0x%" PRIx64 ", size = %" PRId64 "), returned page is at 0x%" PRIx64
+            ", size %" PRId64,
+            page_to_free, page_to_free_size, return_value.item_buffer_ptr,
+            return_value.item_buffer_size);
 
   return return_value;
 }
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
index 12fad7f..ef1ea9b 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
@@ -154,24 +154,23 @@
                 g_get_pending_items_function_code, eLanguageTypeObjC,
                 g_get_pending_items_function_name, error));
         if (error.Fail()) {
-          if (log)
-            log->Printf("Failed to get UtilityFunction for pending-items "
-                        "introspection: %s.",
-                        error.AsCString());
+          LLDB_LOGF(log,
+                    "Failed to get UtilityFunction for pending-items "
+                    "introspection: %s.",
+                    error.AsCString());
           return args_addr;
         }
 
         if (!m_get_pending_items_impl_code->Install(diagnostics, exe_ctx)) {
           if (log) {
-            log->Printf("Failed to install pending-items introspection.");
+            LLDB_LOGF(log, "Failed to install pending-items introspection.");
             diagnostics.Dump(log);
           }
           m_get_pending_items_impl_code.reset();
           return args_addr;
         }
       } else {
-        if (log)
-          log->Printf("No pending-items introspection code found.");
+        LLDB_LOGF(log, "No pending-items introspection code found.");
         return LLDB_INVALID_ADDRESS;
       }
 
@@ -186,10 +185,10 @@
               get_pending_items_return_type, get_pending_items_arglist,
               thread_sp, error);
       if (error.Fail() || get_pending_items_caller == nullptr) {
-        if (log)
-          log->Printf("Failed to install pending-items introspection function "
-                      "caller: %s.",
-                      error.AsCString());
+        LLDB_LOGF(log,
+                  "Failed to install pending-items introspection function "
+                  "caller: %s.",
+                  error.AsCString());
         m_get_pending_items_impl_code.reset();
         return args_addr;
       }
@@ -199,8 +198,7 @@
   diagnostics.Clear();
 
   if (get_pending_items_caller == nullptr) {
-    if (log)
-      log->Printf("Failed to get get_pending_items_caller.");
+    LLDB_LOGF(log, "Failed to get get_pending_items_caller.");
     return LLDB_INVALID_ADDRESS;
   }
 
@@ -212,7 +210,7 @@
   if (!get_pending_items_caller->WriteFunctionArguments(
           exe_ctx, args_addr, get_pending_items_arglist, diagnostics)) {
     if (log) {
-      log->Printf("Error writing pending-items function arguments.");
+      LLDB_LOGF(log, "Error writing pending-items function arguments.");
       diagnostics.Dump(log);
     }
 
@@ -241,9 +239,8 @@
   error.Clear();
 
   if (!thread.SafeToCallFunctions()) {
-    if (log)
-      log->Printf("Not safe to call functions on thread 0x%" PRIx64,
-                  thread.GetID());
+    LLDB_LOGF(log, "Not safe to call functions on thread 0x%" PRIx64,
+              thread.GetID());
     error.SetErrorString("Not safe to call functions on this thread.");
     return return_value;
   }
@@ -303,9 +300,8 @@
     addr_t bufaddr = process_sp->AllocateMemory(
         32, ePermissionsReadable | ePermissionsWritable, error);
     if (!error.Success() || bufaddr == LLDB_INVALID_ADDRESS) {
-      if (log)
-        log->Printf("Failed to allocate memory for return buffer for get "
-                    "current queues func call");
+      LLDB_LOGF(log, "Failed to allocate memory for return buffer for get "
+                     "current queues func call");
       return return_value;
     }
     m_get_pending_items_return_buffer_addr = bufaddr;
@@ -358,11 +354,11 @@
   func_call_ret = get_pending_items_caller->ExecuteFunction(
       exe_ctx, &args_addr, options, diagnostics, results);
   if (func_call_ret != eExpressionCompleted || !error.Success()) {
-    if (log)
-      log->Printf("Unable to call "
-                  "__introspection_dispatch_queue_get_pending_items(), got "
-                  "ExpressionResults %d, error contains %s",
-                  func_call_ret, error.AsCString(""));
+    LLDB_LOGF(log,
+              "Unable to call "
+              "__introspection_dispatch_queue_get_pending_items(), got "
+              "ExpressionResults %d, error contains %s",
+              func_call_ret, error.AsCString(""));
     error.SetErrorString("Unable to call "
                          "__introspection_dispatch_queue_get_pending_items() "
                          "for list of queues");
@@ -392,14 +388,14 @@
     return return_value;
   }
 
-  if (log)
-    log->Printf("AppleGetPendingItemsHandler called "
-                "__introspection_dispatch_queue_get_pending_items "
-                "(page_to_free == 0x%" PRIx64 ", size = %" PRId64
-                "), returned page is at 0x%" PRIx64 ", size %" PRId64
-                ", count = %" PRId64,
-                page_to_free, page_to_free_size, return_value.items_buffer_ptr,
-                return_value.items_buffer_size, return_value.count);
+  LLDB_LOGF(log,
+            "AppleGetPendingItemsHandler called "
+            "__introspection_dispatch_queue_get_pending_items "
+            "(page_to_free == 0x%" PRIx64 ", size = %" PRId64
+            "), returned page is at 0x%" PRIx64 ", size %" PRId64
+            ", count = %" PRId64,
+            page_to_free, page_to_free_size, return_value.items_buffer_ptr,
+            return_value.items_buffer_size, return_value.count);
 
   return return_value;
 }
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
index e1dabae..c9df486 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
@@ -165,16 +165,16 @@
                 g_get_current_queues_function_code, eLanguageTypeC,
                 g_get_current_queues_function_name, error));
         if (error.Fail()) {
-          if (log)
-            log->Printf(
-                "Failed to get UtilityFunction for queues introspection: %s.",
-                error.AsCString());
+          LLDB_LOGF(
+              log,
+              "Failed to get UtilityFunction for queues introspection: %s.",
+              error.AsCString());
           return args_addr;
         }
 
         if (!m_get_queues_impl_code_up->Install(diagnostics, exe_ctx)) {
           if (log) {
-            log->Printf("Failed to install queues introspection");
+            LLDB_LOGF(log, "Failed to install queues introspection");
             diagnostics.Dump(log);
           }
           m_get_queues_impl_code_up.reset();
@@ -182,7 +182,7 @@
         }
       } else {
         if (log) {
-          log->Printf("No queues introspection code found.");
+          LLDB_LOGF(log, "No queues introspection code found.");
           diagnostics.Dump(log);
         }
         return LLDB_INVALID_ADDRESS;
@@ -198,10 +198,9 @@
     get_queues_caller = m_get_queues_impl_code_up->MakeFunctionCaller(
         get_queues_return_type, get_queues_arglist, thread_sp, error);
     if (error.Fail() || get_queues_caller == nullptr) {
-      if (log)
-        log->Printf(
-            "Could not get function caller for get-queues function: %s.",
-            error.AsCString());
+      LLDB_LOGF(log,
+                "Could not get function caller for get-queues function: %s.",
+                error.AsCString());
       return args_addr;
     }
   }
@@ -216,7 +215,7 @@
   if (!get_queues_caller->WriteFunctionArguments(
           exe_ctx, args_addr, get_queues_arglist, diagnostics)) {
     if (log) {
-      log->Printf("Error writing get-queues function arguments.");
+      LLDB_LOGF(log, "Error writing get-queues function arguments.");
       diagnostics.Dump(log);
     }
     return args_addr;
@@ -243,9 +242,8 @@
   error.Clear();
 
   if (!thread.SafeToCallFunctions()) {
-    if (log)
-      log->Printf("Not safe to call functions on thread 0x%" PRIx64,
-                  thread.GetID());
+    LLDB_LOGF(log, "Not safe to call functions on thread 0x%" PRIx64,
+              thread.GetID());
     error.SetErrorString("Not safe to call functions on this thread.");
     return return_value;
   }
@@ -299,9 +297,8 @@
     addr_t bufaddr = process_sp->AllocateMemory(
         32, ePermissionsReadable | ePermissionsWritable, error);
     if (!error.Success() || bufaddr == LLDB_INVALID_ADDRESS) {
-      if (log)
-        log->Printf("Failed to allocate memory for return buffer for get "
-                    "current queues func call");
+      LLDB_LOGF(log, "Failed to allocate memory for return buffer for get "
+                     "current queues func call");
       return return_value;
     }
     m_get_queues_return_buffer_addr = bufaddr;
@@ -357,10 +354,10 @@
   func_call_ret = get_queues_caller->ExecuteFunction(
       exe_ctx, &args_addr, options, diagnostics, results);
   if (func_call_ret != eExpressionCompleted || !error.Success()) {
-    if (log)
-      log->Printf("Unable to call introspection_get_dispatch_queues(), got "
-                  "ExpressionResults %d, error contains %s",
-                  func_call_ret, error.AsCString(""));
+    LLDB_LOGF(log,
+              "Unable to call introspection_get_dispatch_queues(), got "
+              "ExpressionResults %d, error contains %s",
+              func_call_ret, error.AsCString(""));
     error.SetErrorString("Unable to call introspection_get_dispatch_queues() "
                          "for list of queues");
     return return_value;
@@ -389,14 +386,13 @@
     return return_value;
   }
 
-  if (log)
-    log->Printf("AppleGetQueuesHandler called "
-                "__introspection_dispatch_get_queues (page_to_free == "
-                "0x%" PRIx64 ", size = %" PRId64
-                "), returned page is at 0x%" PRIx64 ", size %" PRId64
-                ", count = %" PRId64,
-                page_to_free, page_to_free_size, return_value.queues_buffer_ptr,
-                return_value.queues_buffer_size, return_value.count);
+  LLDB_LOGF(log,
+            "AppleGetQueuesHandler called "
+            "__introspection_dispatch_get_queues (page_to_free == "
+            "0x%" PRIx64 ", size = %" PRId64 "), returned page is at 0x%" PRIx64
+            ", size %" PRId64 ", count = %" PRId64,
+            page_to_free, page_to_free_size, return_value.queues_buffer_ptr,
+            return_value.queues_buffer_size, return_value.count);
 
   return return_value;
 }
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
index 7d0cbc0..fd4d21d 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
@@ -160,18 +160,18 @@
                 g_get_thread_item_info_function_code, eLanguageTypeC,
                 g_get_thread_item_info_function_name, error));
         if (error.Fail()) {
-          if (log)
-            log->Printf("Failed to get UtilityFunction for "
-                        "get-thread-item-info introspection: %s.",
-                        error.AsCString());
+          LLDB_LOGF(log,
+                    "Failed to get UtilityFunction for "
+                    "get-thread-item-info introspection: %s.",
+                    error.AsCString());
           m_get_thread_item_info_impl_code.reset();
           return args_addr;
         }
 
         if (!m_get_thread_item_info_impl_code->Install(diagnostics, exe_ctx)) {
           if (log) {
-            log->Printf(
-                "Failed to install get-thread-item-info introspection.");
+            LLDB_LOGF(log,
+                      "Failed to install get-thread-item-info introspection.");
             diagnostics.Dump(log);
           }
 
@@ -179,8 +179,7 @@
           return args_addr;
         }
       } else {
-        if (log)
-          log->Printf("No get-thread-item-info introspection code found.");
+        LLDB_LOGF(log, "No get-thread-item-info introspection code found.");
         return LLDB_INVALID_ADDRESS;
       }
 
@@ -196,10 +195,10 @@
               get_thread_item_info_return_type, get_thread_item_info_arglist,
               thread_sp, error);
       if (error.Fail() || get_thread_item_info_caller == nullptr) {
-        if (log)
-          log->Printf("Failed to install get-thread-item-info introspection "
-                      "caller: %s.",
-                      error.AsCString());
+        LLDB_LOGF(log,
+                  "Failed to install get-thread-item-info introspection "
+                  "caller: %s.",
+                  error.AsCString());
         m_get_thread_item_info_impl_code.reset();
         return args_addr;
       }
@@ -220,7 +219,7 @@
   if (!get_thread_item_info_caller->WriteFunctionArguments(
           exe_ctx, args_addr, get_thread_item_info_arglist, diagnostics)) {
     if (log) {
-      log->Printf("Error writing get-thread-item-info function arguments");
+      LLDB_LOGF(log, "Error writing get-thread-item-info function arguments");
       diagnostics.Dump(log);
     }
     return args_addr;
@@ -248,9 +247,8 @@
   error.Clear();
 
   if (!thread.SafeToCallFunctions()) {
-    if (log)
-      log->Printf("Not safe to call functions on thread 0x%" PRIx64,
-                  thread.GetID());
+    LLDB_LOGF(log, "Not safe to call functions on thread 0x%" PRIx64,
+              thread.GetID());
     error.SetErrorString("Not safe to call functions on this thread.");
     return return_value;
   }
@@ -305,9 +303,8 @@
     addr_t bufaddr = process_sp->AllocateMemory(
         32, ePermissionsReadable | ePermissionsWritable, error);
     if (!error.Success() || bufaddr == LLDB_INVALID_ADDRESS) {
-      if (log)
-        log->Printf("Failed to allocate memory for return buffer for get "
-                    "current queues func call");
+      LLDB_LOGF(log, "Failed to allocate memory for return buffer for get "
+                     "current queues func call");
       return return_value;
     }
     m_get_thread_item_info_return_buffer_addr = bufaddr;
@@ -369,11 +366,11 @@
   func_call_ret = get_thread_item_info_caller->ExecuteFunction(
       exe_ctx, &args_addr, options, diagnostics, results);
   if (func_call_ret != eExpressionCompleted || !error.Success()) {
-    if (log)
-      log->Printf("Unable to call "
-                  "__introspection_dispatch_thread_get_item_info(), got "
-                  "ExpressionResults %d, error contains %s",
-                  func_call_ret, error.AsCString(""));
+    LLDB_LOGF(log,
+              "Unable to call "
+              "__introspection_dispatch_thread_get_item_info(), got "
+              "ExpressionResults %d, error contains %s",
+              func_call_ret, error.AsCString(""));
     error.SetErrorString("Unable to call "
                          "__introspection_dispatch_thread_get_item_info() for "
                          "list of queues");
@@ -397,13 +394,13 @@
     return return_value;
   }
 
-  if (log)
-    log->Printf("AppleGetThreadItemInfoHandler called "
-                "__introspection_dispatch_thread_get_item_info (page_to_free "
-                "== 0x%" PRIx64 ", size = %" PRId64
-                "), returned page is at 0x%" PRIx64 ", size %" PRId64,
-                page_to_free, page_to_free_size, return_value.item_buffer_ptr,
-                return_value.item_buffer_size);
+  LLDB_LOGF(log,
+            "AppleGetThreadItemInfoHandler called "
+            "__introspection_dispatch_thread_get_item_info (page_to_free "
+            "== 0x%" PRIx64 ", size = %" PRId64
+            "), returned page is at 0x%" PRIx64 ", size %" PRId64,
+            page_to_free, page_to_free_size, return_value.item_buffer_ptr,
+            return_value.item_buffer_size);
 
   return return_value;
 }
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
index dfcc6ac..4e384bd 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
@@ -927,13 +927,13 @@
       offset_t start_of_next_item = start_of_this_item + offset_to_next;
       offset = start_of_next_item;
 
-      if (log)
-        log->Printf("SystemRuntimeMacOSX::PopulateQueuesUsingLibBTR added "
-                    "queue with dispatch_queue_t 0x%" PRIx64
-                    ", serial number 0x%" PRIx64
-                    ", running items %d, pending items %d, name '%s'",
-                    queue, serialnum, running_work_items_count,
-                    pending_work_items_count, queue_label);
+      LLDB_LOGF(log,
+                "SystemRuntimeMacOSX::PopulateQueuesUsingLibBTR added "
+                "queue with dispatch_queue_t 0x%" PRIx64
+                ", serial number 0x%" PRIx64
+                ", running items %d, pending items %d, name '%s'",
+                queue, serialnum, running_work_items_count,
+                pending_work_items_count, queue_label);
 
       QueueSP queue_sp(
           new Queue(m_process->shared_from_this(), serialnum, queue_label));