summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.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/Plugins/Process/gdb-remote/GDBRemoteClientBase.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/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp70
1 files changed, 31 insertions, 39 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
index fe7ef6b3ace..140e2433023 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
@@ -63,18 +63,16 @@ StateType GDBRemoteClientBase::SendContinuePacketAndWaitForResponse(
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 @@ StateType GDBRemoteClientBase::SendContinuePacketAndWaitForResponse(
// 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 @@ GDBRemoteClientBase::SendPacketAndWaitForResponse(
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 @@ GDBRemoteClientBase::SendPacketAndReceiveResponseWithOutputSupport(
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 @@ GDBRemoteClientBase::SendPacketAndWaitForResponseNoLock(
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 @@ GDBRemoteClientBase::SendPacketAndWaitForResponseNoLock(
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 @@ void GDBRemoteClientBase::ContinueLock::unlock() {
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 @@ void GDBRemoteClientBase::Lock::SyncWithContinueThread(bool interrupt) {
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)
OpenPOWER on IntegriCloud