[Lldb-commits] [lldb] 7cd1d42 - [lldb] Remove __FUNCTION__ from log messages in lldbHost (NFC)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 6 13:03:00 PDT 2023
Author: Jonas Devlieghere
Date: 2023-06-06T13:02:43-07:00
New Revision: 7cd1d4231a7c83e719b83c6abbe2d479baa03808
URL: https://github.com/llvm/llvm-project/commit/7cd1d4231a7c83e719b83c6abbe2d479baa03808
DIFF: https://github.com/llvm/llvm-project/commit/7cd1d4231a7c83e719b83c6abbe2d479baa03808.diff
LOG: [lldb] Remove __FUNCTION__ from log messages in lldbHost (NFC)
LLDB's logging infrastructure supports prepending log messages with the
name of the file and function that generates the log (see help log
enable). Therefore it's unnecessary to include the current __FUNCTION__
in the log message itself. This patch removes __FUNCTION__ from log
messages in the Host library.
Differential revision: https://reviews.llvm.org/D151762
Added:
Modified:
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
Removed:
################################################################################
diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp
index 0c0d786c44f7c..5c44c2f38b287 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -225,24 +225,20 @@ bool HostInfoBase::ComputePathRelativeToLibrary(FileSpec &file_spec,
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();
}
diff --git a/lldb/source/Host/common/NativeRegisterContext.cpp b/lldb/source/Host/common/NativeRegisterContext.cpp
index 1be519d129eef..411f5f5c92ed0 100644
--- a/lldb/source/Host/common/NativeRegisterContext.cpp
+++ b/lldb/source/Host/common/NativeRegisterContext.cpp
@@ -125,15 +125,12 @@ lldb::addr_t NativeRegisterContext::GetPC(lldb::addr_t fail_value) {
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 @@ NativeRegisterContext::ReadRegisterAsUnsigned(const RegisterInfo *reg_info,
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 @@ NativeRegisterContext::ReadRegisterAsUnsigned(const RegisterInfo *reg_info,
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);
}
diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp
index 82b00ac561f9a..df4737216ed3a 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -150,7 +150,7 @@ Status TCPSocket::CreateSocket(int domain) {
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::Connect(llvm::StringRef name) {
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);
diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index c80d2002b8f18..06b8df8df2aa2 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -152,8 +152,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
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 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
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);
@@ -496,7 +495,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
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()) {
@@ -510,13 +509,13 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
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");
}
More information about the lldb-commits
mailing list