Skip to content

Commit 0ab109d

Browse files
committed
[lldb][NFC] Modernize logging UserExpression
1 parent 8673def commit 0ab109d

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed

lldb/source/Expression/UserExpression.cpp

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
168168

169169
Target *target = exe_ctx.GetTargetPtr();
170170
if (!target) {
171-
LLDB_LOGF(log, "== [UserExpression::Evaluate] Passed a NULL target, can't "
172-
"run expressions.");
171+
LLDB_LOG(log, "== [UserExpression::Evaluate] Passed a NULL target, can't "
172+
"run expressions.");
173173
error.SetErrorString("expression passed a null target");
174174
return lldb::eExpressionSetupError;
175175
}
@@ -178,9 +178,8 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
178178

179179
if (process == nullptr || process->GetState() != lldb::eStateStopped) {
180180
if (execution_policy == eExecutionPolicyAlways) {
181-
LLDB_LOGF(log,
182-
"== [UserExpression::Evaluate] Expression may not run, but "
183-
"is not constant ==");
181+
LLDB_LOG(log, "== [UserExpression::Evaluate] Expression may not run, but "
182+
"is not constant ==");
184183

185184
error.SetErrorString("expression needed to run but couldn't");
186185

@@ -225,15 +224,13 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
225224
desired_type, options, ctx_obj,
226225
error));
227226
if (error.Fail()) {
228-
if (log)
229-
LLDB_LOGF(log, "== [UserExpression::Evaluate] Getting expression: %s ==",
230-
error.AsCString());
227+
LLDB_LOG(log, "== [UserExpression::Evaluate] Getting expression: {0} ==",
228+
error.AsCString());
231229
return lldb::eExpressionSetupError;
232230
}
233231

234-
if (log)
235-
LLDB_LOGF(log, "== [UserExpression::Evaluate] Parsing expression %s ==",
236-
expr.str().c_str());
232+
LLDB_LOG(log, "== [UserExpression::Evaluate] Parsing expression {0} ==",
233+
expr.str());
237234

238235
const bool keep_expression_in_memory = true;
239236
const bool generate_debug_info = options.GetGenerateDebugInfo();
@@ -306,10 +303,8 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
306303

307304
if (execution_policy == eExecutionPolicyNever &&
308305
!user_expression_sp->CanInterpret()) {
309-
if (log)
310-
LLDB_LOGF(log,
311-
"== [UserExpression::Evaluate] Expression may not run, but "
312-
"is not constant ==");
306+
LLDB_LOG(log, "== [UserExpression::Evaluate] Expression may not run, but "
307+
"is not constant ==");
313308

314309
if (!diagnostic_manager.Diagnostics().size())
315310
error.SetExpressionError(lldb::eExpressionSetupError,
@@ -329,17 +324,15 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
329324

330325
diagnostic_manager.Clear();
331326

332-
if (log)
333-
LLDB_LOGF(log, "== [UserExpression::Evaluate] Executing expression ==");
327+
LLDB_LOG(log, "== [UserExpression::Evaluate] Executing expression ==");
334328

335329
execution_results =
336330
user_expression_sp->Execute(diagnostic_manager, exe_ctx, options,
337331
user_expression_sp, expr_result);
338332

339333
if (execution_results != lldb::eExpressionCompleted) {
340-
if (log)
341-
LLDB_LOGF(log, "== [UserExpression::Evaluate] Execution completed "
342-
"abnormally ==");
334+
LLDB_LOG(log, "== [UserExpression::Evaluate] Execution completed "
335+
"abnormally ==");
343336

344337
if (!diagnostic_manager.Diagnostics().size())
345338
error.SetExpressionError(
@@ -351,15 +344,13 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
351344
if (expr_result) {
352345
result_valobj_sp = expr_result->GetValueObject();
353346

354-
if (log)
355-
LLDB_LOGF(log,
356-
"== [UserExpression::Evaluate] Execution completed "
357-
"normally with result %s ==",
358-
result_valobj_sp->GetValueAsCString());
347+
LLDB_LOG(log,
348+
"== [UserExpression::Evaluate] Execution completed "
349+
"normally with result %s ==",
350+
result_valobj_sp->GetValueAsCString());
359351
} else {
360-
if (log)
361-
LLDB_LOGF(log, "== [UserExpression::Evaluate] Execution completed "
362-
"normally with no result ==");
352+
LLDB_LOG(log, "== [UserExpression::Evaluate] Execution completed "
353+
"normally with no result ==");
363354

364355
error.SetError(UserExpression::kNoResult, lldb::eErrorTypeGeneric);
365356
}

0 commit comments

Comments
 (0)