[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/Process/gdb-remote/GDBRemoteClientBase.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
index fe7ef6b..140e243 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
@@ -63,18 +63,16 @@
     case PacketResult::Success:
       break;
     default:
-      if (log)
-        log->Printf("GDBRemoteClientBase::%s () ReadPacket(...) => false",
-                    __FUNCTION__);
+      LLDB_LOGF(log, "GDBRemoteClientBase::%s () ReadPacket(...) => false",
+                __FUNCTION__);
       return eStateInvalid;
     }
     if (response.Empty())
       return eStateInvalid;
 
     const char stop_type = response.GetChar();
-    if (log)
-      log->Printf("GDBRemoteClientBase::%s () got packet: %s", __FUNCTION__,
-                  response.GetStringRef().c_str());
+    LLDB_LOGF(log, "GDBRemoteClientBase::%s () got packet: %s", __FUNCTION__,
+              response.GetStringRef().c_str());
 
     switch (stop_type) {
     case 'W':
@@ -84,9 +82,8 @@
       // ERROR
       return eStateInvalid;
     default:
-      if (log)
-        log->Printf("GDBRemoteClientBase::%s () unrecognized async packet",
-                    __FUNCTION__);
+      LLDB_LOGF(log, "GDBRemoteClientBase::%s () unrecognized async packet",
+                __FUNCTION__);
       return eStateInvalid;
     case 'O': {
       std::string inferior_stdout;
@@ -162,10 +159,10 @@
   if (!lock) {
     if (Log *log =
             ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS))
-      log->Printf("GDBRemoteClientBase::%s failed to get mutex, not sending "
-                  "packet '%.*s' (send_async=%d)",
-                  __FUNCTION__, int(payload.size()), payload.data(),
-                  send_async);
+      LLDB_LOGF(log,
+                "GDBRemoteClientBase::%s failed to get mutex, not sending "
+                "packet '%.*s' (send_async=%d)",
+                __FUNCTION__, int(payload.size()), payload.data(), send_async);
     return PacketResult::ErrorSendFailed;
   }
 
@@ -181,10 +178,10 @@
   if (!lock) {
     if (Log *log =
             ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS))
-      log->Printf("GDBRemoteClientBase::%s failed to get mutex, not sending "
-                  "packet '%.*s' (send_async=%d)",
-                  __FUNCTION__, int(payload.size()), payload.data(),
-                  send_async);
+      LLDB_LOGF(log,
+                "GDBRemoteClientBase::%s failed to get mutex, not sending "
+                "packet '%.*s' (send_async=%d)",
+                __FUNCTION__, int(payload.size()), payload.data(), send_async);
     return PacketResult::ErrorSendFailed;
   }
 
@@ -214,13 +211,13 @@
       return packet_result;
     // Response says it wasn't valid
     Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS);
-    if (log)
-      log->Printf(
-          "error: packet with payload \"%.*s\" got invalid response \"%s\": %s",
-          int(payload.size()), payload.data(), response.GetStringRef().c_str(),
-          (i == (max_response_retries - 1))
-              ? "using invalid response and giving up"
-              : "ignoring response and waiting for another");
+    LLDB_LOGF(
+        log,
+        "error: packet with payload \"%.*s\" got invalid response \"%s\": %s",
+        int(payload.size()), payload.data(), response.GetStringRef().c_str(),
+        (i == (max_response_retries - 1))
+            ? "using invalid response and giving up"
+            : "ignoring response and waiting for another");
   }
   return packet_result;
 }
@@ -228,16 +225,14 @@
 bool GDBRemoteClientBase::SendvContPacket(llvm::StringRef payload,
                                           StringExtractorGDBRemote &response) {
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-  if (log)
-    log->Printf("GDBRemoteCommunicationClient::%s ()", __FUNCTION__);
+  LLDB_LOGF(log, "GDBRemoteCommunicationClient::%s ()", __FUNCTION__);
 
   // we want to lock down packet sending while we continue
   Lock lock(*this, true);
 
-  if (log)
-    log->Printf(
-        "GDBRemoteCommunicationClient::%s () sending vCont packet: %.*s",
-        __FUNCTION__, int(payload.size()), payload.data());
+  LLDB_LOGF(log,
+            "GDBRemoteCommunicationClient::%s () sending vCont packet: %.*s",
+            __FUNCTION__, int(payload.size()), payload.data());
 
   if (SendPacketNoLock(payload) != PacketResult::Success)
     return false;
@@ -315,18 +310,16 @@
 GDBRemoteClientBase::ContinueLock::LockResult
 GDBRemoteClientBase::ContinueLock::lock() {
   Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS);
-  if (log)
-    log->Printf("GDBRemoteClientBase::ContinueLock::%s() resuming with %s",
-                __FUNCTION__, m_comm.m_continue_packet.c_str());
+  LLDB_LOGF(log, "GDBRemoteClientBase::ContinueLock::%s() resuming with %s",
+            __FUNCTION__, m_comm.m_continue_packet.c_str());
 
   lldbassert(!m_acquired);
   std::unique_lock<std::mutex> lock(m_comm.m_mutex);
   m_comm.m_cv.wait(lock, [this] { return m_comm.m_async_count == 0; });
   if (m_comm.m_should_stop) {
     m_comm.m_should_stop = false;
-    if (log)
-      log->Printf("GDBRemoteClientBase::ContinueLock::%s() cancelled",
-                  __FUNCTION__);
+    LLDB_LOGF(log, "GDBRemoteClientBase::ContinueLock::%s() cancelled",
+              __FUNCTION__);
     return LockResult::Cancelled;
   }
   if (m_comm.SendPacketNoLock(m_comm.m_continue_packet) !=
@@ -368,9 +361,8 @@
       size_t bytes_written = m_comm.Write(&ctrl_c, 1, status, nullptr);
       if (bytes_written == 0) {
         --m_comm.m_async_count;
-        if (log)
-          log->Printf("GDBRemoteClientBase::Lock::Lock failed to send "
-                      "interrupt packet");
+        LLDB_LOGF(log, "GDBRemoteClientBase::Lock::Lock failed to send "
+                       "interrupt packet");
         return;
       }
       if (log)
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 11052ef..23a069d 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -99,8 +99,7 @@
   ConnectionStatus status = eConnectionStatusSuccess;
   char ch = '+';
   const size_t bytes_written = Write(&ch, 1, status, nullptr);
-  if (log)
-    log->Printf("<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
+  LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
   m_history.AddPacket(ch, GDBRemoteCommunicationHistory::ePacketTypeSend,
                       bytes_written);
   return bytes_written;
@@ -111,8 +110,7 @@
   ConnectionStatus status = eConnectionStatusSuccess;
   char ch = '-';
   const size_t bytes_written = Write(&ch, 1, status, nullptr);
-  if (log)
-    log->Printf("<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
+  LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
   m_history.AddPacket(ch, GDBRemoteCommunicationHistory::ePacketTypeSend,
                       bytes_written);
   return bytes_written;
@@ -172,8 +170,8 @@
         strm.Printf("%*s", (int)3, p);
         log->PutString(strm.GetString());
       } else
-        log->Printf("<%4" PRIu64 "> send packet: %.*s", (uint64_t)bytes_written,
-                    (int)packet_length, packet_data);
+        LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %.*s",
+                  (uint64_t)bytes_written, (int)packet_length, packet_data);
     }
 
     m_history.AddPacket(packet.str(), packet_length,
@@ -186,9 +184,8 @@
       else
         return PacketResult::Success;
     } else {
-      if (log)
-        log->Printf("error: failed to send packet: %.*s", (int)packet_length,
-                    packet_data);
+      LLDB_LOGF(log, "error: failed to send packet: %.*s", (int)packet_length,
+                packet_data);
     }
   }
   return PacketResult::ErrorSendFailed;
@@ -489,11 +486,10 @@
         llvm::StringRef(m_bytes).substr(1, hash_mark_idx - 1));
     bool success = packet_checksum == actual_checksum;
     if (!success) {
-      if (log)
-        log->Printf(
-            "error: checksum mismatch: %.*s expected 0x%2.2x, got 0x%2.2x",
-            (int)(pkt_size), m_bytes.c_str(), (uint8_t)packet_checksum,
-            (uint8_t)actual_checksum);
+      LLDB_LOGF(log,
+                "error: checksum mismatch: %.*s expected 0x%2.2x, got 0x%2.2x",
+                (int)(pkt_size), m_bytes.c_str(), (uint8_t)packet_checksum,
+                (uint8_t)actual_checksum);
     }
     // Send the ack or nack if needed
     if (!success) {
@@ -651,8 +647,8 @@
   if (src && src_len > 0) {
     if (log && log->GetVerbose()) {
       StreamString s;
-      log->Printf("GDBRemoteCommunication::%s adding %u bytes: %.*s",
-                  __FUNCTION__, (uint32_t)src_len, (uint32_t)src_len, src);
+      LLDB_LOGF(log, "GDBRemoteCommunication::%s adding %u bytes: %.*s",
+                __FUNCTION__, (uint32_t)src_len, (uint32_t)src_len, src);
     }
     m_bytes.append((const char *)src, src_len);
   }
@@ -733,9 +729,8 @@
           break;
         }
       }
-      if (log)
-        log->Printf("GDBRemoteCommunication::%s tossing %u junk bytes: '%.*s'",
-                    __FUNCTION__, idx - 1, idx - 1, m_bytes.c_str());
+      LLDB_LOGF(log, "GDBRemoteCommunication::%s tossing %u junk bytes: '%.*s'",
+                __FUNCTION__, idx - 1, idx - 1, m_bytes.c_str());
       m_bytes.erase(0, idx - 1);
     } break;
     }
@@ -800,13 +795,13 @@
           log->PutString(strm.GetString());
         } else {
           if (CompressionIsEnabled())
-            log->Printf("<%4" PRIu64 ":%" PRIu64 "> read packet: %.*s",
-                        (uint64_t)original_packet_size, (uint64_t)total_length,
-                        (int)(total_length), m_bytes.c_str());
+            LLDB_LOGF(log, "<%4" PRIu64 ":%" PRIu64 "> read packet: %.*s",
+                      (uint64_t)original_packet_size, (uint64_t)total_length,
+                      (int)(total_length), m_bytes.c_str());
           else
-            log->Printf("<%4" PRIu64 "> read packet: %.*s",
-                        (uint64_t)total_length, (int)(total_length),
-                        m_bytes.c_str());
+            LLDB_LOGF(log, "<%4" PRIu64 "> read packet: %.*s",
+                      (uint64_t)total_length, (int)(total_length),
+                      m_bytes.c_str());
         }
       }
 
@@ -853,11 +848,11 @@
                 llvm::StringRef(m_bytes).slice(content_start, content_end));
             success = packet_checksum == actual_checksum;
             if (!success) {
-              if (log)
-                log->Printf("error: checksum mismatch: %.*s expected 0x%2.2x, "
-                            "got 0x%2.2x",
-                            (int)(total_length), m_bytes.c_str(),
-                            (uint8_t)packet_checksum, (uint8_t)actual_checksum);
+              LLDB_LOGF(log,
+                        "error: checksum mismatch: %.*s expected 0x%2.2x, "
+                        "got 0x%2.2x",
+                        (int)(total_length), m_bytes.c_str(),
+                        (uint8_t)packet_checksum, (uint8_t)actual_checksum);
             }
             // Send the ack or nack if needed
             if (!success)
@@ -867,9 +862,8 @@
           }
         } else {
           success = false;
-          if (log)
-            log->Printf("error: invalid checksum in packet: '%s'\n",
-                        m_bytes.c_str());
+          LLDB_LOGF(log, "error: invalid checksum in packet: '%s'\n",
+                    m_bytes.c_str());
         }
       }
 
@@ -933,10 +927,8 @@
     const char *url, Platform *platform, ProcessLaunchInfo &launch_info,
     uint16_t *port, const Args *inferior_args, int pass_comm_fd) {
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-  if (log)
-    log->Printf("GDBRemoteCommunication::%s(url=%s, port=%" PRIu16 ")",
-                __FUNCTION__, url ? url : "<empty>",
-                port ? *port : uint16_t(0));
+  LLDB_LOGF(log, "GDBRemoteCommunication::%s(url=%s, port=%" PRIu16 ")",
+            __FUNCTION__, url ? url : "<empty>", port ? *port : uint16_t(0));
 
   Status error;
   // If we locate debugserver, keep that located version around
@@ -953,10 +945,10 @@
   if (!env_debugserver_path.empty()) {
     debugserver_file_spec.SetFile(env_debugserver_path,
                                   FileSpec::Style::native);
-    if (log)
-      log->Printf("GDBRemoteCommunication::%s() gdb-remote stub exe path set "
-                  "from environment variable: %s",
-                  __FUNCTION__, env_debugserver_path.c_str());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunication::%s() gdb-remote stub exe path set "
+              "from environment variable: %s",
+              __FUNCTION__, env_debugserver_path.c_str());
   } else
     debugserver_file_spec = g_debugserver_file_spec;
   bool debugserver_exists =
@@ -968,10 +960,9 @@
       debugserver_file_spec.AppendPathComponent(DEBUGSERVER_BASENAME);
       debugserver_exists = FileSystem::Instance().Exists(debugserver_file_spec);
       if (debugserver_exists) {
-        if (log)
-          log->Printf(
-              "GDBRemoteCommunication::%s() found gdb-remote stub exe '%s'",
-              __FUNCTION__, debugserver_file_spec.GetPath().c_str());
+        LLDB_LOGF(log,
+                  "GDBRemoteCommunication::%s() found gdb-remote stub exe '%s'",
+                  __FUNCTION__, debugserver_file_spec.GetPath().c_str());
 
         g_debugserver_file_spec = debugserver_file_spec;
       } else {
@@ -985,10 +976,10 @@
           // exist
           debugserver_exists = true;
         } else {
-          if (log)
-            log->Printf("GDBRemoteCommunication::%s() could not find "
-                        "gdb-remote stub exe '%s'",
-                        __FUNCTION__, debugserver_file_spec.GetPath().c_str());
+          LLDB_LOGF(log,
+                    "GDBRemoteCommunication::%s() could not find "
+                    "gdb-remote stub exe '%s'",
+                    __FUNCTION__, debugserver_file_spec.GetPath().c_str());
         }
         // Don't cache the platform specific GDB server binary as it could
         // change from platform to platform
@@ -1052,10 +1043,10 @@
         error = socket_pipe.CreateWithUniqueName("debugserver-named-pipe",
                                                  false, named_pipe_path);
         if (error.Fail()) {
-          if (log)
-            log->Printf("GDBRemoteCommunication::%s() "
-                        "named pipe creation failed: %s",
-                        __FUNCTION__, error.AsCString());
+          LLDB_LOGF(log,
+                    "GDBRemoteCommunication::%s() "
+                    "named pipe creation failed: %s",
+                    __FUNCTION__, error.AsCString());
           return error;
         }
         debugserver_args.AppendArgument(llvm::StringRef("--named-pipe"));
@@ -1065,10 +1056,10 @@
         // using using an unnamed pipe...
         error = socket_pipe.CreateNew(true);
         if (error.Fail()) {
-          if (log)
-            log->Printf("GDBRemoteCommunication::%s() "
-                        "unnamed pipe creation failed: %s",
-                        __FUNCTION__, error.AsCString());
+          LLDB_LOGF(log,
+                    "GDBRemoteCommunication::%s() "
+                    "unnamed pipe creation failed: %s",
+                    __FUNCTION__, error.AsCString());
           return error;
         }
         pipe_t write = socket_pipe.GetWritePipe();
@@ -1081,10 +1072,10 @@
         // debugserver connect to us..
         error = StartListenThread("127.0.0.1", 0);
         if (error.Fail()) {
-          if (log)
-            log->Printf("GDBRemoteCommunication::%s() unable to start listen "
-                        "thread: %s",
-                        __FUNCTION__, error.AsCString());
+          LLDB_LOGF(log,
+                    "GDBRemoteCommunication::%s() unable to start listen "
+                    "thread: %s",
+                    __FUNCTION__, error.AsCString());
           return error;
         }
 
@@ -1104,9 +1095,8 @@
             *port = port_;
         } else {
           error.SetErrorString("failed to bind to port 0 on 127.0.0.1");
-          if (log)
-            log->Printf("GDBRemoteCommunication::%s() failed: %s", __FUNCTION__,
-                        error.AsCString());
+          LLDB_LOGF(log, "GDBRemoteCommunication::%s() failed: %s",
+                    __FUNCTION__, error.AsCString());
           return error;
         }
       }
@@ -1148,10 +1138,10 @@
 
       if (has_env_var) {
         debugserver_args.AppendArgument(llvm::StringRef(extra_arg));
-        if (log)
-          log->Printf("GDBRemoteCommunication::%s adding env var %s contents "
-                      "to stub command line (%s)",
-                      __FUNCTION__, env_var_name, extra_arg.c_str());
+        LLDB_LOGF(log,
+                  "GDBRemoteCommunication::%s adding env var %s contents "
+                  "to stub command line (%s)",
+                  __FUNCTION__, env_var_name, extra_arg.c_str());
       }
     } while (has_env_var);
 
@@ -1177,8 +1167,8 @@
       StreamString string_stream;
       Platform *const platform = nullptr;
       launch_info.Dump(string_stream, platform);
-      log->Printf("launch info for gdb-remote stub:\n%s",
-                  string_stream.GetData());
+      LLDB_LOGF(log, "launch info for gdb-remote stub:\n%s",
+                string_stream.GetData());
     }
     error = Host::LaunchProcess(launch_info);
 
@@ -1188,11 +1178,10 @@
       if (named_pipe_path.size() > 0) {
         error = socket_pipe.OpenAsReader(named_pipe_path, false);
         if (error.Fail())
-          if (log)
-            log->Printf("GDBRemoteCommunication::%s() "
-                        "failed to open named pipe %s for reading: %s",
-                        __FUNCTION__, named_pipe_path.c_str(),
-                        error.AsCString());
+          LLDB_LOGF(log,
+                    "GDBRemoteCommunication::%s() "
+                    "failed to open named pipe %s for reading: %s",
+                    __FUNCTION__, named_pipe_path.c_str(), error.AsCString());
       }
 
       if (socket_pipe.CanWrite())
@@ -1209,24 +1198,22 @@
           uint16_t child_port = StringConvert::ToUInt32(port_cstr, 0);
           if (*port == 0 || *port == child_port) {
             *port = child_port;
-            if (log)
-              log->Printf("GDBRemoteCommunication::%s() "
-                          "debugserver listens %u port",
-                          __FUNCTION__, *port);
+            LLDB_LOGF(log,
+                      "GDBRemoteCommunication::%s() "
+                      "debugserver listens %u port",
+                      __FUNCTION__, *port);
           } else {
-            if (log)
-              log->Printf("GDBRemoteCommunication::%s() "
-                          "debugserver listening on port "
-                          "%d but requested port was %d",
-                          __FUNCTION__, (uint32_t)child_port,
-                          (uint32_t)(*port));
+            LLDB_LOGF(log,
+                      "GDBRemoteCommunication::%s() "
+                      "debugserver listening on port "
+                      "%d but requested port was %d",
+                      __FUNCTION__, (uint32_t)child_port, (uint32_t)(*port));
           }
         } else {
-          if (log)
-            log->Printf("GDBRemoteCommunication::%s() "
-                        "failed to read a port value from pipe %s: %s",
-                        __FUNCTION__, named_pipe_path.c_str(),
-                        error.AsCString());
+          LLDB_LOGF(log,
+                    "GDBRemoteCommunication::%s() "
+                    "failed to read a port value from pipe %s: %s",
+                    __FUNCTION__, named_pipe_path.c_str(), error.AsCString());
         }
         socket_pipe.Close();
       }
@@ -1234,10 +1221,9 @@
       if (named_pipe_path.size() > 0) {
         const auto err = socket_pipe.Delete(named_pipe_path);
         if (err.Fail()) {
-          if (log)
-            log->Printf(
-                "GDBRemoteCommunication::%s failed to delete pipe %s: %s",
-                __FUNCTION__, named_pipe_path.c_str(), err.AsCString());
+          LLDB_LOGF(log,
+                    "GDBRemoteCommunication::%s failed to delete pipe %s: %s",
+                    __FUNCTION__, named_pipe_path.c_str(), err.AsCString());
         }
       }
 
@@ -1249,9 +1235,8 @@
   }
 
   if (error.Fail()) {
-    if (log)
-      log->Printf("GDBRemoteCommunication::%s() failed: %s", __FUNCTION__,
-                  error.AsCString());
+    LLDB_LOGF(log, "GDBRemoteCommunication::%s() failed: %s", __FUNCTION__,
+              error.AsCString());
   }
 
   return error;
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 9797184..8ebeaf0 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -439,8 +439,7 @@
         m_max_packet_size = UINT64_MAX; // Must have been a garbled response
         Log *log(
             ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-        if (log)
-          log->Printf("Garbled PacketSize spec in qSupported response");
+        LLDB_LOGF(log, "Garbled PacketSize spec in qSupported response");
       }
     }
   }
@@ -525,9 +524,10 @@
   if (!lock) {
     if (Log *log = ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(
             GDBR_LOG_PROCESS | GDBR_LOG_PACKETS))
-      log->Printf("GDBRemoteCommunicationClient::%s: Didn't get sequence mutex "
-                  "for %s packet.",
-                  __FUNCTION__, payload.GetData());
+      LLDB_LOGF(log,
+                "GDBRemoteCommunicationClient::%s: Didn't get sequence mutex "
+                "for %s packet.",
+                __FUNCTION__, payload.GetData());
     return PacketResult::ErrorNoSequenceLock;
   }
 
@@ -660,10 +660,10 @@
   if (!lock) {
     Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS |
                                                            GDBR_LOG_PACKETS));
-    if (log)
-      log->Printf("error: failed to get packet sequence mutex, not sending "
-                  "packets with prefix '%s'",
-                  payload_prefix);
+    LLDB_LOGF(log,
+              "error: failed to get packet sequence mutex, not sending "
+              "packets with prefix '%s'",
+              payload_prefix);
     return PacketResult::ErrorNoSequenceLock;
   }
 
@@ -1284,14 +1284,15 @@
             assert(byte_order == m_host_arch.GetByteOrder());
           }
 
-          if (log)
-            log->Printf("GDBRemoteCommunicationClient::%s parsed host "
-                        "architecture as %s, triple as %s from triple text %s",
-                        __FUNCTION__, m_host_arch.GetArchitectureName()
-                                          ? m_host_arch.GetArchitectureName()
-                                          : "<null-arch-name>",
-                        m_host_arch.GetTriple().getTriple().c_str(),
-                        triple.c_str());
+          LLDB_LOGF(log,
+                    "GDBRemoteCommunicationClient::%s parsed host "
+                    "architecture as %s, triple as %s from triple text %s",
+                    __FUNCTION__,
+                    m_host_arch.GetArchitectureName()
+                        ? m_host_arch.GetArchitectureName()
+                        : "<null-arch-name>",
+                    m_host_arch.GetTriple().getTriple().c_str(),
+                    triple.c_str());
         }
         if (!distribution_id.empty())
           m_host_arch.SetDistributionId(distribution_id.c_str());
@@ -2064,12 +2065,10 @@
           break;
         case llvm::Triple::Wasm:
         case llvm::Triple::XCOFF:
-          if (log)
-            log->Printf("error: not supported target architecture");
+          LLDB_LOGF(log, "error: not supported target architecture");
           return false;
         case llvm::Triple::UnknownObjectFormat:
-          if (log)
-            log->Printf("error: failed to determine target architecture");
+          LLDB_LOGF(log, "error: failed to determine target architecture");
           return false;
         }
 
@@ -2641,9 +2640,8 @@
 uint8_t GDBRemoteCommunicationClient::SendGDBStoppointTypePacket(
     GDBStoppointType type, bool insert, addr_t addr, uint32_t length) {
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
-  if (log)
-    log->Printf("GDBRemoteCommunicationClient::%s() %s at addr = 0x%" PRIx64,
-                __FUNCTION__, insert ? "add" : "remove", addr);
+  LLDB_LOGF(log, "GDBRemoteCommunicationClient::%s() %s at addr = 0x%" PRIx64,
+            __FUNCTION__, insert ? "add" : "remove", addr);
 
   // Check if the stub is known not to support this breakpoint type
   if (!SupportsGDBStoppointPacket(type))
@@ -2745,9 +2743,8 @@
 #if !defined(LLDB_CONFIGURATION_DEBUG)
     Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS |
                                                            GDBR_LOG_PACKETS));
-    if (log)
-      log->Printf("error: failed to get packet sequence mutex, not sending "
-                  "packet 'qfThreadInfo'");
+    LLDB_LOGF(log, "error: failed to get packet sequence mutex, not sending "
+                   "packet 'qfThreadInfo'");
 #endif
     sequence_mutex_unavailable = true;
   }
@@ -3873,9 +3870,9 @@
 
     } else if (Log *log = ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(
                    GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)) {
-      log->Printf(
-          "GDBRemoteCommunicationClient::%s: Didn't get sequence mutex.",
-          __FUNCTION__);
+      LLDB_LOGF(log,
+                "GDBRemoteCommunicationClient::%s: Didn't get sequence mutex.",
+                __FUNCTION__);
     }
   }
 }
@@ -3899,26 +3896,27 @@
           !m_supported_async_json_packets_sp->GetAsArray()) {
         // We were returned something other than a JSON array.  This is
         // invalid.  Clear it out.
-        if (log)
-          log->Printf("GDBRemoteCommunicationClient::%s(): "
-                      "QSupportedAsyncJSONPackets returned invalid "
-                      "result: %s",
-                      __FUNCTION__, response.GetStringRef().c_str());
+        LLDB_LOGF(log,
+                  "GDBRemoteCommunicationClient::%s(): "
+                  "QSupportedAsyncJSONPackets returned invalid "
+                  "result: %s",
+                  __FUNCTION__, response.GetStringRef().c_str());
         m_supported_async_json_packets_sp.reset();
       }
     } else {
-      if (log)
-        log->Printf("GDBRemoteCommunicationClient::%s(): "
-                    "QSupportedAsyncJSONPackets unsupported",
-                    __FUNCTION__);
+      LLDB_LOGF(log,
+                "GDBRemoteCommunicationClient::%s(): "
+                "QSupportedAsyncJSONPackets unsupported",
+                __FUNCTION__);
     }
 
     if (log && m_supported_async_json_packets_sp) {
       StreamString stream;
       m_supported_async_json_packets_sp->Dump(stream);
-      log->Printf("GDBRemoteCommunicationClient::%s(): supported async "
-                  "JSON packets: %s",
-                  __FUNCTION__, stream.GetData());
+      LLDB_LOGF(log,
+                "GDBRemoteCommunicationClient::%s(): supported async "
+                "JSON packets: %s",
+                __FUNCTION__, stream.GetData());
     }
   }
 
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
index bcddb4f..f9f67fc 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
@@ -95,10 +95,10 @@
     const Entry &entry = m_packets[idx];
     if (entry.type == ePacketTypeInvalid || entry.packet.data.empty())
       break;
-    log->Printf("history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s",
-                entry.packet_idx, entry.tid, entry.bytes_transmitted,
-                (entry.type == ePacketTypeSend) ? "send" : "read",
-                entry.packet.data.c_str());
+    LLDB_LOGF(log, "history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s",
+              entry.packet_idx, entry.tid, entry.bytes_transmitted,
+              (entry.type == ePacketTypeSend) ? "send" : "read",
+              entry.packet.data.c_str());
   }
 }
 
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
index 49cbeb0..d137c4c 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
@@ -139,10 +139,9 @@
 GDBRemoteCommunicationServer::SendIllFormedResponse(
     const StringExtractorGDBRemote &failed_packet, const char *message) {
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
-  if (log)
-    log->Printf("GDBRemoteCommunicationServer::%s: ILLFORMED: '%s' (%s)",
-                __FUNCTION__, failed_packet.GetStringRef().c_str(),
-                message ? message : "");
+  LLDB_LOGF(log, "GDBRemoteCommunicationServer::%s: ILLFORMED: '%s' (%s)",
+            __FUNCTION__, failed_packet.GetStringRef().c_str(),
+            message ? message : "");
   return SendErrorResponse(0x03);
 }
 
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 9767d3e..c1eaa1d 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -421,8 +421,7 @@
     StringExtractorGDBRemote &packet) {
 #if !defined(LLDB_DISABLE_POSIX)
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
-  if (log)
-    log->Printf("GDBRemoteCommunicationServerCommon::%s begin", __FUNCTION__);
+  LLDB_LOGF(log, "GDBRemoteCommunicationServerCommon::%s begin", __FUNCTION__);
 
   // Packet format: "qUserName:%i" where %i is the uid
   packet.SetFilePos(::strlen("qUserName:"));
@@ -435,8 +434,7 @@
       return SendPacketNoLock(response.GetString());
     }
   }
-  if (log)
-    log->Printf("GDBRemoteCommunicationServerCommon::%s end", __FUNCTION__);
+  LLDB_LOGF(log, "GDBRemoteCommunicationServerCommon::%s end", __FUNCTION__);
 #endif
   return SendErrorResponse(5);
 }
@@ -1017,9 +1015,8 @@
                   m_process_launch_info.GetExecutableFile().SetFile(
                       arg, FileSpec::Style::native);
                 m_process_launch_info.GetArguments().AppendArgument(arg);
-                if (log)
-                  log->Printf("LLGSPacketHandler::%s added arg %d: \"%s\"",
-                              __FUNCTION__, actual_arg_index, arg.c_str());
+                LLDB_LOGF(log, "LLGSPacketHandler::%s added arg %d: \"%s\"",
+                          __FUNCTION__, actual_arg_index, arg.c_str());
                 ++actual_arg_index;
               }
             }
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 190db34..6bdbbd2 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -249,18 +249,18 @@
     // Setup stdout/stderr mapping from inferior to $O
     auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
     if (terminal_fd >= 0) {
-      if (log)
-        log->Printf("ProcessGDBRemoteCommunicationServerLLGS::%s setting "
-                    "inferior STDIO fd to %d",
-                    __FUNCTION__, terminal_fd);
+      LLDB_LOGF(log,
+                "ProcessGDBRemoteCommunicationServerLLGS::%s setting "
+                "inferior STDIO fd to %d",
+                __FUNCTION__, terminal_fd);
       Status status = SetSTDIOFileDescriptor(terminal_fd);
       if (status.Fail())
         return status;
     } else {
-      if (log)
-        log->Printf("ProcessGDBRemoteCommunicationServerLLGS::%s ignoring "
-                    "inferior STDIO since terminal fd reported as %d",
-                    __FUNCTION__, terminal_fd);
+      LLDB_LOGF(log,
+                "ProcessGDBRemoteCommunicationServerLLGS::%s ignoring "
+                "inferior STDIO since terminal fd reported as %d",
+                __FUNCTION__, terminal_fd);
     }
   } else {
     LLDB_LOG(log,
@@ -278,9 +278,8 @@
 
 Status GDBRemoteCommunicationServerLLGS::AttachToProcess(lldb::pid_t pid) {
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
-  if (log)
-    log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64,
-                __FUNCTION__, pid);
+  LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64,
+            __FUNCTION__, pid);
 
   // Before we try to attach, make sure we aren't already monitoring something
   // else.
@@ -304,18 +303,18 @@
   // Setup stdout/stderr mapping from inferior.
   auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
   if (terminal_fd >= 0) {
-    if (log)
-      log->Printf("ProcessGDBRemoteCommunicationServerLLGS::%s setting "
-                  "inferior STDIO fd to %d",
-                  __FUNCTION__, terminal_fd);
+    LLDB_LOGF(log,
+              "ProcessGDBRemoteCommunicationServerLLGS::%s setting "
+              "inferior STDIO fd to %d",
+              __FUNCTION__, terminal_fd);
     Status status = SetSTDIOFileDescriptor(terminal_fd);
     if (status.Fail())
       return status;
   } else {
-    if (log)
-      log->Printf("ProcessGDBRemoteCommunicationServerLLGS::%s ignoring "
-                  "inferior STDIO since terminal fd reported as %d",
-                  __FUNCTION__, terminal_fd);
+    LLDB_LOGF(log,
+              "ProcessGDBRemoteCommunicationServerLLGS::%s ignoring "
+              "inferior STDIO since terminal fd reported as %d",
+              __FUNCTION__, terminal_fd);
   }
 
   printf("Attached to process %" PRIu64 "...\n", pid);
@@ -327,10 +326,11 @@
   assert(process && "process cannot be NULL");
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
   if (log) {
-    log->Printf("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()));
   }
 }
 
@@ -431,10 +431,9 @@
     const RegisterInfo *const reg_info_p =
         reg_ctx.GetRegisterInfoAtIndex(reg_num);
     if (reg_info_p == nullptr) {
-      if (log)
-        log->Printf(
-            "%s failed to get register info for register index %" PRIu32,
-            __FUNCTION__, reg_num);
+      LLDB_LOGF(log,
+                "%s failed to get register info for register index %" PRIu32,
+                __FUNCTION__, reg_num);
       continue;
     }
 
@@ -445,11 +444,10 @@
     RegisterValue reg_value;
     Status error = reg_ctx.ReadRegister(reg_info_p, reg_value);
     if (error.Fail()) {
-      if (log)
-        log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s",
-                    __FUNCTION__,
-                    reg_info_p->name ? reg_info_p->name : "<unnamed-register>",
-                    reg_num, error.AsCString());
+      LLDB_LOGF(log, "%s failed to read register '%s' index %" PRIu32 ": %s",
+                __FUNCTION__,
+                reg_info_p->name ? reg_info_p->name : "<unnamed-register>",
+                reg_num, error.AsCString());
       continue;
     }
 
@@ -511,11 +509,12 @@
 
     const int signum = tid_stop_info.details.signal.signo;
     if (log) {
-      log->Printf("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);
     }
 
     JSONObject::SP thread_obj_sp = std::make_shared<JSONObject>();
@@ -684,12 +683,10 @@
       RegisterValue reg_value;
       Status error = reg_ctx.ReadRegister(reg_info_p, reg_value);
       if (error.Fail()) {
-        if (log)
-          log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s",
-                      __FUNCTION__,
-                      reg_info_p->name ? reg_info_p->name
-                                       : "<unnamed-register>",
-                      reg_to_read, error.AsCString());
+        LLDB_LOGF(log, "%s failed to read register '%s' index %" PRIu32 ": %s",
+                  __FUNCTION__,
+                  reg_info_p->name ? reg_info_p->name : "<unnamed-register>",
+                  reg_to_read, error.AsCString());
         continue;
       }
 
@@ -713,25 +710,24 @@
   const RegisterSet *reg_set_p;
   if (reg_ctx.GetRegisterSetCount() > 0 &&
       ((reg_set_p = reg_ctx.GetRegisterSet(0)) != nullptr)) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s expediting registers "
-                  "from set '%s' (registers set count: %zu)",
-                  __FUNCTION__,
-                  reg_set_p->name ? reg_set_p->name : "<unnamed-set>",
-                  reg_set_p->num_registers);
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s expediting registers "
+              "from set '%s' (registers set count: %zu)",
+              __FUNCTION__, reg_set_p->name ? reg_set_p->name : "<unnamed-set>",
+              reg_set_p->num_registers);
 
     for (const uint32_t *reg_num_p = reg_set_p->registers;
          *reg_num_p != LLDB_INVALID_REGNUM; ++reg_num_p) {
       const RegisterInfo *const reg_info_p =
           reg_ctx.GetRegisterInfoAtIndex(*reg_num_p);
       if (reg_info_p == nullptr) {
-        if (log)
-          log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to get "
-                      "register info for register set '%s', register index "
-                      "%" PRIu32,
-                      __FUNCTION__,
-                      reg_set_p->name ? reg_set_p->name : "<unnamed-set>",
-                      *reg_num_p);
+        LLDB_LOGF(log,
+                  "GDBRemoteCommunicationServerLLGS::%s failed to get "
+                  "register info for register set '%s', register index "
+                  "%" PRIu32,
+                  __FUNCTION__,
+                  reg_set_p->name ? reg_set_p->name : "<unnamed-set>",
+                  *reg_num_p);
       } else if (reg_info_p->value_regs == nullptr) {
         // Only expediate registers that are not contained in other registers.
         RegisterValue reg_value;
@@ -742,13 +738,12 @@
                                             &reg_value, lldb::eByteOrderBig);
           response.PutChar(';');
         } else {
-          if (log)
-            log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to read "
-                        "register '%s' index %" PRIu32 ": %s",
-                        __FUNCTION__,
-                        reg_info_p->name ? reg_info_p->name
-                                         : "<unnamed-register>",
-                        *reg_num_p, error.AsCString());
+          LLDB_LOGF(log,
+                    "GDBRemoteCommunicationServerLLGS::%s failed to read "
+                    "register '%s' index %" PRIu32 ": %s",
+                    __FUNCTION__,
+                    reg_info_p->name ? reg_info_p->name : "<unnamed-register>",
+                    *reg_num_p, error.AsCString());
         }
       }
     }
@@ -787,15 +782,14 @@
   assert(process && "process cannot be NULL");
 
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
-  if (log)
-    log->Printf("GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
+  LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
 
   PacketResult result = SendStopReasonForState(StateType::eStateExited);
   if (result != PacketResult::Success) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to send stop "
-                  "notification for PID %" PRIu64 ", state: eStateExited",
-                  __FUNCTION__, process->GetID());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed to send stop "
+              "notification for PID %" PRIu64 ", state: eStateExited",
+              __FUNCTION__, process->GetID());
   }
 
   // Close the pipe to the inferior terminal i/o if we launched it and set one
@@ -812,8 +806,7 @@
   assert(process && "process cannot be NULL");
 
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
-  if (log)
-    log->Printf("GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
+  LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
 
   // Send the stop reason unless this is the stop after the launch or attach.
   switch (m_inferior_prev_state) {
@@ -825,10 +818,10 @@
     // In all other cases, send the stop reason.
     PacketResult result = SendStopReasonForState(StateType::eStateStopped);
     if (result != PacketResult::Success) {
-      if (log)
-        log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to send stop "
-                    "notification for PID %" PRIu64 ", state: eStateExited",
-                    __FUNCTION__, process->GetID());
+      LLDB_LOGF(log,
+                "GDBRemoteCommunicationServerLLGS::%s failed to send stop "
+                "notification for PID %" PRIu64 ", state: eStateExited",
+                __FUNCTION__, process->GetID());
     }
     break;
   }
@@ -839,9 +832,10 @@
   assert(process && "process cannot be NULL");
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
   if (log) {
-    log->Printf("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) {
@@ -868,9 +862,10 @@
 
   default:
     if (log) {
-      log->Printf("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;
   }
@@ -888,10 +883,10 @@
 
   if (!m_handshake_completed) {
     if (!HandshakeWithClient()) {
-      if (log)
-        log->Printf("GDBRemoteCommunicationServerLLGS::%s handshake with "
-                    "client failed, exiting",
-                    __FUNCTION__);
+      LLDB_LOGF(log,
+                "GDBRemoteCommunicationServerLLGS::%s handshake with "
+                "client failed, exiting",
+                __FUNCTION__);
       m_mainloop.RequestTermination();
       return;
     }
@@ -908,10 +903,10 @@
       break; // No more packets in the queue
 
     if ((result != PacketResult::Success)) {
-      if (log)
-        log->Printf("GDBRemoteCommunicationServerLLGS::%s processing a packet "
-                    "failed: %s",
-                    __FUNCTION__, error.AsCString());
+      LLDB_LOGF(log,
+                "GDBRemoteCommunicationServerLLGS::%s processing a packet "
+                "failed: %s",
+                __FUNCTION__, error.AsCString());
       m_mainloop.RequestTermination();
       break;
     }
@@ -982,9 +977,10 @@
     // Not much we can do about the failure. Log it and continue without
     // forwarding.
     if (Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS))
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s Failed to set up stdio "
-                  "forwarding: %s",
-                  __FUNCTION__, error.AsCString());
+      LLDB_LOGF(log,
+                "GDBRemoteCommunicationServerLLGS::%s Failed to set up stdio "
+                "forwarding: %s",
+                __FUNCTION__, error.AsCString());
   }
 }
 
@@ -1008,10 +1004,11 @@
     case eConnectionStatusError:
     case eConnectionStatusNoConnection:
       if (Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS))
-        log->Printf("GDBRemoteCommunicationServerLLGS::%s Stopping stdio "
-                    "forwarding as communication returned status %d (error: "
-                    "%s)",
-                    __FUNCTION__, status, error.AsCString());
+        LLDB_LOGF(log,
+                  "GDBRemoteCommunicationServerLLGS::%s Stopping stdio "
+                  "forwarding as communication returned status %d (error: "
+                  "%s)",
+                  __FUNCTION__, status, error.AsCString());
       m_stdio_handle_up.reset();
       return;
 
@@ -1349,15 +1346,14 @@
 GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerLLGS::Handle_C(StringExtractorGDBRemote &packet) {
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
-  if (log)
-    log->Printf("GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
+  LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
 
   // Ensure we have a native process.
   if (!m_debugged_process_up) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s no debugged process "
-                  "shared pointer",
-                  __FUNCTION__);
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s no debugged process "
+              "shared pointer",
+              __FUNCTION__);
     return SendErrorResponse(0x36);
   }
 
@@ -1430,8 +1426,7 @@
 GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerLLGS::Handle_c(StringExtractorGDBRemote &packet) {
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
-  if (log)
-    log->Printf("GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
+  LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
 
   packet.SetFilePos(packet.GetFilePos() + ::strlen("c"));
 
@@ -1445,10 +1440,10 @@
 
   // Ensure we have a native process.
   if (!m_debugged_process_up) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s no debugged process "
-                  "shared pointer",
-                  __FUNCTION__);
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s no debugged process "
+              "shared pointer",
+              __FUNCTION__);
     return SendErrorResponse(0x36);
   }
 
@@ -1480,17 +1475,16 @@
 GDBRemoteCommunicationServerLLGS::Handle_vCont(
     StringExtractorGDBRemote &packet) {
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
-  if (log)
-    log->Printf("GDBRemoteCommunicationServerLLGS::%s handling vCont packet",
-                __FUNCTION__);
+  LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s handling vCont packet",
+            __FUNCTION__);
 
   packet.SetFilePos(::strlen("vCont"));
 
   if (packet.GetBytesLeft() == 0) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s missing action from "
-                  "vCont package",
-                  __FUNCTION__);
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s missing action from "
+              "vCont package",
+              __FUNCTION__);
     return SendIllFormedResponse(packet, "Missing action from vCont package");
   }
 
@@ -1958,10 +1952,10 @@
   const uint32_t reg_index =
       packet.GetHexMaxU32(false, std::numeric_limits<uint32_t>::max());
   if (reg_index == std::numeric_limits<uint32_t>::max()) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, could not "
-                  "parse register number from request \"%s\"",
-                  __FUNCTION__, packet.GetStringRef().c_str());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed, could not "
+              "parse register number from request \"%s\"",
+              __FUNCTION__, packet.GetStringRef().c_str());
     return SendErrorResponse(0x15);
   }
 
@@ -1978,20 +1972,19 @@
   // Return the end of registers response if we've iterated one past the end of
   // the register set.
   if (reg_index >= reg_context.GetUserRegisterCount()) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested "
-                  "register %" PRIu32 " beyond register count %" PRIu32,
-                  __FUNCTION__, reg_index,
-                  reg_context.GetUserRegisterCount());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed, requested "
+              "register %" PRIu32 " beyond register count %" PRIu32,
+              __FUNCTION__, reg_index, reg_context.GetUserRegisterCount());
     return SendErrorResponse(0x15);
   }
 
   const RegisterInfo *reg_info = reg_context.GetRegisterInfoAtIndex(reg_index);
   if (!reg_info) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested "
-                  "register %" PRIu32 " returned NULL",
-                  __FUNCTION__, reg_index);
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed, requested "
+              "register %" PRIu32 " returned NULL",
+              __FUNCTION__, reg_index);
     return SendErrorResponse(0x15);
   }
 
@@ -2002,20 +1995,20 @@
   RegisterValue reg_value;
   Status error = reg_context.ReadRegister(reg_info, reg_value);
   if (error.Fail()) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, read of "
-                  "requested register %" PRIu32 " (%s) failed: %s",
-                  __FUNCTION__, reg_index, reg_info->name, error.AsCString());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed, read of "
+              "requested register %" PRIu32 " (%s) failed: %s",
+              __FUNCTION__, reg_index, reg_info->name, error.AsCString());
     return SendErrorResponse(0x15);
   }
 
   const uint8_t *const data =
       reinterpret_cast<const uint8_t *>(reg_value.GetBytes());
   if (!data) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to get data "
-                  "bytes from requested register %" PRIu32,
-                  __FUNCTION__, reg_index);
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed to get data "
+              "bytes from requested register %" PRIu32,
+              __FUNCTION__, reg_index);
     return SendErrorResponse(0x15);
   }
 
@@ -2039,10 +2032,10 @@
   const uint32_t reg_index =
       packet.GetHexMaxU32(false, std::numeric_limits<uint32_t>::max());
   if (reg_index == std::numeric_limits<uint32_t>::max()) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, could not "
-                  "parse register number from request \"%s\"",
-                  __FUNCTION__, packet.GetStringRef().c_str());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed, could not "
+              "parse register number from request \"%s\"",
+              __FUNCTION__, packet.GetStringRef().c_str());
     return SendErrorResponse(0x29);
   }
 
@@ -2058,10 +2051,10 @@
   // Get the thread to use.
   NativeThreadProtocol *thread = GetThreadFromSuffix(packet);
   if (!thread) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, no thread "
-                  "available (thread index 0)",
-                  __FUNCTION__);
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed, no thread "
+              "available (thread index 0)",
+              __FUNCTION__);
     return SendErrorResponse(0x28);
   }
 
@@ -2069,20 +2062,20 @@
   NativeRegisterContext &reg_context = thread->GetRegisterContext();
   const RegisterInfo *reg_info = reg_context.GetRegisterInfoAtIndex(reg_index);
   if (!reg_info) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested "
-                  "register %" PRIu32 " returned NULL",
-                  __FUNCTION__, reg_index);
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed, requested "
+              "register %" PRIu32 " returned NULL",
+              __FUNCTION__, reg_index);
     return SendErrorResponse(0x48);
   }
 
   // Return the end of registers response if we've iterated one past the end of
   // the register set.
   if (reg_index >= reg_context.GetUserRegisterCount()) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested "
-                  "register %" PRIu32 " beyond register count %" PRIu32,
-                  __FUNCTION__, reg_index, reg_context.GetUserRegisterCount());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed, requested "
+              "register %" PRIu32 " beyond register count %" PRIu32,
+              __FUNCTION__, reg_index, reg_context.GetUserRegisterCount());
     return SendErrorResponse(0x47);
   }
 
@@ -2101,10 +2094,10 @@
       m_debugged_process_up->GetArchitecture().GetByteOrder());
   Status error = reg_context.WriteRegister(reg_info, reg_value);
   if (error.Fail()) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, write of "
-                  "requested register %" PRIu32 " (%s) failed: %s",
-                  __FUNCTION__, reg_index, reg_info->name, error.AsCString());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed, write of "
+              "requested register %" PRIu32 " (%s) failed: %s",
+              __FUNCTION__, reg_index, reg_info->name, error.AsCString());
     return SendErrorResponse(0x32);
   }
 
@@ -2118,20 +2111,20 @@
   // Fail if we don't have a current process.
   if (!m_debugged_process_up ||
       (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
-    if (log)
-      log->Printf(
-          "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
-          __FUNCTION__);
+    LLDB_LOGF(
+        log,
+        "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+        __FUNCTION__);
     return SendErrorResponse(0x15);
   }
 
   // Parse out which variant of $H is requested.
   packet.SetFilePos(strlen("H"));
   if (packet.GetBytesLeft() < 1) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, H command "
-                  "missing {g,c} variant",
-                  __FUNCTION__);
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed, H command "
+              "missing {g,c} variant",
+              __FUNCTION__);
     return SendIllFormedResponse(packet, "H command missing {g,c} variant");
   }
 
@@ -2144,10 +2137,10 @@
     break;
 
   default:
-    if (log)
-      log->Printf(
-          "GDBRemoteCommunicationServerLLGS::%s failed, invalid $H variant %c",
-          __FUNCTION__, h_variant);
+    LLDB_LOGF(
+        log,
+        "GDBRemoteCommunicationServerLLGS::%s failed, invalid $H variant %c",
+        __FUNCTION__, h_variant);
     return SendIllFormedResponse(packet,
                                  "H variant unsupported, should be c or g");
   }
@@ -2162,10 +2155,10 @@
   if (tid != LLDB_INVALID_THREAD_ID && tid != 0) {
     NativeThreadProtocol *thread = m_debugged_process_up->GetThreadByID(tid);
     if (!thread) {
-      if (log)
-        log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, tid %" PRIu64
-                    " not found",
-                    __FUNCTION__, tid);
+      LLDB_LOGF(log,
+                "GDBRemoteCommunicationServerLLGS::%s failed, tid %" PRIu64
+                " not found",
+                __FUNCTION__, tid);
       return SendErrorResponse(0x15);
     }
   }
@@ -2196,10 +2189,10 @@
   // Fail if we don't have a current process.
   if (!m_debugged_process_up ||
       (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
-    if (log)
-      log->Printf(
-          "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
-          __FUNCTION__);
+    LLDB_LOGF(
+        log,
+        "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+        __FUNCTION__);
     return SendErrorResponse(0x15);
   }
 
@@ -2257,10 +2250,10 @@
 
   if (!m_debugged_process_up ||
       (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
-    if (log)
-      log->Printf(
-          "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
-          __FUNCTION__);
+    LLDB_LOGF(
+        log,
+        "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+        __FUNCTION__);
     return SendErrorResponse(0x15);
   }
 
@@ -2284,10 +2277,10 @@
 
   const uint64_t byte_count = packet.GetHexMaxU64(false, 0);
   if (byte_count == 0) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s nothing to read: "
-                  "zero-length packet",
-                  __FUNCTION__);
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s nothing to read: "
+              "zero-length packet",
+              __FUNCTION__);
     return SendOKResponse();
   }
 
@@ -2301,20 +2294,20 @@
   Status error = m_debugged_process_up->ReadMemoryWithoutTrap(
       read_addr, &buf[0], byte_count, bytes_read);
   if (error.Fail()) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
-                  " mem 0x%" PRIx64 ": failed to read. Error: %s",
-                  __FUNCTION__, m_debugged_process_up->GetID(), read_addr,
-                  error.AsCString());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
+              " mem 0x%" PRIx64 ": failed to read. Error: %s",
+              __FUNCTION__, m_debugged_process_up->GetID(), read_addr,
+              error.AsCString());
     return SendErrorResponse(0x08);
   }
 
   if (bytes_read == 0) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
-                  " mem 0x%" PRIx64 ": read 0 of %" PRIu64 " requested bytes",
-                  __FUNCTION__, m_debugged_process_up->GetID(), read_addr,
-                  byte_count);
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
+              " mem 0x%" PRIx64 ": read 0 of %" PRIu64 " requested bytes",
+              __FUNCTION__, m_debugged_process_up->GetID(), read_addr,
+              byte_count);
     return SendErrorResponse(0x08);
   }
 
@@ -2338,10 +2331,10 @@
 
   if (!m_debugged_process_up ||
       (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
-    if (log)
-      log->Printf(
-          "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
-          __FUNCTION__);
+    LLDB_LOGF(
+        log,
+        "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+        __FUNCTION__);
     return SendErrorResponse(0x15);
   }
 
@@ -2426,10 +2419,10 @@
   // since we won't have a NativeProcessProtocol.
   if (!m_debugged_process_up ||
       (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
-    if (log)
-      log->Printf(
-          "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
-          __FUNCTION__);
+    LLDB_LOGF(
+        log,
+        "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+        __FUNCTION__);
     return SendErrorResponse(0x15);
   }
 
@@ -2454,10 +2447,10 @@
   // Ensure we have a process.
   if (!m_debugged_process_up ||
       (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
-    if (log)
-      log->Printf(
-          "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
-          __FUNCTION__);
+    LLDB_LOGF(
+        log,
+        "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+        __FUNCTION__);
     return SendErrorResponse(0x15);
   }
 
@@ -2703,10 +2696,10 @@
   // Ensure we have a process.
   if (!m_debugged_process_up ||
       (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
-    if (log)
-      log->Printf(
-          "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
-          __FUNCTION__);
+    LLDB_LOGF(
+        log,
+        "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+        __FUNCTION__);
     return SendErrorResponse(0x32);
   }
 
@@ -2735,11 +2728,11 @@
   actions.SetDefaultThreadActionIfNeeded(eStateStopped, 0);
   Status error = m_debugged_process_up->Resume(actions);
   if (error.Fail()) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
-                  " tid %" PRIu64 " Resume() failed with error: %s",
-                  __FUNCTION__, m_debugged_process_up->GetID(), tid,
-                  error.AsCString());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
+              " tid %" PRIu64 " Resume() failed with error: %s",
+              __FUNCTION__, m_debugged_process_up->GetID(), tid,
+              error.AsCString());
     return SendErrorResponse(0x49);
   }
 
@@ -2986,18 +2979,18 @@
                                  "vAttach failed to parse the process id");
 
   // Attempt to attach.
-  if (log)
-    log->Printf("GDBRemoteCommunicationServerLLGS::%s attempting to attach to "
-                "pid %" PRIu64,
-                __FUNCTION__, pid);
+  LLDB_LOGF(log,
+            "GDBRemoteCommunicationServerLLGS::%s attempting to attach to "
+            "pid %" PRIu64,
+            __FUNCTION__, pid);
 
   Status error = AttachToProcess(pid);
 
   if (error.Fail()) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to attach to "
-                  "pid %" PRIu64 ": %s\n",
-                  __FUNCTION__, pid, error.AsCString());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed to attach to "
+              "pid %" PRIu64 ": %s\n",
+              __FUNCTION__, pid, error.AsCString());
     return SendErrorResponse(error);
   }
 
@@ -3014,10 +3007,10 @@
   // Fail if we don't have a current process.
   if (!m_debugged_process_up ||
       (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
-    if (log)
-      log->Printf(
-          "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
-          __FUNCTION__);
+    LLDB_LOGF(
+        log,
+        "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+        __FUNCTION__);
     return SendErrorResponse(0x15);
   }
 
@@ -3041,11 +3034,10 @@
 
   const Status error = m_debugged_process_up->Detach();
   if (error.Fail()) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to detach from "
-                  "pid %" PRIu64 ": %s\n",
-                  __FUNCTION__, m_debugged_process_up->GetID(),
-                  error.AsCString());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed to detach from "
+              "pid %" PRIu64 ": %s\n",
+              __FUNCTION__, m_debugged_process_up->GetID(), error.AsCString());
     return SendErrorResponse(0x01);
   }
 
@@ -3060,10 +3052,10 @@
   packet.SetFilePos(strlen("qThreadStopInfo"));
   const lldb::tid_t tid = packet.GetHexMaxU32(false, LLDB_INVALID_THREAD_ID);
   if (tid == LLDB_INVALID_THREAD_ID) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, could not "
-                  "parse thread id from request \"%s\"",
-                  __FUNCTION__, packet.GetStringRef().c_str());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s failed, could not "
+              "parse thread id from request \"%s\"",
+              __FUNCTION__, packet.GetStringRef().c_str());
     return SendErrorResponse(0x15);
   }
   return SendStopReplyPacketForThread(tid);
@@ -3195,15 +3187,15 @@
       connection->Disconnect(&error);
 
       if (error.Success()) {
-        if (log)
-          log->Printf("GDBRemoteCommunicationServerLLGS::%s disconnect process "
-                      "terminal stdio - SUCCESS",
-                      __FUNCTION__);
+        LLDB_LOGF(log,
+                  "GDBRemoteCommunicationServerLLGS::%s disconnect process "
+                  "terminal stdio - SUCCESS",
+                  __FUNCTION__);
       } else {
-        if (log)
-          log->Printf("GDBRemoteCommunicationServerLLGS::%s disconnect process "
-                      "terminal stdio - FAIL: %s",
-                      __FUNCTION__, error.AsCString());
+        LLDB_LOGF(log,
+                  "GDBRemoteCommunicationServerLLGS::%s disconnect process "
+                  "terminal stdio - FAIL: %s",
+                  __FUNCTION__, error.AsCString());
       }
     }
   }
@@ -3233,11 +3225,11 @@
 
   // Parse out the ';'.
   if (packet.GetBytesLeft() < 1 || packet.GetChar() != ';') {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s gdb-remote parse "
-                  "error: expected ';' prior to start of thread suffix: packet "
-                  "contents = '%s'",
-                  __FUNCTION__, packet.GetStringRef().c_str());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s gdb-remote parse "
+              "error: expected ';' prior to start of thread suffix: packet "
+              "contents = '%s'",
+              __FUNCTION__, packet.GetStringRef().c_str());
     return nullptr;
   }
 
@@ -3246,11 +3238,11 @@
 
   // Parse out thread: portion.
   if (strncmp(packet.Peek(), "thread:", strlen("thread:")) != 0) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerLLGS::%s gdb-remote parse "
-                  "error: expected 'thread:' but not found, packet contents = "
-                  "'%s'",
-                  __FUNCTION__, packet.GetStringRef().c_str());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerLLGS::%s gdb-remote parse "
+              "error: expected 'thread:' but not found, packet contents = "
+              "'%s'",
+              __FUNCTION__, packet.GetStringRef().c_str());
     return nullptr;
   }
   packet.SetFilePos(packet.GetFilePos() + strlen("thread:"));
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
index 6deb75f..eb6cc6e 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -104,8 +104,8 @@
     hostname = "127.0.0.1";
 
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
-  if (log)
-    log->Printf("Launching debugserver with: %s:%u...", hostname.c_str(), port);
+  LLDB_LOGF(log, "Launching debugserver with: %s:%u...", hostname.c_str(),
+            port);
 
   // Do not run in a new session so that it can not linger after the platform
   // closes.
@@ -161,9 +161,8 @@
   // process...
 
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
-  if (log)
-    log->Printf("GDBRemoteCommunicationServerPlatform::%s() called",
-                __FUNCTION__);
+  LLDB_LOGF(log, "GDBRemoteCommunicationServerPlatform::%s() called",
+            __FUNCTION__);
 
   ConnectionFileDescriptor file_conn;
   std::string hostname;
@@ -183,17 +182,17 @@
   Status error =
       LaunchGDBServer(Args(), hostname, debugserver_pid, port, socket_name);
   if (error.Fail()) {
-    if (log)
-      log->Printf("GDBRemoteCommunicationServerPlatform::%s() debugserver "
-                  "launch failed: %s",
-                  __FUNCTION__, error.AsCString());
+    LLDB_LOGF(log,
+              "GDBRemoteCommunicationServerPlatform::%s() debugserver "
+              "launch failed: %s",
+              __FUNCTION__, error.AsCString());
     return SendErrorResponse(9);
   }
 
-  if (log)
-    log->Printf("GDBRemoteCommunicationServerPlatform::%s() debugserver "
-                "launched successfully as pid %" PRIu64,
-                __FUNCTION__, debugserver_pid);
+  LLDB_LOGF(log,
+            "GDBRemoteCommunicationServerPlatform::%s() debugserver "
+            "launched successfully as pid %" PRIu64,
+            __FUNCTION__, debugserver_pid);
 
   StreamGDBRemote response;
   response.Printf("pid:%" PRIu64 ";port:%u;", debugserver_pid,
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index a77e659..2bd0234 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -206,11 +206,14 @@
         } else {
           Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD |
                                                                 GDBR_LOG_PACKETS));
-          if (log)
-            log->Printf ("error: GDBRemoteRegisterContext::ReadRegisterBytes tried to read the "
-                        "entire register context at once, expected at least %" PRId64 " bytes "
-                        "but only got %" PRId64 " bytes.", m_reg_data.GetByteSize(),
-                        buffer_sp->GetByteSize());
+          LLDB_LOGF(
+              log,
+              "error: GDBRemoteRegisterContext::ReadRegisterBytes tried "
+              "to read the "
+              "entire register context at once, expected at least %" PRId64
+              " bytes "
+              "but only got %" PRId64 " bytes.",
+              m_reg_data.GetByteSize(), buffer_sp->GetByteSize());
         }
       }
       return false;
@@ -390,13 +393,15 @@
         if (log->GetVerbose()) {
           StreamString strm;
           gdb_comm.DumpHistory(strm);
-          log->Printf("error: failed to get packet sequence mutex, not sending "
-                      "write register for \"%s\":\n%s",
-                      reg_info->name, strm.GetData());
+          LLDB_LOGF(log,
+                    "error: failed to get packet sequence mutex, not sending "
+                    "write register for \"%s\":\n%s",
+                    reg_info->name, strm.GetData());
         } else
-          log->Printf("error: failed to get packet sequence mutex, not sending "
-                      "write register for \"%s\"",
-                      reg_info->name);
+          LLDB_LOGF(log,
+                    "error: failed to get packet sequence mutex, not sending "
+                    "write register for \"%s\"",
+                    reg_info->name);
       }
     }
   }
@@ -494,12 +499,14 @@
       if (log->GetVerbose()) {
         StreamString strm;
         gdb_comm.DumpHistory(strm);
-        log->Printf("error: failed to get packet sequence mutex, not sending "
-                    "read all registers:\n%s",
-                    strm.GetData());
+        LLDB_LOGF(log,
+                  "error: failed to get packet sequence mutex, not sending "
+                  "read all registers:\n%s",
+                  strm.GetData());
       } else
-        log->Printf("error: failed to get packet sequence mutex, not sending "
-                    "read all registers");
+        LLDB_LOGF(log,
+                  "error: failed to get packet sequence mutex, not sending "
+                  "read all registers");
     }
   }
 
@@ -667,12 +674,14 @@
       if (log->GetVerbose()) {
         StreamString strm;
         gdb_comm.DumpHistory(strm);
-        log->Printf("error: failed to get packet sequence mutex, not sending "
-                    "write all registers:\n%s",
-                    strm.GetData());
+        LLDB_LOGF(log,
+                  "error: failed to get packet sequence mutex, not sending "
+                  "write all registers:\n%s",
+                  strm.GetData());
       } else
-        log->Printf("error: failed to get packet sequence mutex, not sending "
-                    "write all registers");
+        LLDB_LOGF(log,
+                  "error: failed to get packet sequence mutex, not sending "
+                  "write all registers");
     }
   }
   return false;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index a6fdd8d..ce2073a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -354,10 +354,10 @@
 
   if (m_async_listener_sp->StartListeningForEvents(
           &m_async_broadcaster, async_event_mask) != async_event_mask) {
-    if (log)
-      log->Printf("ProcessGDBRemote::%s failed to listen for "
-                  "m_async_broadcaster events",
-                  __FUNCTION__);
+    LLDB_LOGF(log,
+              "ProcessGDBRemote::%s failed to listen for "
+              "m_async_broadcaster events",
+              __FUNCTION__);
   }
 
   const uint32_t gdb_event_mask =
@@ -365,9 +365,9 @@
       GDBRemoteCommunication::eBroadcastBitGdbReadThreadGotNotify;
   if (m_async_listener_sp->StartListeningForEvents(
           &m_gdb_comm, gdb_event_mask) != gdb_event_mask) {
-    if (log)
-      log->Printf("ProcessGDBRemote::%s failed to listen for m_gdb_comm events",
-                  __FUNCTION__);
+    LLDB_LOGF(log,
+              "ProcessGDBRemote::%s failed to listen for m_gdb_comm events",
+              __FUNCTION__);
   }
 
   const uint64_t timeout_seconds =
@@ -785,15 +785,15 @@
                                      pid, remote_url.str().c_str());
   }
 
-  if (log)
-    log->Printf("ProcessGDBRemote::%s pid %" PRIu64
-                ": normalizing target architecture initial triple: %s "
-                "(GetTarget().GetArchitecture().IsValid() %s, "
-                "m_gdb_comm.GetHostArchitecture().IsValid(): %s)",
-                __FUNCTION__, GetID(),
-                GetTarget().GetArchitecture().GetTriple().getTriple().c_str(),
-                GetTarget().GetArchitecture().IsValid() ? "true" : "false",
-                m_gdb_comm.GetHostArchitecture().IsValid() ? "true" : "false");
+  LLDB_LOGF(log,
+            "ProcessGDBRemote::%s pid %" PRIu64
+            ": normalizing target architecture initial triple: %s "
+            "(GetTarget().GetArchitecture().IsValid() %s, "
+            "m_gdb_comm.GetHostArchitecture().IsValid(): %s)",
+            __FUNCTION__, GetID(),
+            GetTarget().GetArchitecture().GetTriple().getTriple().c_str(),
+            GetTarget().GetArchitecture().IsValid() ? "true" : "false",
+            m_gdb_comm.GetHostArchitecture().IsValid() ? "true" : "false");
 
   if (error.Success() && !GetTarget().GetArchitecture().IsValid() &&
       m_gdb_comm.GetHostArchitecture().IsValid()) {
@@ -805,11 +805,11 @@
       GetTarget().SetArchitecture(m_gdb_comm.GetHostArchitecture());
   }
 
-  if (log)
-    log->Printf("ProcessGDBRemote::%s pid %" PRIu64
-                ": normalized target architecture triple: %s",
-                __FUNCTION__, GetID(),
-                GetTarget().GetArchitecture().GetTriple().getTriple().c_str());
+  LLDB_LOGF(log,
+            "ProcessGDBRemote::%s pid %" PRIu64
+            ": normalized target architecture triple: %s",
+            __FUNCTION__, GetID(),
+            GetTarget().GetArchitecture().GetTriple().getTriple().c_str());
 
   if (error.Success()) {
     PlatformSP platform_sp = GetTarget().GetPlatform();
@@ -834,8 +834,7 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
   Status error;
 
-  if (log)
-    log->Printf("ProcessGDBRemote::%s() entered", __FUNCTION__);
+  LLDB_LOGF(log, "ProcessGDBRemote::%s() entered", __FUNCTION__);
 
   uint32_t launch_flags = launch_info.GetFlags().Get();
   FileSpec stdin_file_spec{};
@@ -862,15 +861,17 @@
 
   if (log) {
     if (stdin_file_spec || stdout_file_spec || stderr_file_spec)
-      log->Printf("ProcessGDBRemote::%s provided with STDIO paths via "
-                  "launch_info: stdin=%s, stdout=%s, stderr=%s",
-                  __FUNCTION__,
-                  stdin_file_spec ? stdin_file_spec.GetCString() : "<null>",
-                  stdout_file_spec ? stdout_file_spec.GetCString() : "<null>",
-                  stderr_file_spec ? stderr_file_spec.GetCString() : "<null>");
+      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.GetCString() : "<null>",
+                stdout_file_spec ? stdout_file_spec.GetCString() : "<null>",
+                stderr_file_spec ? stderr_file_spec.GetCString() : "<null>");
     else
-      log->Printf("ProcessGDBRemote::%s no STDIO paths given via launch_info",
-                  __FUNCTION__);
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::%s no STDIO paths given via launch_info",
+                __FUNCTION__);
   }
 
   const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0;
@@ -925,24 +926,23 @@
           if (!stderr_file_spec)
             stderr_file_spec = slave_name;
         }
-        if (log)
-          log->Printf(
-              "ProcessGDBRemote::%s adjusted STDIO paths for local platform "
-              "(IsHost() is true) using slave: stdin=%s, stdout=%s, stderr=%s",
-              __FUNCTION__,
-              stdin_file_spec ? stdin_file_spec.GetCString() : "<null>",
-              stdout_file_spec ? stdout_file_spec.GetCString() : "<null>",
-              stderr_file_spec ? stderr_file_spec.GetCString() : "<null>");
+        LLDB_LOGF(
+            log,
+            "ProcessGDBRemote::%s adjusted STDIO paths for local platform "
+            "(IsHost() is true) using slave: stdin=%s, stdout=%s, stderr=%s",
+            __FUNCTION__,
+            stdin_file_spec ? stdin_file_spec.GetCString() : "<null>",
+            stdout_file_spec ? stdout_file_spec.GetCString() : "<null>",
+            stderr_file_spec ? stderr_file_spec.GetCString() : "<null>");
       }
 
-      if (log)
-        log->Printf("ProcessGDBRemote::%s final STDIO paths after all "
-                    "adjustments: stdin=%s, stdout=%s, stderr=%s",
-                    __FUNCTION__,
-                    stdin_file_spec ? stdin_file_spec.GetCString() : "<null>",
-                    stdout_file_spec ? stdout_file_spec.GetCString() : "<null>",
-                    stderr_file_spec ? stderr_file_spec.GetCString()
-                                     : "<null>");
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::%s final STDIO paths after all "
+                "adjustments: stdin=%s, stdout=%s, stderr=%s",
+                __FUNCTION__,
+                stdin_file_spec ? stdin_file_spec.GetCString() : "<null>",
+                stdout_file_spec ? stdout_file_spec.GetCString() : "<null>",
+                stderr_file_spec ? stderr_file_spec.GetCString() : "<null>");
 
       if (stdin_file_spec)
         m_gdb_comm.SetSTDIN(stdin_file_spec);
@@ -988,9 +988,8 @@
       }
 
       if (GetID() == LLDB_INVALID_PROCESS_ID) {
-        if (log)
-          log->Printf("failed to connect to debugserver: %s",
-                      error.AsCString());
+        LLDB_LOGF(log, "failed to connect to debugserver: %s",
+                  error.AsCString());
         KillDebugserverProcess();
         return error;
       }
@@ -1020,8 +1019,7 @@
         }
       }
     } else {
-      if (log)
-        log->Printf("failed to connect to debugserver: %s", error.AsCString());
+      LLDB_LOGF(log, "failed to connect to debugserver: %s", error.AsCString());
     }
   } else {
     // Set our user ID to an invalid process ID.
@@ -1040,9 +1038,8 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
 
   if (!connect_url.empty()) {
-    if (log)
-      log->Printf("ProcessGDBRemote::%s Connecting to %s", __FUNCTION__,
-                  connect_url.str().c_str());
+    LLDB_LOGF(log, "ProcessGDBRemote::%s Connecting to %s", __FUNCTION__,
+              connect_url.str().c_str());
     std::unique_ptr<ConnectionFileDescriptor> conn_up(
         new ConnectionFileDescriptor());
     if (conn_up) {
@@ -1116,8 +1113,7 @@
 
 void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) {
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-  if (log)
-    log->Printf("ProcessGDBRemote::%s()", __FUNCTION__);
+  LLDB_LOGF(log, "ProcessGDBRemote::%s()", __FUNCTION__);
   if (GetID() != LLDB_INVALID_PROCESS_ID) {
     BuildDynamicRegisterInfo(false);
 
@@ -1130,43 +1126,42 @@
     const ArchSpec &remote_process_arch = m_gdb_comm.GetProcessArchitecture();
     if (remote_process_arch.IsValid()) {
       process_arch = remote_process_arch;
-      if (log)
-        log->Printf("ProcessGDBRemote::%s gdb-remote had process architecture, "
-                    "using %s %s",
-                    __FUNCTION__,
-                    process_arch.GetArchitectureName()
-                        ? process_arch.GetArchitectureName()
-                        : "<null>",
-                    process_arch.GetTriple().getTriple().c_str()
-                        ? process_arch.GetTriple().getTriple().c_str()
-                        : "<null>");
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::%s gdb-remote had process architecture, "
+                "using %s %s",
+                __FUNCTION__,
+                process_arch.GetArchitectureName()
+                    ? process_arch.GetArchitectureName()
+                    : "<null>",
+                process_arch.GetTriple().getTriple().c_str()
+                    ? process_arch.GetTriple().getTriple().c_str()
+                    : "<null>");
     } else {
       process_arch = m_gdb_comm.GetHostArchitecture();
-      if (log)
-        log->Printf("ProcessGDBRemote::%s gdb-remote did not have process "
-                    "architecture, using gdb-remote host architecture %s %s",
-                    __FUNCTION__,
-                    process_arch.GetArchitectureName()
-                        ? process_arch.GetArchitectureName()
-                        : "<null>",
-                    process_arch.GetTriple().getTriple().c_str()
-                        ? process_arch.GetTriple().getTriple().c_str()
-                        : "<null>");
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::%s gdb-remote did not have process "
+                "architecture, using gdb-remote host architecture %s %s",
+                __FUNCTION__,
+                process_arch.GetArchitectureName()
+                    ? process_arch.GetArchitectureName()
+                    : "<null>",
+                process_arch.GetTriple().getTriple().c_str()
+                    ? process_arch.GetTriple().getTriple().c_str()
+                    : "<null>");
     }
 
     if (process_arch.IsValid()) {
       const ArchSpec &target_arch = GetTarget().GetArchitecture();
       if (target_arch.IsValid()) {
-        if (log)
-          log->Printf(
-              "ProcessGDBRemote::%s analyzing target arch, currently %s %s",
-              __FUNCTION__,
-              target_arch.GetArchitectureName()
-                  ? target_arch.GetArchitectureName()
-                  : "<null>",
-              target_arch.GetTriple().getTriple().c_str()
-                  ? target_arch.GetTriple().getTriple().c_str()
-                  : "<null>");
+        LLDB_LOGF(log,
+                  "ProcessGDBRemote::%s analyzing target arch, currently %s %s",
+                  __FUNCTION__,
+                  target_arch.GetArchitectureName()
+                      ? target_arch.GetArchitectureName()
+                      : "<null>",
+                  target_arch.GetTriple().getTriple().c_str()
+                      ? target_arch.GetTriple().getTriple().c_str()
+                      : "<null>");
 
         // If the remote host is ARM and we have apple as the vendor, then
         // ARM executables and shared libraries can have mixed ARM
@@ -1180,16 +1175,16 @@
              process_arch.GetMachine() == llvm::Triple::thumb) &&
             process_arch.GetTriple().getVendor() == llvm::Triple::Apple) {
           GetTarget().SetArchitecture(process_arch);
-          if (log)
-            log->Printf("ProcessGDBRemote::%s remote process is ARM/Apple, "
-                        "setting target arch to %s %s",
-                        __FUNCTION__,
-                        process_arch.GetArchitectureName()
-                            ? process_arch.GetArchitectureName()
-                            : "<null>",
-                        process_arch.GetTriple().getTriple().c_str()
-                            ? process_arch.GetTriple().getTriple().c_str()
-                            : "<null>");
+          LLDB_LOGF(log,
+                    "ProcessGDBRemote::%s remote process is ARM/Apple, "
+                    "setting target arch to %s %s",
+                    __FUNCTION__,
+                    process_arch.GetArchitectureName()
+                        ? process_arch.GetArchitectureName()
+                        : "<null>",
+                    process_arch.GetTriple().getTriple().c_str()
+                        ? process_arch.GetTriple().getTriple().c_str()
+                        : "<null>");
         } else {
           // Fill in what is missing in the triple
           const llvm::Triple &remote_triple = process_arch.GetTriple();
@@ -1211,16 +1206,16 @@
           }
         }
 
-        if (log)
-          log->Printf("ProcessGDBRemote::%s final target arch after "
-                      "adjustments for remote architecture: %s %s",
-                      __FUNCTION__,
-                      target_arch.GetArchitectureName()
-                          ? target_arch.GetArchitectureName()
-                          : "<null>",
-                      target_arch.GetTriple().getTriple().c_str()
-                          ? target_arch.GetTriple().getTriple().c_str()
-                          : "<null>");
+        LLDB_LOGF(log,
+                  "ProcessGDBRemote::%s final target arch after "
+                  "adjustments for remote architecture: %s %s",
+                  __FUNCTION__,
+                  target_arch.GetArchitectureName()
+                      ? target_arch.GetArchitectureName()
+                      : "<null>",
+                  target_arch.GetTriple().getTriple().c_str()
+                      ? target_arch.GetTriple().getTriple().c_str()
+                      : "<null>");
       } else {
         // The target doesn't have a valid architecture yet, set it from the
         // architecture we got from the remote GDB server
@@ -1247,8 +1242,7 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
   Status error;
 
-  if (log)
-    log->Printf("ProcessGDBRemote::%s()", __FUNCTION__);
+  LLDB_LOGF(log, "ProcessGDBRemote::%s()", __FUNCTION__);
 
   // Clear out and clean up from any current state
   Clear();
@@ -1359,8 +1353,7 @@
 Status ProcessGDBRemote::DoResume() {
   Status error;
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-  if (log)
-    log->Printf("ProcessGDBRemote::Resume()");
+  LLDB_LOGF(log, "ProcessGDBRemote::Resume()");
 
   ListenerSP listener_sp(
       Listener::MakeListener("gdb-remote.resume-packet-sent"));
@@ -1547,9 +1540,8 @@
       EventSP event_sp;
       if (!m_async_thread.IsJoinable()) {
         error.SetErrorString("Trying to resume but the async thread is dead.");
-        if (log)
-          log->Printf("ProcessGDBRemote::DoResume: Trying to resume but the "
-                      "async thread is dead.");
+        LLDB_LOGF(log, "ProcessGDBRemote::DoResume: Trying to resume but the "
+                       "async thread is dead.");
         return error;
       }
 
@@ -1560,14 +1552,13 @@
 
       if (!listener_sp->GetEvent(event_sp, std::chrono::seconds(5))) {
         error.SetErrorString("Resume timed out.");
-        if (log)
-          log->Printf("ProcessGDBRemote::DoResume: Resume timed out.");
+        LLDB_LOGF(log, "ProcessGDBRemote::DoResume: Resume timed out.");
       } else if (event_sp->BroadcasterIs(&m_async_broadcaster)) {
         error.SetErrorString("Broadcast continue, but the async thread was "
                              "killed before we got an ack back.");
-        if (log)
-          log->Printf("ProcessGDBRemote::DoResume: Broadcast continue, but the "
-                      "async thread was killed before we got an ack back.");
+        LLDB_LOGF(log,
+                  "ProcessGDBRemote::DoResume: Broadcast continue, but the "
+                  "async thread was killed before we got an ack back.");
         return error;
       }
     }
@@ -1979,8 +1970,7 @@
               if (watch_id == LLDB_INVALID_WATCH_ID) {
                 Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(
                     GDBR_LOG_WATCHPOINTS));
-                if (log)
-                  log->Printf("failed to find watchpoint");
+                LLDB_LOGF(log, "failed to find watchpoint");
               }
               thread_sp->SetStopInfo(StopInfo::CreateStopReasonWithWatchpointID(
                   *thread_sp, watch_id, wp_hit_addr));
@@ -2501,8 +2491,7 @@
 Status ProcessGDBRemote::DoDetach(bool keep_stopped) {
   Status error;
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-  if (log)
-    log->Printf("ProcessGDBRemote::DoDetach(keep_stopped: %i)", keep_stopped);
+  LLDB_LOGF(log, "ProcessGDBRemote::DoDetach(keep_stopped: %i)", keep_stopped);
 
   error = m_gdb_comm.Detach(keep_stopped);
   if (log) {
@@ -2510,8 +2499,9 @@
       log->PutCString(
           "ProcessGDBRemote::DoDetach() detach packet sent successfully");
     else
-      log->Printf("ProcessGDBRemote::DoDetach() detach packet send failed: %s",
-                  error.AsCString() ? error.AsCString() : "<unknown error>");
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::DoDetach() detach packet send failed: %s",
+                error.AsCString() ? error.AsCString() : "<unknown error>");
   }
 
   if (!error.Success())
@@ -2530,8 +2520,7 @@
 Status ProcessGDBRemote::DoDestroy() {
   Status error;
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-  if (log)
-    log->Printf("ProcessGDBRemote::DoDestroy()");
+  LLDB_LOGF(log, "ProcessGDBRemote::DoDestroy()");
 
   // There is a bug in older iOS debugservers where they don't shut down the
   // process they are debugging properly.  If the process is sitting at a
@@ -2586,11 +2575,11 @@
               reason = stop_info_sp->GetStopReason();
             if (reason == eStopReasonBreakpoint ||
                 reason == eStopReasonException) {
-              if (log)
-                log->Printf(
-                    "ProcessGDBRemote::DoDestroy() - thread: 0x%4.4" PRIx64
-                    " stopped with reason: %s.",
-                    thread_sp->GetProtocolID(), stop_info_sp->GetDescription());
+              LLDB_LOGF(log,
+                        "ProcessGDBRemote::DoDestroy() - thread: 0x%4.4" PRIx64
+                        " stopped with reason: %s.",
+                        thread_sp->GetProtocolID(),
+                        stop_info_sp->GetDescription());
               stop_looks_like_crash = true;
               break;
             }
@@ -2622,10 +2611,10 @@
                 reason = stop_info_sp->GetStopReason();
               if (reason != eStopReasonBreakpoint &&
                   reason != eStopReasonException) {
-                if (log)
-                  log->Printf("ProcessGDBRemote::DoDestroy() - Suspending "
-                              "thread: 0x%4.4" PRIx64 " before running.",
-                              thread_sp->GetProtocolID());
+                LLDB_LOGF(log,
+                          "ProcessGDBRemote::DoDestroy() - Suspending "
+                          "thread: 0x%4.4" PRIx64 " before running.",
+                          thread_sp->GetProtocolID());
                 thread_sp->SetResumeState(eStateSuspended);
               }
             }
@@ -2669,30 +2658,28 @@
             int status;
             ::pid_t reap_pid;
             reap_pid = waitpid(GetID(), &status, WNOHANG);
-            if (log)
-              log->Printf("Reaped pid: %d, status: %d.\n", reap_pid, status);
+            LLDB_LOGF(log, "Reaped pid: %d, status: %d.\n", reap_pid, status);
           }
 #endif
           SetLastStopPacket(response);
           ClearThreadIDList();
           exit_status = response.GetHexU8();
         } else {
-          if (log)
-            log->Printf("ProcessGDBRemote::DoDestroy - got unexpected response "
-                        "to k packet: %s",
-                        response.GetStringRef().c_str());
+          LLDB_LOGF(log,
+                    "ProcessGDBRemote::DoDestroy - got unexpected response "
+                    "to k packet: %s",
+                    response.GetStringRef().c_str());
           exit_string.assign("got unexpected response to k packet: ");
           exit_string.append(response.GetStringRef());
         }
       } else {
-        if (log)
-          log->Printf("ProcessGDBRemote::DoDestroy - failed to send k packet");
+        LLDB_LOGF(log, "ProcessGDBRemote::DoDestroy - failed to send k packet");
         exit_string.assign("failed to send the k packet");
       }
     } else {
-      if (log)
-        log->Printf("ProcessGDBRemote::DoDestroy - killed or interrupted while "
-                    "attaching");
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::DoDestroy - killed or interrupted while "
+                "attaching");
       exit_string.assign("killed or interrupted while attaching.");
     }
   } else {
@@ -2715,8 +2702,7 @@
       response.GetStringRef().find(";reason:exec;") != std::string::npos;
   if (did_exec) {
     Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-    if (log)
-      log->Printf("ProcessGDBRemote::SetLastStopPacket () - detected exec");
+    LLDB_LOGF(log, "ProcessGDBRemote::SetLastStopPacket () - detected exec");
 
     m_thread_list_real.Clear();
     m_thread_list.Clear();
@@ -3078,11 +3064,11 @@
       m_addr_to_mmap_size[allocated_addr] = size;
     else {
       allocated_addr = LLDB_INVALID_ADDRESS;
-      if (log)
-        log->Printf("ProcessGDBRemote::%s no direct stub support for memory "
-                    "allocation, and InferiorCallMmap also failed - is stub "
-                    "missing register context save/restore capability?",
-                    __FUNCTION__);
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::%s no direct stub support for memory "
+                "allocation, and InferiorCallMmap also failed - is stub "
+                "missing register context save/restore capability?",
+                __FUNCTION__);
     }
   }
 
@@ -3173,17 +3159,17 @@
   const addr_t addr = bp_site->GetLoadAddress();
 
   // Log that a breakpoint was requested
-  if (log)
-    log->Printf("ProcessGDBRemote::EnableBreakpointSite (size_id = %" PRIu64
-                ") address = 0x%" PRIx64,
-                site_id, (uint64_t)addr);
+  LLDB_LOGF(log,
+            "ProcessGDBRemote::EnableBreakpointSite (size_id = %" PRIu64
+            ") address = 0x%" PRIx64,
+            site_id, (uint64_t)addr);
 
   // Breakpoint already exists and is enabled
   if (bp_site->IsEnabled()) {
-    if (log)
-      log->Printf("ProcessGDBRemote::EnableBreakpointSite (size_id = %" PRIu64
-                  ") address = 0x%" PRIx64 " -- SUCCESS (already enabled)",
-                  site_id, (uint64_t)addr);
+    LLDB_LOGF(log,
+              "ProcessGDBRemote::EnableBreakpointSite (size_id = %" PRIu64
+              ") address = 0x%" PRIx64 " -- SUCCESS (already enabled)",
+              site_id, (uint64_t)addr);
     return error;
   }
 
@@ -3231,8 +3217,7 @@
     // We reach here when software breakpoints have been found to be
     // unsupported. For future calls to set a breakpoint, we will not attempt
     // to set a breakpoint with a type that is known not to be supported.
-    if (log)
-      log->Printf("Software breakpoints are unsupported");
+    LLDB_LOGF(log, "Software breakpoints are unsupported");
 
     // So we will fall through and try a hardware breakpoint
   }
@@ -3270,8 +3255,7 @@
 
     // We will reach here when the stub gives an unsupported response to a
     // hardware breakpoint
-    if (log)
-      log->Printf("Hardware breakpoints are unsupported");
+    LLDB_LOGF(log, "Hardware breakpoints are unsupported");
 
     // Finally we will falling through to a #trap style breakpoint
   }
@@ -3293,10 +3277,10 @@
   addr_t addr = bp_site->GetLoadAddress();
   user_id_t site_id = bp_site->GetID();
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS));
-  if (log)
-    log->Printf("ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64
-                ") addr = 0x%8.8" PRIx64,
-                site_id, (uint64_t)addr);
+  LLDB_LOGF(log,
+            "ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64
+            ") addr = 0x%8.8" PRIx64,
+            site_id, (uint64_t)addr);
 
   if (bp_site->IsEnabled()) {
     const size_t bp_op_size = GetSoftwareBreakpointTrapOpcode(bp_site);
@@ -3328,10 +3312,10 @@
     if (error.Success())
       bp_site->SetEnabled(false);
   } else {
-    if (log)
-      log->Printf("ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64
-                  ") addr = 0x%8.8" PRIx64 " -- SUCCESS (already disabled)",
-                  site_id, (uint64_t)addr);
+    LLDB_LOGF(log,
+              "ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64
+              ") addr = 0x%8.8" PRIx64 " -- SUCCESS (already disabled)",
+              site_id, (uint64_t)addr);
     return error;
   }
 
@@ -3363,14 +3347,13 @@
     addr_t addr = wp->GetLoadAddress();
     Log *log(
         ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_WATCHPOINTS));
-    if (log)
-      log->Printf("ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64 ")",
-                  watchID);
+    LLDB_LOGF(log, "ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64 ")",
+              watchID);
     if (wp->IsEnabled()) {
-      if (log)
-        log->Printf("ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64
-                    ") addr = 0x%8.8" PRIx64 ": watchpoint already enabled.",
-                    watchID, (uint64_t)addr);
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64
+                ") addr = 0x%8.8" PRIx64 ": watchpoint already enabled.",
+                watchID, (uint64_t)addr);
       return error;
     }
 
@@ -3403,16 +3386,16 @@
 
     addr_t addr = wp->GetLoadAddress();
 
-    if (log)
-      log->Printf("ProcessGDBRemote::DisableWatchpoint (watchID = %" PRIu64
-                  ") addr = 0x%8.8" PRIx64,
-                  watchID, (uint64_t)addr);
+    LLDB_LOGF(log,
+              "ProcessGDBRemote::DisableWatchpoint (watchID = %" PRIu64
+              ") addr = 0x%8.8" PRIx64,
+              watchID, (uint64_t)addr);
 
     if (!wp->IsEnabled()) {
-      if (log)
-        log->Printf("ProcessGDBRemote::DisableWatchpoint (watchID = %" PRIu64
-                    ") addr = 0x%8.8" PRIx64 " -- SUCCESS (already disabled)",
-                    watchID, (uint64_t)addr);
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::DisableWatchpoint (watchID = %" PRIu64
+                ") addr = 0x%8.8" PRIx64 " -- SUCCESS (already disabled)",
+                watchID, (uint64_t)addr);
       // See also 'class WatchpointSentry' within StopInfo.cpp. This disabling
       // attempt might come from the user-supplied actions, we'll route it in
       // order for the watchpoint object to intelligently process this action.
@@ -3447,8 +3430,7 @@
 Status ProcessGDBRemote::DoSignal(int signo) {
   Status error;
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-  if (log)
-    log->Printf("ProcessGDBRemote::DoSignal (signal = %d)", signo);
+  LLDB_LOGF(log, "ProcessGDBRemote::DoSignal (signal = %d)", signo);
 
   if (!m_gdb_comm.SendAsyncSignal(signo))
     error.SetErrorStringWithFormat("failed to send signal %i", signo);
@@ -3586,9 +3568,8 @@
     if (error.Fail()) {
       Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
 
-      if (log)
-        log->Printf("failed to start debugserver process: %s",
-                    error.AsCString());
+      LLDB_LOGF(log, "failed to start debugserver process: %s",
+                error.AsCString());
       return error;
     }
 
@@ -3614,15 +3595,14 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
   const bool handled = true;
 
-  if (log)
-    log->Printf("ProcessGDBRemote::%s(process_wp, pid=%" PRIu64
-                ", signo=%i (0x%x), exit_status=%i)",
-                __FUNCTION__, debugserver_pid, signo, signo, exit_status);
+  LLDB_LOGF(log,
+            "ProcessGDBRemote::%s(process_wp, pid=%" PRIu64
+            ", signo=%i (0x%x), exit_status=%i)",
+            __FUNCTION__, debugserver_pid, signo, signo, exit_status);
 
   std::shared_ptr<ProcessGDBRemote> process_sp = process_wp.lock();
-  if (log)
-    log->Printf("ProcessGDBRemote::%s(process = %p)", __FUNCTION__,
-                static_cast<void *>(process_sp.get()));
+  LLDB_LOGF(log, "ProcessGDBRemote::%s(process = %p)", __FUNCTION__,
+            static_cast<void *>(process_sp.get()));
   if (!process_sp || process_sp->m_debugserver_pid != debugserver_pid)
     return handled;
 
@@ -3692,8 +3672,7 @@
 bool ProcessGDBRemote::StartAsyncThread() {
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
 
-  if (log)
-    log->Printf("ProcessGDBRemote::%s ()", __FUNCTION__);
+  LLDB_LOGF(log, "ProcessGDBRemote::%s ()", __FUNCTION__);
 
   std::lock_guard<std::recursive_mutex> guard(m_async_thread_state_mutex);
   if (!m_async_thread.IsJoinable()) {
@@ -3709,10 +3688,11 @@
       return false;
     }
     m_async_thread = *async_thread;
-  } else if (log)
-    log->Printf("ProcessGDBRemote::%s () - Called when Async thread was "
-                "already running.",
-                __FUNCTION__);
+  } else
+    LLDB_LOGF(log,
+              "ProcessGDBRemote::%s () - Called when Async thread was "
+              "already running.",
+              __FUNCTION__);
 
   return m_async_thread.IsJoinable();
 }
@@ -3720,8 +3700,7 @@
 void ProcessGDBRemote::StopAsyncThread() {
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
 
-  if (log)
-    log->Printf("ProcessGDBRemote::%s ()", __FUNCTION__);
+  LLDB_LOGF(log, "ProcessGDBRemote::%s ()", __FUNCTION__);
 
   std::lock_guard<std::recursive_mutex> guard(m_async_thread_state_mutex);
   if (m_async_thread.IsJoinable()) {
@@ -3733,8 +3712,9 @@
     // Stop the stdio thread
     m_async_thread.Join(nullptr);
     m_async_thread.Reset();
-  } else if (log)
-    log->Printf(
+  } else
+    LLDB_LOGF(
+        log,
         "ProcessGDBRemote::%s () - Called when Async thread was not running.",
         __FUNCTION__);
 }
@@ -3768,25 +3748,25 @@
   ProcessGDBRemote *process = (ProcessGDBRemote *)arg;
 
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-  if (log)
-    log->Printf("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
-                ") thread starting...",
-                __FUNCTION__, arg, process->GetID());
+  LLDB_LOGF(log,
+            "ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
+            ") thread starting...",
+            __FUNCTION__, arg, process->GetID());
 
   EventSP event_sp;
   bool done = false;
   while (!done) {
-    if (log)
-      log->Printf("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
-                  ") listener.WaitForEvent (NULL, event_sp)...",
-                  __FUNCTION__, arg, process->GetID());
+    LLDB_LOGF(log,
+              "ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
+              ") listener.WaitForEvent (NULL, event_sp)...",
+              __FUNCTION__, arg, process->GetID());
     if (process->m_async_listener_sp->GetEvent(event_sp, llvm::None)) {
       const uint32_t event_type = event_sp->GetType();
       if (event_sp->BroadcasterIs(&process->m_async_broadcaster)) {
-        if (log)
-          log->Printf("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
-                      ") Got an event of type: %d...",
-                      __FUNCTION__, arg, process->GetID(), event_type);
+        LLDB_LOGF(log,
+                  "ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
+                  ") Got an event of type: %d...",
+                  __FUNCTION__, arg, process->GetID(), event_type);
 
         switch (event_type) {
         case eBroadcastBitAsyncContinue: {
@@ -3797,10 +3777,10 @@
             const char *continue_cstr =
                 (const char *)continue_packet->GetBytes();
             const size_t continue_cstr_len = continue_packet->GetByteSize();
-            if (log)
-              log->Printf("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
-                          ") got eBroadcastBitAsyncContinue: %s",
-                          __FUNCTION__, arg, process->GetID(), continue_cstr);
+            LLDB_LOGF(log,
+                      "ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
+                      ") got eBroadcastBitAsyncContinue: %s",
+                      __FUNCTION__, arg, process->GetID(), continue_cstr);
 
             if (::strstr(continue_cstr, "vAttach") == nullptr)
               process->SetPrivateState(eStateRunning);
@@ -3891,18 +3871,18 @@
         break;
 
         case eBroadcastBitAsyncThreadShouldExit:
-          if (log)
-            log->Printf("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
-                        ") got eBroadcastBitAsyncThreadShouldExit...",
-                        __FUNCTION__, arg, process->GetID());
+          LLDB_LOGF(log,
+                    "ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
+                    ") got eBroadcastBitAsyncThreadShouldExit...",
+                    __FUNCTION__, arg, process->GetID());
           done = true;
           break;
 
         default:
-          if (log)
-            log->Printf("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
-                        ") got unknown event 0x%8.8x",
-                        __FUNCTION__, arg, process->GetID(), event_type);
+          LLDB_LOGF(log,
+                    "ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
+                    ") got unknown event 0x%8.8x",
+                    __FUNCTION__, arg, process->GetID(), event_type);
           done = true;
           break;
         }
@@ -3925,27 +3905,27 @@
         }
 
         default:
-          if (log)
-            log->Printf("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
-                        ") got unknown event 0x%8.8x",
-                        __FUNCTION__, arg, process->GetID(), event_type);
+          LLDB_LOGF(log,
+                    "ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
+                    ") got unknown event 0x%8.8x",
+                    __FUNCTION__, arg, process->GetID(), event_type);
           done = true;
           break;
         }
       }
     } else {
-      if (log)
-        log->Printf("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
-                    ") listener.WaitForEvent (NULL, event_sp) => false",
-                    __FUNCTION__, arg, process->GetID());
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
+                ") listener.WaitForEvent (NULL, event_sp) => false",
+                __FUNCTION__, arg, process->GetID());
       done = true;
     }
   }
 
-  if (log)
-    log->Printf("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
-                ") thread exiting...",
-                __FUNCTION__, arg, process->GetID());
+  LLDB_LOGF(log,
+            "ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
+            ") thread exiting...",
+            __FUNCTION__, arg, process->GetID());
 
   return {};
 }
@@ -3977,8 +3957,7 @@
   // thread when it starts to
   // run so I can stop it if that's what I want to do.
   Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
-  if (log)
-    log->Printf("Hit New Thread Notification breakpoint.");
+  LLDB_LOGF(log, "Hit New Thread Notification breakpoint.");
   return false;
 }
 
@@ -4023,7 +4002,7 @@
   Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
   if (m_thread_create_bp_sp) {
     if (log && log->GetVerbose())
-      log->Printf("Enabled noticing new thread breakpoint.");
+      LLDB_LOGF(log, "Enabled noticing new thread breakpoint.");
     m_thread_create_bp_sp->SetEnabled(true);
   } else {
     PlatformSP platform_sp(GetTarget().GetPlatform());
@@ -4032,14 +4011,13 @@
           platform_sp->SetThreadCreationBreakpoint(GetTarget());
       if (m_thread_create_bp_sp) {
         if (log && log->GetVerbose())
-          log->Printf(
-              "Successfully created new thread notification breakpoint %i",
+          LLDB_LOGF(
+              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 {
-        if (log)
-          log->Printf("Failed to create new thread notification breakpoint.");
+        LLDB_LOGF(log, "Failed to create new thread notification breakpoint.");
       }
     }
   }
@@ -4049,7 +4027,7 @@
 bool ProcessGDBRemote::StopNoticingNewThreads() {
   Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
   if (log && log->GetVerbose())
-    log->Printf("Disabling new thread notification breakpoint.");
+    LLDB_LOGF(log, "Disabling new thread notification breakpoint.");
 
   if (m_thread_create_bp_sp)
     m_thread_create_bp_sp->SetEnabled(false);
@@ -4325,19 +4303,18 @@
   }
 
   if (!m_gdb_comm.GetModuleInfo(module_file_spec, arch, module_spec)) {
-    if (log)
-      log->Printf("ProcessGDBRemote::%s - failed to get module info for %s:%s",
-                  __FUNCTION__, module_file_spec.GetPath().c_str(),
-                  arch.GetTriple().getTriple().c_str());
+    LLDB_LOGF(log, "ProcessGDBRemote::%s - failed to get module info for %s:%s",
+              __FUNCTION__, module_file_spec.GetPath().c_str(),
+              arch.GetTriple().getTriple().c_str());
     return false;
   }
 
   if (log) {
     StreamString stream;
     module_spec.Dump(stream);
-    log->Printf("ProcessGDBRemote::%s - got module info for (%s:%s) : %s",
-                __FUNCTION__, module_file_spec.GetPath().c_str(),
-                arch.GetTriple().getTriple().c_str(), stream.GetData());
+    LLDB_LOGF(log, "ProcessGDBRemote::%s - got module info for (%s:%s) : %s",
+              __FUNCTION__, module_file_spec.GetPath().c_str(),
+              arch.GetTriple().getTriple().c_str(), stream.GetData());
   }
 
   m_cached_module_specs[key] = module_spec;
@@ -4711,8 +4688,7 @@
     return Status(0, ErrorType::eErrorTypeGeneric);
 
   Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS);
-  if (log)
-    log->Printf("ProcessGDBRemote::%s", __FUNCTION__);
+  LLDB_LOGF(log, "ProcessGDBRemote::%s", __FUNCTION__);
 
   GDBRemoteCommunicationClient &comm = m_gdb_comm;
   bool can_use_svr4 = GetGlobalPluginProperties()->GetUseSVR4();
@@ -4730,8 +4706,7 @@
       return Status(0, ErrorType::eErrorTypeGeneric);
 
     // parse the xml file in memory
-    if (log)
-      log->Printf("parsing: %s", raw.c_str());
+    LLDB_LOGF(log, "parsing: %s", raw.c_str());
     XMLDocument doc;
 
     if (!doc.ParseMemory(raw.c_str(), raw.size(), "noname.xml"))
@@ -4791,10 +4766,11 @@
             module.get_base_is_offset(base_is_offset);
             module.get_dynamic(ld);
 
-            log->Printf("found (link_map:0x%08" PRIx64 ", base:0x%08" PRIx64
-                        "[%s], ld:0x%08" PRIx64 ", name:'%s')",
-                        lm, base, (base_is_offset ? "offset" : "absolute"), ld,
-                        name.c_str());
+            LLDB_LOGF(log,
+                      "found (link_map:0x%08" PRIx64 ", base:0x%08" PRIx64
+                      "[%s], ld:0x%08" PRIx64 ", name:'%s')",
+                      lm, base, (base_is_offset ? "offset" : "absolute"), ld,
+                      name.c_str());
           }
 
           list.add(module);
@@ -4802,9 +4778,8 @@
                        // node
         });
 
-    if (log)
-      log->Printf("found %" PRId32 " modules in total",
-                  (int)list.m_list.size());
+    LLDB_LOGF(log, "found %" PRId32 " modules in total",
+              (int)list.m_list.size());
   } else if (comm.GetQXferLibrariesReadSupported()) {
     list.clear();
 
@@ -4816,8 +4791,7 @@
                              lldberr))
       return Status(0, ErrorType::eErrorTypeGeneric);
 
-    if (log)
-      log->Printf("parsing: %s", raw.c_str());
+    LLDB_LOGF(log, "parsing: %s", raw.c_str());
     XMLDocument doc;
 
     if (!doc.ParseMemory(raw.c_str(), raw.size(), "noname.xml"))
@@ -4853,8 +4827,8 @@
             module.get_base(base);
             module.get_base_is_offset(base_is_offset);
 
-            log->Printf("found (base:0x%08" PRIx64 "[%s], name:'%s')", base,
-                        (base_is_offset ? "offset" : "absolute"), name.c_str());
+            LLDB_LOGF(log, "found (base:0x%08" PRIx64 "[%s], name:'%s')", base,
+                      (base_is_offset ? "offset" : "absolute"), name.c_str());
           }
 
           list.add(module);
@@ -4862,9 +4836,8 @@
                        // node
         });
 
-    if (log)
-      log->Printf("found %" PRId32 " modules in total",
-                  (int)list.m_list.size());
+    LLDB_LOGF(log, "found %" PRId32 " modules in total",
+              (int)list.m_list.size());
   } else {
     return Status(0, ErrorType::eErrorTypeGeneric);
   }
@@ -5149,7 +5122,8 @@
 
   if (!packet.consume_front(s_async_json_packet_prefix)) {
     if (log) {
-      log->Printf(
+      LLDB_LOGF(
+          log,
           "GDBRemoteCommunicationClientBase::%s() received $J packet "
           "but was not a StructuredData packet: packet starts with "
           "%s",
@@ -5166,14 +5140,16 @@
       StreamString json_str;
       json_sp->Dump(json_str);
       json_str.Flush();
-      log->Printf("ProcessGDBRemote::%s() "
-                  "received Async StructuredData packet: %s",
-                  __FUNCTION__, json_str.GetData());
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::%s() "
+                "received Async StructuredData packet: %s",
+                __FUNCTION__, json_str.GetData());
     } else {
-      log->Printf("ProcessGDBRemote::%s"
-                  "() received StructuredData packet:"
-                  " parse failure",
-                  __FUNCTION__);
+      LLDB_LOGF(log,
+                "ProcessGDBRemote::%s"
+                "() received StructuredData packet:"
+                " parse failure",
+                __FUNCTION__);
     }
   }
   return json_sp;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index 6607bce..8a6a58c 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -215,8 +215,7 @@
   StructuredData::ObjectSP object_sp;
   const lldb::user_id_t tid = GetProtocolID();
   Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
-  if (log)
-    log->Printf("Fetching extended information for thread %4.4" PRIx64, tid);
+  LLDB_LOGF(log, "Fetching extended information for thread %4.4" PRIx64, tid);
   ProcessSP process_sp(GetProcess());
   if (process_sp) {
     ProcessGDBRemote *gdb_process =
@@ -230,9 +229,8 @@
   int signo = GetResumeSignal();
   const lldb::user_id_t tid = GetProtocolID();
   Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
-  if (log)
-    log->Printf("Resuming thread: %4.4" PRIx64 " with state: %s.", tid,
-                StateAsCString(resume_state));
+  LLDB_LOGF(log, "Resuming thread: %4.4" PRIx64 " with state: %s.", tid,
+            StateAsCString(resume_state));
 
   ProcessSP process_sp(GetProcess());
   if (process_sp) {