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/FreeBSD/ProcessMonitor.cpp | |
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/FreeBSD/ProcessMonitor.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp | 80 |
1 files changed, 38 insertions, 42 deletions
diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp index 4b9225db5e3..2866ebf479b 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp @@ -66,13 +66,14 @@ extern long PtraceWrapper(int req, lldb::pid_t pid, void *addr, int data, Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); if (log) { - log->Printf("ptrace(%s, %" PRIu64 ", %p, %x) called from file %s line %d", - reqName, pid, addr, data, file, line); + LLDB_LOGF(log, + "ptrace(%s, %" PRIu64 ", %p, %x) called from file %s line %d", + reqName, pid, addr, data, file, line); if (req == PT_IO) { struct ptrace_io_desc *pi = (struct ptrace_io_desc *)addr; - log->Printf("PT_IO: op=%s offs=%zx size=%zu", Get_PT_IO_OP(pi->piod_op), - (size_t)pi->piod_offs, pi->piod_len); + LLDB_LOGF(log, "PT_IO: op=%s offs=%zx size=%zu", + Get_PT_IO_OP(pi->piod_op), (size_t)pi->piod_offs, pi->piod_len); } } @@ -101,7 +102,7 @@ extern long PtraceWrapper(int req, lldb::pid_t pid, void *addr, int data, default: str = "<unknown>"; } - log->Printf("ptrace() failed; errno=%d (%s)", errno, str); + LLDB_LOGF(log, "ptrace() failed; errno=%d (%s)", errno, str); } if (log) { @@ -109,15 +110,15 @@ extern long PtraceWrapper(int req, lldb::pid_t pid, void *addr, int data, if (req == PT_GETREGS) { struct reg *r = (struct reg *)addr; - log->Printf("PT_GETREGS: rip=0x%lx rsp=0x%lx rbp=0x%lx rax=0x%lx", - r->r_rip, r->r_rsp, r->r_rbp, r->r_rax); + LLDB_LOGF(log, "PT_GETREGS: rip=0x%lx rsp=0x%lx rbp=0x%lx rax=0x%lx", + r->r_rip, r->r_rsp, r->r_rbp, r->r_rax); } if (req == PT_GETDBREGS || req == PT_SETDBREGS) { struct dbreg *r = (struct dbreg *)addr; char setget = (req == PT_GETDBREGS) ? 'G' : 'S'; for (int i = 0; i <= 7; i++) - log->Printf("PT_%cETDBREGS: dr[%d]=0x%lx", setget, i, r->dr[i]); + LLDB_LOGF(log, "PT_%cETDBREGS: dr[%d]=0x%lx", setget, i, r->dr[i]); } #endif } @@ -1037,9 +1038,8 @@ bool ProcessMonitor::MonitorCallback(ProcessMonitor *monitor, lldb::pid_t pid, Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); if (exited) { - if (log) - log->Printf("ProcessMonitor::%s() got exit signal, tid = %" PRIu64, - __FUNCTION__, pid); + LLDB_LOGF(log, "ProcessMonitor::%s() got exit signal, tid = %" PRIu64, + __FUNCTION__, pid); message = ProcessMessage::Exit(pid, status); process->SendMessage(message); return pid == process->GetID(); @@ -1087,10 +1087,10 @@ ProcessMessage ProcessMonitor::MonitorSIGTRAP(ProcessMonitor *monitor, unsigned long data = 0; if (!monitor->GetEventMessage(tid, &data)) data = -1; - if (log) - log->Printf("ProcessMonitor::%s() received exit? event, data = %lx, tid " - "= %" PRIu64, - __FUNCTION__, data, tid); + LLDB_LOGF(log, + "ProcessMonitor::%s() received exit? event, data = %lx, tid " + "= %" PRIu64, + __FUNCTION__, data, tid); message = ProcessMessage::Limbo(tid, (data >> 8)); break; } @@ -1101,26 +1101,25 @@ ProcessMessage ProcessMonitor::MonitorSIGTRAP(ProcessMonitor *monitor, // Map TRAP_CAP to a trace trap in the absense of a more specific handler. case TRAP_CAP: #endif - if (log) - log->Printf("ProcessMonitor::%s() received trace event, tid = %" PRIu64 - " : si_code = %d", - __FUNCTION__, tid, info->si_code); + LLDB_LOGF(log, + "ProcessMonitor::%s() received trace event, tid = %" PRIu64 + " : si_code = %d", + __FUNCTION__, tid, info->si_code); message = ProcessMessage::Trace(tid); break; case SI_KERNEL: case TRAP_BRKPT: if (monitor->m_process->IsSoftwareStepBreakpoint(tid)) { - if (log) - log->Printf("ProcessMonitor::%s() received sw single step breakpoint " - "event, tid = %" PRIu64, - __FUNCTION__, tid); + LLDB_LOGF(log, + "ProcessMonitor::%s() received sw single step breakpoint " + "event, tid = %" PRIu64, + __FUNCTION__, tid); message = ProcessMessage::Trace(tid); } else { - if (log) - log->Printf( - "ProcessMonitor::%s() received breakpoint event, tid = %" PRIu64, - __FUNCTION__, tid); + LLDB_LOGF( + log, "ProcessMonitor::%s() received breakpoint event, tid = %" PRIu64, + __FUNCTION__, tid); message = ProcessMessage::Break(tid); } break; @@ -1146,22 +1145,19 @@ ProcessMessage ProcessMonitor::MonitorSignal(ProcessMonitor *monitor, // // Similarly, ACK signals generated by this monitor. if (info->si_code == SI_USER) { - if (log) - log->Printf( - "ProcessMonitor::%s() received signal %s with code %s, pid = %d", - __FUNCTION__, - monitor->m_process->GetUnixSignals()->GetSignalAsCString(signo), - "SI_USER", info->si_pid); + LLDB_LOGF(log, + "ProcessMonitor::%s() received signal %s with code %s, pid = %d", + __FUNCTION__, + monitor->m_process->GetUnixSignals()->GetSignalAsCString(signo), + "SI_USER", info->si_pid); if (info->si_pid == getpid()) return ProcessMessage::SignalDelivered(tid, signo); else return ProcessMessage::Signal(tid, signo); } - if (log) - log->Printf( - "ProcessMonitor::%s() received signal %s", __FUNCTION__, - monitor->m_process->GetUnixSignals()->GetSignalAsCString(signo)); + LLDB_LOGF(log, "ProcessMonitor::%s() received signal %s", __FUNCTION__, + monitor->m_process->GetUnixSignals()->GetSignalAsCString(signo)); switch (signo) { case SIGSEGV: @@ -1313,14 +1309,14 @@ bool ProcessMonitor::Resume(lldb::tid_t unused, uint32_t signo) { m_process->GetUnixSignals()->GetSignalAsCString(signo); if (signame == nullptr) signame = "<none>"; - log->Printf("ProcessMonitor::%s() resuming pid %" PRIu64 " with signal %s", - __FUNCTION__, GetPID(), signame); + LLDB_LOGF(log, + "ProcessMonitor::%s() resuming pid %" PRIu64 " with signal %s", + __FUNCTION__, GetPID(), signame); } ResumeOperation op(signo, result); DoOperation(&op); - if (log) - log->Printf("ProcessMonitor::%s() resuming result = %s", __FUNCTION__, - result ? "true" : "false"); + LLDB_LOGF(log, "ProcessMonitor::%s() resuming result = %s", __FUNCTION__, + result ? "true" : "false"); return result; } |