[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
This commit is contained in:
Jonas Devlieghere
2019-07-24 17:56:10 +00:00
parent 2bf871be4c
commit 63e5fb76ec
190 changed files with 5362 additions and 5932 deletions

View File

@@ -148,7 +148,7 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
s.Address(
m_thread.GetRegisterContext()->GetPC(),
m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
log->Printf("ThreadPlanStepInRange reached %s.", s.GetData());
LLDB_LOGF(log, "ThreadPlanStepInRange reached %s.", s.GetData());
}
if (IsPlanComplete())
@@ -197,13 +197,14 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
CheckShouldStopHereAndQueueStepOut(frame_order, m_status);
if (log) {
if (m_sub_plan_sp)
log->Printf("ShouldStopHere found plan to step out of this frame.");
LLDB_LOGF(log,
"ShouldStopHere found plan to step out of this frame.");
else
log->Printf("ShouldStopHere no plan to step out of this frame.");
LLDB_LOGF(log, "ShouldStopHere no plan to step out of this frame.");
}
} else if (log) {
log->Printf(
"Thought I stepped out, but in fact arrived at a trampoline.");
LLDB_LOGF(
log, "Thought I stepped out, but in fact arrived at a trampoline.");
}
} else if (frame_order == eFrameCompareEqual && InSymbol()) {
// If we are not in a place we should step through, we're done. One
@@ -237,9 +238,10 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
if (log) {
if (m_sub_plan_sp)
log->Printf("Found a step through plan: %s", m_sub_plan_sp->GetName());
LLDB_LOGF(log, "Found a step through plan: %s",
m_sub_plan_sp->GetName());
else
log->Printf("No step through plan found.");
LLDB_LOGF(log, "No step through plan found.");
}
// If not, give the "should_stop" callback a chance to push a plan to get
@@ -289,8 +291,7 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
if (bytes_to_skip != 0) {
func_start_address.Slide(bytes_to_skip);
log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP);
if (log)
log->Printf("Pushing past prologue ");
LLDB_LOGF(log, "Pushing past prologue ");
m_sub_plan_sp = m_thread.QueueThreadPlanForRunToAddress(
false, func_start_address, true, m_status);
@@ -373,11 +374,12 @@ bool ThreadPlanStepInRange::FrameMatchesAvoidCriteria() {
if (log) {
std::string match;
regex_match.GetMatchAtIndex(frame_function_name, 0, match);
log->Printf("Stepping out of function \"%s\" because it matches "
"the avoid regexp \"%s\" - match substring: \"%s\".",
frame_function_name,
avoid_regexp_to_use->GetText().str().c_str(),
match.c_str());
LLDB_LOGF(log,
"Stepping out of function \"%s\" because it matches "
"the avoid regexp \"%s\" - match substring: \"%s\".",
frame_function_name,
avoid_regexp_to_use->GetText().str().c_str(),
match.c_str());
}
}
return return_value;
@@ -424,10 +426,11 @@ bool ThreadPlanStepInRange::DefaultShouldStopHereCallback(
should_stop_here = false;
}
if (log && !should_stop_here)
log->Printf("Stepping out of frame %s which did not match step into "
"target %s.",
sc.GetFunctionName().AsCString(),
step_in_range_plan->m_step_into_target.AsCString());
LLDB_LOGF(log,
"Stepping out of frame %s which did not match step into "
"target %s.",
sc.GetFunctionName().AsCString(),
step_in_range_plan->m_step_into_target.AsCString());
}
}
@@ -496,10 +499,10 @@ bool ThreadPlanStepInRange::DoWillResume(lldb::StateType resume_state,
bool step_without_resume = m_thread.DecrementCurrentInlinedDepth();
if (step_without_resume) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log)
log->Printf("ThreadPlanStepInRange::DoWillResume: returning false, "
"inline_depth: %d",
m_thread.GetCurrentInlinedDepth());
LLDB_LOGF(log,
"ThreadPlanStepInRange::DoWillResume: returning false, "
"inline_depth: %d",
m_thread.GetCurrentInlinedDepth());
SetStopInfo(StopInfo::CreateStopReasonToTrace(m_thread));
// FIXME: Maybe it would be better to create a InlineStep stop reason, but