[Lldb-commits] [lldb] r180047 - Fix data race in Address class by wrapping m_offset in std::atomic

Daniel Malea daniel.malea at intel.com
Mon Apr 22 13:59:13 PDT 2013


Author: dmalea
Date: Mon Apr 22 15:59:13 2013
New Revision: 180047

URL: http://llvm.org/viewvc/llvm-project?rev=180047&view=rev
Log:
Fix data race in Address class by wrapping m_offset in std::atomic


Modified:
    lldb/trunk/include/lldb/Core/Address.h
    lldb/trunk/source/Core/Address.cpp

Modified: lldb/trunk/include/lldb/Core/Address.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=180047&r1=180046&r2=180047&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Address.h (original)
+++ lldb/trunk/include/lldb/Core/Address.h Mon Apr 22 15:59:13 2013
@@ -12,6 +12,7 @@
 
 // C Includes
 // C++ Includes
+#include <atomic>
 // Other libraries and framework includes
 // Project includes
 #include "lldb/lldb-private.h"
@@ -115,7 +116,7 @@ public:
     //------------------------------------------------------------------
     Address (const Address& rhs) :
         m_section_wp (rhs.m_section_wp),
-        m_offset (rhs.m_offset)
+        m_offset(rhs.m_offset.load())
     {
     }
 
@@ -538,7 +539,7 @@ protected:
     // Member variables.
     //------------------------------------------------------------------
     lldb::SectionWP m_section_wp;   ///< The section for the address, can be NULL.
-    lldb::addr_t m_offset;      ///< Offset into section if \a m_section_wp is valid...
+    std::atomic<lldb::addr_t> m_offset;      ///< Offset into section if \a m_section_wp is valid...
 };
 
 

Modified: lldb/trunk/source/Core/Address.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=180047&r1=180046&r2=180047&view=diff
==============================================================================
--- lldb/trunk/source/Core/Address.cpp (original)
+++ lldb/trunk/source/Core/Address.cpp Mon Apr 22 15:59:13 2013
@@ -231,7 +231,7 @@ Address::operator= (const Address& rhs)
     if (this != &rhs)
     {
         m_section_wp = rhs.m_section_wp;
-        m_offset = rhs.m_offset;
+        m_offset = rhs.m_offset.load();
     }
     return *this;
 }
@@ -391,7 +391,7 @@ Address::Dump (Stream *s, ExecutionConte
         if (section_sp)
         {
             section_sp->DumpName(s);
-            s->Printf (" + %" PRIu64, m_offset);
+            s->Printf (" + %" PRIu64, m_offset.load());
         }
         else
         {





More information about the lldb-commits mailing list