diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-24 17:56:10 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-24 17:56:10 +0000 |
commit | 63e5fb76ecfed3434252868d8cf07d676f979f2f (patch) | |
tree | 349d6bd303f53aa57b988dee284c7f264404a8fc /lldb/source/Plugins/Process/MacOSX-Kernel | |
parent | 2bf871be4c35d70db080dde789cf9bb334c04057 (diff) | |
download | bcm5719-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/MacOSX-Kernel')
-rw-r--r-- | lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp | 26 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp | 90 |
2 files changed, 54 insertions, 62 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index 1a75326f3b2..5737efd1d6e 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -70,8 +70,8 @@ bool CommunicationKDP::SendRequestAndGetReply( if (log) { PacketStreamType log_strm; DumpPacket(log_strm, request_packet.GetData(), request_packet.GetSize()); - log->Printf("error: kdp running, not sending packet: %.*s", - (uint32_t)log_strm.GetSize(), log_strm.GetData()); + LLDB_LOGF(log, "error: kdp running, not sending packet: %.*s", + (uint32_t)log_strm.GetSize(), log_strm.GetData()); } return false; } @@ -140,7 +140,7 @@ bool CommunicationKDP::SendRequestPacketNoLock( if (log) { PacketStreamType log_strm; DumpPacket(log_strm, packet_data, packet_size); - log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData()); + LLDB_LOGF(log, "%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData()); } ConnectionStatus status = eConnectionStatusSuccess; @@ -149,10 +149,10 @@ bool CommunicationKDP::SendRequestPacketNoLock( if (bytes_written == packet_size) return true; - if (log) - log->Printf("error: failed to send packet entire packet %" PRIu64 - " of %" PRIu64 " bytes sent", - (uint64_t)bytes_written, (uint64_t)packet_size); + LLDB_LOGF(log, + "error: failed to send packet entire packet %" PRIu64 + " of %" PRIu64 " bytes sent", + (uint64_t)bytes_written, (uint64_t)packet_size); } return false; } @@ -241,8 +241,8 @@ bool CommunicationKDP::CheckForPacket(const uint8_t *src, size_t src_len, if (log && log->GetVerbose()) { PacketStreamType log_strm; DumpHexBytes(&log_strm, src, src_len, UINT32_MAX, LLDB_INVALID_ADDRESS); - log->Printf("CommunicationKDP::%s adding %u bytes: %s", __FUNCTION__, - (uint32_t)src_len, log_strm.GetData()); + LLDB_LOGF(log, "CommunicationKDP::%s adding %u bytes: %s", __FUNCTION__, + (uint32_t)src_len, log_strm.GetData()); } m_bytes.append((const char *)src, src_len); } @@ -314,7 +314,8 @@ bool CommunicationKDP::CheckForPacket(const uint8_t *src, size_t src_len, PacketStreamType log_strm; DumpPacket(log_strm, packet); - log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData()); + LLDB_LOGF(log, "%.*s", (uint32_t)log_strm.GetSize(), + log_strm.GetData()); } return true; } @@ -323,9 +324,8 @@ bool CommunicationKDP::CheckForPacket(const uint8_t *src, size_t src_len, default: // Unrecognized reply command byte, erase this byte and try to get back // on track - if (log) - log->Printf("CommunicationKDP::%s: tossing junk byte: 0x%2.2x", - __FUNCTION__, (uint8_t)m_bytes[0]); + LLDB_LOGF(log, "CommunicationKDP::%s: tossing junk byte: 0x%2.2x", + __FUNCTION__, (uint8_t)m_bytes[0]); m_bytes.erase(0, 1); break; } diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index 6f1bb4b6476..52c494db6be 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -394,8 +394,7 @@ void ProcessKDP::DidAttach(ArchSpec &process_arch) { Process::DidAttach(process_arch); Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); - if (log) - log->Printf("ProcessKDP::DidAttach()"); + LLDB_LOGF(log, "ProcessKDP::DidAttach()"); if (GetID() != LLDB_INVALID_PROCESS_ID) { GetHostArchitecture(process_arch); } @@ -429,15 +428,13 @@ Status ProcessKDP::DoResume() { const StateType thread_resume_state = kernel_thread_sp->GetTemporaryResumeState(); - if (log) - log->Printf("ProcessKDP::DoResume() thread_resume_state = %s", - StateAsCString(thread_resume_state)); + LLDB_LOGF(log, "ProcessKDP::DoResume() thread_resume_state = %s", + StateAsCString(thread_resume_state)); switch (thread_resume_state) { case eStateSuspended: // Nothing to do here when a thread will stay suspended we just leave the // CPU mask bit set to zero for the thread - if (log) - log->Printf("ProcessKDP::DoResume() = suspended???"); + LLDB_LOGF(log, "ProcessKDP::DoResume() = suspended???"); break; case eStateStepping: { @@ -445,9 +442,9 @@ Status ProcessKDP::DoResume() { kernel_thread_sp->GetRegisterContext()); if (reg_ctx_sp) { - if (log) - log->Printf( - "ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep (true);"); + LLDB_LOGF( + log, + "ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep (true);"); reg_ctx_sp->HardwareSingleStep(true); resume = true; } else { @@ -462,9 +459,8 @@ Status ProcessKDP::DoResume() { kernel_thread_sp->GetRegisterContext()); if (reg_ctx_sp) { - if (log) - log->Printf("ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep " - "(false);"); + LLDB_LOGF(log, "ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep " + "(false);"); reg_ctx_sp->HardwareSingleStep(false); resume = true; } else { @@ -481,8 +477,7 @@ Status ProcessKDP::DoResume() { } if (resume) { - if (log) - log->Printf("ProcessKDP::DoResume () sending resume"); + LLDB_LOGF(log, "ProcessKDP::DoResume () sending resume"); if (m_comm.SendRequestResume()) { m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue); @@ -550,8 +545,7 @@ Status ProcessKDP::DoHalt(bool &caused_stop) { Status ProcessKDP::DoDetach(bool keep_stopped) { Status error; Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); - if (log) - log->Printf("ProcessKDP::DoDetach(keep_stopped = %i)", keep_stopped); + LLDB_LOGF(log, "ProcessKDP::DoDetach(keep_stopped = %i)", keep_stopped); if (m_comm.IsRunning()) { // We are running and we can't interrupt a running kernel, so we need to @@ -734,8 +728,7 @@ void ProcessKDP::DebuggerInitialize(lldb_private::Debugger &debugger) { bool ProcessKDP::StartAsyncThread() { Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); - if (log) - log->Printf("ProcessKDP::StartAsyncThread ()"); + LLDB_LOGF(log, "ProcessKDP::StartAsyncThread ()"); if (m_async_thread.IsJoinable()) return true; @@ -755,8 +748,7 @@ bool ProcessKDP::StartAsyncThread() { void ProcessKDP::StopAsyncThread() { Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); - if (log) - log->Printf("ProcessKDP::StopAsyncThread ()"); + LLDB_LOGF(log, "ProcessKDP::StopAsyncThread ()"); m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncThreadShouldExit); @@ -771,10 +763,10 @@ void *ProcessKDP::AsyncThread(void *arg) { const lldb::pid_t pid = process->GetID(); Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); - if (log) - log->Printf("ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 - ") thread starting...", - arg, pid); + LLDB_LOGF(log, + "ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 + ") thread starting...", + arg, pid); ListenerSP listener_sp(Listener::MakeListener("ProcessKDP::AsyncThread")); EventSP event_sp; @@ -786,16 +778,16 @@ void *ProcessKDP::AsyncThread(void *arg) { desired_event_mask) { bool done = false; while (!done) { - if (log) - log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64 - ") listener.WaitForEvent (NULL, event_sp)...", - pid); + LLDB_LOGF(log, + "ProcessKDP::AsyncThread (pid = %" PRIu64 + ") listener.WaitForEvent (NULL, event_sp)...", + pid); if (listener_sp->GetEvent(event_sp, llvm::None)) { uint32_t event_type = event_sp->GetType(); - if (log) - log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64 - ") Got an event of type: %d...", - pid, event_type); + LLDB_LOGF(log, + "ProcessKDP::AsyncThread (pid = %" PRIu64 + ") Got an event of type: %d...", + pid, event_type); // When we are running, poll for 1 second to try and get an exception // to indicate the process has stopped. If we don't get one, check to @@ -834,38 +826,38 @@ void *ProcessKDP::AsyncThread(void *arg) { } break; case eBroadcastBitAsyncThreadShouldExit: - if (log) - log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64 - ") got eBroadcastBitAsyncThreadShouldExit...", - pid); + LLDB_LOGF(log, + "ProcessKDP::AsyncThread (pid = %" PRIu64 + ") got eBroadcastBitAsyncThreadShouldExit...", + pid); done = true; is_running = false; break; default: - if (log) - log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64 - ") got unknown event 0x%8.8x", - pid, event_type); + LLDB_LOGF(log, + "ProcessKDP::AsyncThread (pid = %" PRIu64 + ") got unknown event 0x%8.8x", + pid, event_type); done = true; is_running = false; break; } } while (is_running); } else { - if (log) - log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64 - ") listener.WaitForEvent (NULL, event_sp) => false", - pid); + LLDB_LOGF(log, + "ProcessKDP::AsyncThread (pid = %" PRIu64 + ") listener.WaitForEvent (NULL, event_sp) => false", + pid); done = true; } } } - if (log) - log->Printf("ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 - ") thread exiting...", - arg, pid); + LLDB_LOGF(log, + "ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 + ") thread exiting...", + arg, pid); process->m_async_thread.Reset(); return NULL; |