JDevlieghere updated this revision to Diff 526854.
JDevlieghere added a comment.

Use `LLDB_LOG` when `StringRef`s are involved.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151762/new/

https://reviews.llvm.org/D151762

Files:
  lldb/source/Host/common/HostInfoBase.cpp
  lldb/source/Host/common/NativeRegisterContext.cpp
  lldb/source/Host/common/TCPSocket.cpp
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===================================================================
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -152,8 +152,7 @@
     FileSystem::Instance().Resolve(support_dir_spec);
     if (!FileSystem::Instance().IsDirectory(support_dir_spec)) {
       Log *log = GetLog(LLDBLog::Host);
-      LLDB_LOGF(log, "HostInfoMacOSX::%s(): failed to find support directory",
-                __FUNCTION__);
+      LLDB_LOG(log, "failed to find support directory");
       return false;
     }
 
@@ -342,8 +341,8 @@
         HostInfo::GetSDKRoot(SDKOptions{XcodeSDK::GetAnyMacOS()});
     if (!sdk_path_or_err) {
       Log *log = GetLog(LLDBLog::Host);
-      LLDB_LOGF(log, "Error while searching for Xcode SDK: %s",
-                toString(sdk_path_or_err.takeError()).c_str());
+      LLDB_LOG_ERROR(log, sdk_path_or_err.takeError(),
+                     "Error while searching for Xcode SDK: {0}");
       return;
     }
     FileSpec fspec(*sdk_path_or_err);
@@ -493,7 +492,7 @@
       if (!path.empty())
         break;
     }
-    LLDB_LOGF(log, "Couldn't find SDK %s on host", sdk_name.c_str());
+    LLDB_LOG(log, "Couldn't find SDK {0} on host", sdk_name);
 
     // Try without the version.
     if (!info.version.empty()) {
@@ -507,13 +506,13 @@
         break;
     }
 
-    LLDB_LOGF(log, "Couldn't find any matching SDK on host");
+    LLDB_LOG(log, "Couldn't find any matching SDK on host");
     return "";
   }
 
   // Whatever is left in output should be a valid path.
   if (!FileSystem::Instance().Exists(path)) {
-    LLDB_LOGF(log, "SDK returned by xcrun doesn't exist");
+    LLDB_LOG(log, "SDK returned by xcrun doesn't exist");
     return llvm::createStringError(llvm::inconvertibleErrorCode(),
                                    "SDK returned by xcrun doesn't exist");
   }
Index: lldb/source/Host/common/TCPSocket.cpp
===================================================================
--- lldb/source/Host/common/TCPSocket.cpp
+++ lldb/source/Host/common/TCPSocket.cpp
@@ -150,7 +150,7 @@
 Status TCPSocket::Connect(llvm::StringRef name) {
 
   Log *log = GetLog(LLDBLog::Communication);
-  LLDB_LOGF(log, "TCPSocket::%s (host/port = %s)", __FUNCTION__, name.data());
+  LLDB_LOG(log, "Connect to host/port {0}", name);
 
   Status error;
   llvm::Expected<HostAndPort> host_port = DecodeHostAndPort(name);
@@ -189,7 +189,7 @@
 
 Status TCPSocket::Listen(llvm::StringRef name, int backlog) {
   Log *log = GetLog(LLDBLog::Connection);
-  LLDB_LOGF(log, "TCPSocket::%s (%s)", __FUNCTION__, name.data());
+  LLDB_LOG(log, "Listen to {0}", name);
 
   Status error;
   llvm::Expected<HostAndPort> host_port = DecodeHostAndPort(name);
Index: lldb/source/Host/common/NativeRegisterContext.cpp
===================================================================
--- lldb/source/Host/common/NativeRegisterContext.cpp
+++ lldb/source/Host/common/NativeRegisterContext.cpp
@@ -125,15 +125,12 @@
 
   uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric,
                                                      LLDB_REGNUM_GENERIC_PC);
-  LLDB_LOGF(log,
-            "NativeRegisterContext::%s using reg index %" PRIu32
-            " (default %" PRIu64 ")",
-            __FUNCTION__, reg, fail_value);
+  LLDB_LOGF(log, "Using reg index %" PRIu32 " (default %" PRIu64 ")", reg,
+            fail_value);
 
   const uint64_t retval = ReadRegisterAsUnsigned(reg, fail_value);
 
-  LLDB_LOGF(log, "NativeRegisterContext::%s " PRIu32 " retval %" PRIu64,
-            __FUNCTION__, retval);
+  LLDB_LOGF(log, PRIu32 " retval %" PRIu64, retval);
 
   return retval;
 }
@@ -203,18 +200,15 @@
     Status error = ReadRegister(reg_info, value);
     if (error.Success()) {
       LLDB_LOGF(log,
-                "NativeRegisterContext::%s ReadRegister() succeeded, value "
+                "Read register succeeded: value "
                 "%" PRIu64,
-                __FUNCTION__, value.GetAsUInt64());
+                value.GetAsUInt64());
       return value.GetAsUInt64();
     } else {
-      LLDB_LOGF(log,
-                "NativeRegisterContext::%s ReadRegister() failed, error %s",
-                __FUNCTION__, error.AsCString());
+      LLDB_LOGF(log, "Read register failed: error %s", error.AsCString());
     }
   } else {
-    LLDB_LOGF(log, "NativeRegisterContext::%s ReadRegister() null reg_info",
-              __FUNCTION__);
+    LLDB_LOGF(log, "Read register failed: null reg_info");
   }
   return fail_value;
 }
@@ -222,7 +216,7 @@
 Status NativeRegisterContext::WriteRegisterFromUnsigned(uint32_t reg,
                                                         uint64_t uval) {
   if (reg == LLDB_INVALID_REGNUM)
-    return Status("NativeRegisterContext::%s (): reg is invalid", __FUNCTION__);
+    return Status("Write register failed: reg is invalid");
   return WriteRegisterFromUnsigned(GetRegisterInfoAtIndex(reg), uval);
 }
 
Index: lldb/source/Host/common/HostInfoBase.cpp
===================================================================
--- lldb/source/Host/common/HostInfoBase.cpp
+++ lldb/source/Host/common/HostInfoBase.cpp
@@ -225,24 +225,20 @@
     return false;
 
   std::string raw_path = lldb_file_spec.GetPath();
-  LLDB_LOGF(log,
-            "HostInfo::%s() attempting to "
-            "derive the path %s relative to liblldb install path: %s",
-            __FUNCTION__, dir.data(), raw_path.c_str());
+  LLDB_LOG(
+      log,
+      "Attempting to derive the path {0} relative to liblldb install path: {1}",
+      dir, raw_path);
 
   // Drop bin (windows) or lib
   llvm::StringRef parent_path = llvm::sys::path::parent_path(raw_path);
   if (parent_path.empty()) {
-    LLDB_LOGF(log,
-              "HostInfo::%s() failed to find liblldb within the shared "
-              "lib path",
-              __FUNCTION__);
+    LLDB_LOG(log, "Failed to find liblldb within the shared lib path");
     return false;
   }
 
   raw_path = (parent_path + dir).str();
-  LLDB_LOGF(log, "HostInfo::%s() derived the path as: %s", __FUNCTION__,
-            raw_path.c_str());
+  LLDB_LOG(log, "Derived the path as: {0}", raw_path);
   file_spec.SetDirectory(raw_path);
   return (bool)file_spec.GetDirectory();
 }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to