[Lldb-commits] [lldb] r362985 - [Target] Use llvm::scope_exit to restore m_suppress_stop_hooks value.

Tatyana Krasnukha via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 10 14:13:37 PDT 2019


Author: tkrasnukha
Date: Mon Jun 10 14:13:37 2019
New Revision: 362985

URL: http://llvm.org/viewvc/llvm-project?rev=362985&view=rev
Log:
[Target] Use llvm::scope_exit to restore m_suppress_stop_hooks value.

Modified:
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=362985&r1=362984&r2=362985&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Jun 10 14:13:37 2019
@@ -57,6 +57,8 @@
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Timer.h"
 
+#include "llvm/ADT/ScopeExit.h"
+
 #include <memory>
 #include <mutex>
 
@@ -2380,10 +2382,11 @@ ExpressionResults Target::EvaluateExpres
   if (expr.empty())
     return execution_results;
 
-  // We shouldn't run stop hooks in expressions. Be sure to reset this if you
-  // return anywhere within this function.
+  // We shouldn't run stop hooks in expressions.
   bool old_suppress_value = m_suppress_stop_hooks;
   m_suppress_stop_hooks = true;
+  auto on_exit = llvm::make_scope_exit([this, old_suppress_value]() {
+      m_suppress_stop_hooks = old_suppress_value; });
 
   ExecutionContext exe_ctx;
 
@@ -2417,8 +2420,6 @@ ExpressionResults Target::EvaluateExpres
                                  ctx_obj);
   }
 
-  m_suppress_stop_hooks = old_suppress_value;
-
   return execution_results;
 }
 




More information about the lldb-commits mailing list