summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/Socket.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-07-24 17:56:10 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-07-24 17:56:10 +0000
commit63e5fb76ecfed3434252868d8cf07d676f979f2f (patch)
tree349d6bd303f53aa57b988dee284c7f264404a8fc /lldb/source/Host/common/Socket.cpp
parent2bf871be4c35d70db080dde789cf9bb334c04057 (diff)
downloadbcm5719-llvm-63e5fb76ecfed3434252868d8cf07d676f979f2f.tar.gz
bcm5719-llvm-63e5fb76ecfed3434252868d8cf07d676f979f2f.zip
[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
Diffstat (limited to 'lldb/source/Host/common/Socket.cpp')
-rw-r--r--lldb/source/Host/common/Socket.cpp44
1 files changed, 21 insertions, 23 deletions
diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp
index a89f1178e96..ea1049dad81 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -149,9 +149,8 @@ std::unique_ptr<Socket> Socket::Create(const SocketProtocol protocol,
Status Socket::TcpConnect(llvm::StringRef host_and_port,
bool child_processes_inherit, Socket *&socket) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
- if (log)
- log->Printf("Socket::%s (host/port = %s)", __FUNCTION__,
- host_and_port.str().c_str());
+ LLDB_LOGF(log, "Socket::%s (host/port = %s)", __FUNCTION__,
+ host_and_port.str().c_str());
Status error;
std::unique_ptr<Socket> connect_socket(
@@ -170,8 +169,7 @@ Status Socket::TcpListen(llvm::StringRef host_and_port,
bool child_processes_inherit, Socket *&socket,
Predicate<uint16_t> *predicate, int backlog) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
- if (log)
- log->Printf("Socket::%s (%s)", __FUNCTION__, host_and_port.str().c_str());
+ LLDB_LOGF(log, "Socket::%s (%s)", __FUNCTION__, host_and_port.str().c_str());
Status error;
std::string host_str;
@@ -209,9 +207,8 @@ Status Socket::TcpListen(llvm::StringRef host_and_port,
Status Socket::UdpConnect(llvm::StringRef host_and_port,
bool child_processes_inherit, Socket *&socket) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
- if (log)
- log->Printf("Socket::%s (host/port = %s)", __FUNCTION__,
- host_and_port.str().c_str());
+ LLDB_LOGF(log, "Socket::%s (host/port = %s)", __FUNCTION__,
+ host_and_port.str().c_str());
return UDPSocket::Connect(host_and_port, child_processes_inherit, socket);
}
@@ -345,12 +342,13 @@ Status Socket::Read(void *buf, size_t &num_bytes) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
if (log) {
- log->Printf("%p Socket::Read() (socket = %" PRIu64
- ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64
- " (error = %s)",
- static_cast<void *>(this), static_cast<uint64_t>(m_socket), buf,
- static_cast<uint64_t>(num_bytes),
- static_cast<int64_t>(bytes_received), error.AsCString());
+ LLDB_LOGF(log,
+ "%p Socket::Read() (socket = %" PRIu64
+ ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64
+ " (error = %s)",
+ static_cast<void *>(this), static_cast<uint64_t>(m_socket), buf,
+ static_cast<uint64_t>(num_bytes),
+ static_cast<int64_t>(bytes_received), error.AsCString());
}
return error;
@@ -371,12 +369,13 @@ Status Socket::Write(const void *buf, size_t &num_bytes) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
if (log) {
- log->Printf("%p Socket::Write() (socket = %" PRIu64
- ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64
- " (error = %s)",
- static_cast<void *>(this), static_cast<uint64_t>(m_socket), buf,
- static_cast<uint64_t>(num_bytes),
- static_cast<int64_t>(bytes_sent), error.AsCString());
+ LLDB_LOGF(log,
+ "%p Socket::Write() (socket = %" PRIu64
+ ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64
+ " (error = %s)",
+ static_cast<void *>(this), static_cast<uint64_t>(m_socket), buf,
+ static_cast<uint64_t>(num_bytes),
+ static_cast<int64_t>(bytes_sent), error.AsCString());
}
return error;
@@ -393,9 +392,8 @@ Status Socket::Close() {
return error;
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
- if (log)
- log->Printf("%p Socket::Close (fd = %" PRIu64 ")",
- static_cast<void *>(this), static_cast<uint64_t>(m_socket));
+ LLDB_LOGF(log, "%p Socket::Close (fd = %" PRIu64 ")",
+ static_cast<void *>(this), static_cast<uint64_t>(m_socket));
#if defined(_WIN32)
bool success = !!closesocket(m_socket);
OpenPOWER on IntegriCloud