[Lldb-commits] [lldb] r361440 - Actaully lock accesses to OptionValueFileSpecList objects

Frederic Riss via lldb-commits lldb-commits at lists.llvm.org
Wed May 22 14:58:52 PDT 2019


Author: friss
Date: Wed May 22 14:58:52 2019
New Revision: 361440

URL: http://llvm.org/viewvc/llvm-project?rev=361440&view=rev
Log:
Actaully lock accesses to OptionValueFileSpecList objects

The patch in r359029 missed a few accessors and mutators. This patch
also changes the lock to a recursive one as OptionValueFileSpecList::Clear()
can be invoked from some of the other methods.

Modified:
    lldb/trunk/include/lldb/Interpreter/OptionValueFileSpecList.h
    lldb/trunk/source/Interpreter/OptionValueFileSpecLIst.cpp

Modified: lldb/trunk/include/lldb/Interpreter/OptionValueFileSpecList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionValueFileSpecList.h?rev=361440&r1=361439&r2=361440&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionValueFileSpecList.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionValueFileSpecList.h Wed May 22 14:58:52 2019
@@ -40,6 +40,7 @@ public:
                      VarSetOperationType = eVarSetOperationAssign) = delete;
 
   bool Clear() override {
+    std::lock_guard<std::recursive_mutex> lock(m_mutex);
     m_current_value.Clear();
     m_value_was_set = false;
     return true;
@@ -52,22 +53,22 @@ public:
   // Subclass specific functions
 
   FileSpecList GetCurrentValue() const {
-    std::lock_guard<std::mutex> lock(m_mutex);
+    std::lock_guard<std::recursive_mutex> lock(m_mutex);
     return m_current_value;
   }
 
   void SetCurrentValue(const FileSpecList &value) {
-    std::lock_guard<std::mutex> lock(m_mutex);
+    std::lock_guard<std::recursive_mutex> lock(m_mutex);
     m_current_value = value;
   }
 
   void AppendCurrentValue(const FileSpec &value) {
-    std::lock_guard<std::mutex> lock(m_mutex);
+    std::lock_guard<std::recursive_mutex> lock(m_mutex);
     m_current_value.Append(value);
   }
 
 protected:
-  mutable std::mutex m_mutex;
+  mutable std::recursive_mutex m_mutex;
   FileSpecList m_current_value;
 };
 

Modified: lldb/trunk/source/Interpreter/OptionValueFileSpecLIst.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueFileSpecLIst.cpp?rev=361440&r1=361439&r2=361440&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueFileSpecLIst.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueFileSpecLIst.cpp Wed May 22 14:58:52 2019
@@ -17,6 +17,7 @@ using namespace lldb_private;
 
 void OptionValueFileSpecList::DumpValue(const ExecutionContext *exe_ctx,
                                         Stream &strm, uint32_t dump_mask) {
+  std::lock_guard<std::recursive_mutex> lock(m_mutex);
   if (dump_mask & eDumpOptionType)
     strm.Printf("(%s)", GetTypeAsCString());
   if (dump_mask & eDumpOptionValue) {
@@ -43,6 +44,7 @@ void OptionValueFileSpecList::DumpValue(
 
 Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value,
                                                    VarSetOperationType op) {
+  std::lock_guard<std::recursive_mutex> lock(m_mutex);
   Status error;
   Args args(value.str());
   const size_t argc = args.GetArgumentCount();
@@ -163,6 +165,6 @@ Status OptionValueFileSpecList::SetValue
 }
 
 lldb::OptionValueSP OptionValueFileSpecList::DeepCopy() const {
-  std::lock_guard<std::mutex> lock(m_mutex);
+  std::lock_guard<std::recursive_mutex> lock(m_mutex);
   return OptionValueSP(new OptionValueFileSpecList(m_current_value));
 }




More information about the lldb-commits mailing list