[Lldb-commits] [lldb] 0ab109d - [lldb][NFC] Modernize logging UserExpression

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 4 09:05:12 PST 2020


Author: Raphael Isemann
Date: 2020-03-04T09:04:54-08:00
New Revision: 0ab109d43d9d8389fe686ee8df4a82634f246b55

URL: https://github.com/llvm/llvm-project/commit/0ab109d43d9d8389fe686ee8df4a82634f246b55
DIFF: https://github.com/llvm/llvm-project/commit/0ab109d43d9d8389fe686ee8df4a82634f246b55.diff

LOG: [lldb][NFC] Modernize logging UserExpression

Added: 
    

Modified: 
    lldb/source/Expression/UserExpression.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Expression/UserExpression.cpp b/lldb/source/Expression/UserExpression.cpp
index 3bfb5f27e6c6..0243cc0c3750 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -168,8 +168,8 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
 
   Target *target = exe_ctx.GetTargetPtr();
   if (!target) {
-    LLDB_LOGF(log, "== [UserExpression::Evaluate] Passed a NULL target, can't "
-                   "run expressions.");
+    LLDB_LOG(log, "== [UserExpression::Evaluate] Passed a NULL target, can't "
+                  "run expressions.");
     error.SetErrorString("expression passed a null target");
     return lldb::eExpressionSetupError;
   }
@@ -178,9 +178,8 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
 
   if (process == nullptr || process->GetState() != lldb::eStateStopped) {
     if (execution_policy == eExecutionPolicyAlways) {
-      LLDB_LOGF(log,
-                "== [UserExpression::Evaluate] Expression may not run, but "
-                "is not constant ==");
+      LLDB_LOG(log, "== [UserExpression::Evaluate] Expression may not run, but "
+                    "is not constant ==");
 
       error.SetErrorString("expression needed to run but couldn't");
 
@@ -225,15 +224,13 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
                                            desired_type, options, ctx_obj,
                                            error));
   if (error.Fail()) {
-    if (log)
-      LLDB_LOGF(log, "== [UserExpression::Evaluate] Getting expression: %s ==",
-                error.AsCString());
+    LLDB_LOG(log, "== [UserExpression::Evaluate] Getting expression: {0} ==",
+             error.AsCString());
     return lldb::eExpressionSetupError;
   }
 
-  if (log)
-    LLDB_LOGF(log, "== [UserExpression::Evaluate] Parsing expression %s ==",
-              expr.str().c_str());
+  LLDB_LOG(log, "== [UserExpression::Evaluate] Parsing expression {0} ==",
+           expr.str());
 
   const bool keep_expression_in_memory = true;
   const bool generate_debug_info = options.GetGenerateDebugInfo();
@@ -306,10 +303,8 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
 
     if (execution_policy == eExecutionPolicyNever &&
         !user_expression_sp->CanInterpret()) {
-      if (log)
-        LLDB_LOGF(log,
-                  "== [UserExpression::Evaluate] Expression may not run, but "
-                  "is not constant ==");
+      LLDB_LOG(log, "== [UserExpression::Evaluate] Expression may not run, but "
+                    "is not constant ==");
 
       if (!diagnostic_manager.Diagnostics().size())
         error.SetExpressionError(lldb::eExpressionSetupError,
@@ -329,17 +324,15 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
 
       diagnostic_manager.Clear();
 
-      if (log)
-        LLDB_LOGF(log, "== [UserExpression::Evaluate] Executing expression ==");
+      LLDB_LOG(log, "== [UserExpression::Evaluate] Executing expression ==");
 
       execution_results =
           user_expression_sp->Execute(diagnostic_manager, exe_ctx, options,
                                       user_expression_sp, expr_result);
 
       if (execution_results != lldb::eExpressionCompleted) {
-        if (log)
-          LLDB_LOGF(log, "== [UserExpression::Evaluate] Execution completed "
-                         "abnormally ==");
+        LLDB_LOG(log, "== [UserExpression::Evaluate] Execution completed "
+                      "abnormally ==");
 
         if (!diagnostic_manager.Diagnostics().size())
           error.SetExpressionError(
@@ -351,15 +344,13 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
         if (expr_result) {
           result_valobj_sp = expr_result->GetValueObject();
 
-          if (log)
-            LLDB_LOGF(log,
-                      "== [UserExpression::Evaluate] Execution completed "
-                      "normally with result %s ==",
-                      result_valobj_sp->GetValueAsCString());
+          LLDB_LOG(log,
+                   "== [UserExpression::Evaluate] Execution completed "
+                   "normally with result %s ==",
+                   result_valobj_sp->GetValueAsCString());
         } else {
-          if (log)
-            LLDB_LOGF(log, "== [UserExpression::Evaluate] Execution completed "
-                           "normally with no result ==");
+          LLDB_LOG(log, "== [UserExpression::Evaluate] Execution completed "
+                        "normally with no result ==");
 
           error.SetError(UserExpression::kNoResult, lldb::eErrorTypeGeneric);
         }


        


More information about the lldb-commits mailing list