[Lldb-commits] [lldb] r152679 - in /lldb/trunk: include/lldb/Core/Module.h include/lldb/Symbol/ObjectFile.h include/lldb/Symbol/SymbolVendor.h source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h source/Symbol/SymbolVendor.cpp

Greg Clayton gclayton at apple.com
Tue Mar 13 16:14:30 PDT 2012


Author: gclayton
Date: Tue Mar 13 18:14:29 2012
New Revision: 152679

URL: http://llvm.org/viewvc/llvm-project?rev=152679&view=rev
Log:
<rdar://problem/11034170> 

Simplify the locking strategy for Module and its owned objects to always use the Module's mutex to avoid A/B deadlocks. We had a case where a symbol vendor was locking itself and then calling a function that would try to get it's Module's mutex and at the same time another thread had the Module mutex that was trying to get the SymbolVendor mutex. Now any classes that inherit from ModuleChild should use the module lock using code like:

void
ModuleChildSubclass::Function
{
	ModuleSP module_sp(GetModule());
	if (module_sp)
	{
    	lldb_private::Mutex::Locker locker(module_sp->GetMutex());
		... do work here...
	}
}

This will help avoid deadlocks by using as few locks as possible for a module and all its child objects and also enforce detecting if a module has gone away (the ModuleSP will be returned empty if the weak_ptr does refer to a valid object anymore).


Modified:
    lldb/trunk/include/lldb/Core/Module.h
    lldb/trunk/include/lldb/Symbol/ObjectFile.h
    lldb/trunk/include/lldb/Symbol/SymbolVendor.h
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
    lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
    lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
    lldb/trunk/source/Symbol/SymbolVendor.cpp

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=152679&r1=152678&r2=152679&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Tue Mar 13 18:14:29 2012
@@ -984,6 +984,16 @@
     bool
     SetModified (bool b);
 
+    //------------------------------------------------------------------
+    // SymbolVendor, SymbolFile and ObjectFile member objects should
+    // lock the module mutex to avoid deadlocks.
+    //------------------------------------------------------------------
+    Mutex &
+    GetMutex () const
+    {
+        return m_mutex;
+    }
+
 protected:
     //------------------------------------------------------------------
     // Member Variables

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=152679&r1=152678&r2=152679&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Tue Mar 13 18:14:29 2012
@@ -562,6 +562,7 @@
     {
         return m_memory_addr != LLDB_INVALID_ADDRESS;
     }
+    
 protected:
     //------------------------------------------------------------------
     // Member variables.

Modified: lldb/trunk/include/lldb/Symbol/SymbolVendor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolVendor.h?rev=152679&r1=152678&r2=152679&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolVendor.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolVendor.h Tue Mar 13 18:14:29 2012
@@ -15,7 +15,6 @@
 #include "lldb/lldb-private.h"
 #include "lldb/Core/ModuleChild.h"
 #include "lldb/Core/PluginInterface.h"
-#include "lldb/Host/Mutex.h"
 #include "lldb/Symbol/ClangNamespaceDecl.h"
 #include "lldb/Symbol/TypeList.h"
 
@@ -185,7 +184,6 @@
     typedef CompileUnits::iterator CompileUnitIter;
     typedef CompileUnits::const_iterator CompileUnitConstIter;
 
-    mutable Mutex m_mutex;
     TypeList m_type_list; // Uniqued types for all parsers owned by this module
     CompileUnits m_compile_units; // The current compile units
     lldb::ObjectFileSP m_objfile_sp;    // Keep a reference to the object file in case it isn't the same as the module object file (debug symbols in a separate file)

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=152679&r1=152678&r2=152679&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Mar 13 18:14:29 2012
@@ -464,7 +464,6 @@
 
 ObjectFileMachO::ObjectFileMachO(const lldb::ModuleSP &module_sp, DataBufferSP& data_sp, const FileSpec* file, addr_t offset, addr_t length) :
     ObjectFile(module_sp, file, offset, length, data_sp),
-    m_mutex (Mutex::eMutexTypeRecursive),
     m_sections_ap(),
     m_symtab_ap(),
     m_mach_segments(),
@@ -482,7 +481,6 @@
                                   const lldb::ProcessSP &process_sp,
                                   lldb::addr_t header_addr) :
     ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
-    m_mutex (Mutex::eMutexTypeRecursive),
     m_sections_ap(),
     m_symtab_ap(),
     m_mach_segments(),
@@ -503,75 +501,79 @@
 bool
 ObjectFileMachO::ParseHeader ()
 {
-    lldb_private::Mutex::Locker locker(m_mutex);
-    bool can_parse = false;
-    uint32_t offset = 0;
-    m_data.SetByteOrder (lldb::endian::InlHostByteOrder());
-    // Leave magic in the original byte order
-    m_header.magic = m_data.GetU32(&offset);
-    switch (m_header.magic)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-    case HeaderMagic32:
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        bool can_parse = false;
+        uint32_t offset = 0;
         m_data.SetByteOrder (lldb::endian::InlHostByteOrder());
-        m_data.SetAddressByteSize(4);
-        can_parse = true;
-        break;
+        // Leave magic in the original byte order
+        m_header.magic = m_data.GetU32(&offset);
+        switch (m_header.magic)
+        {
+        case HeaderMagic32:
+            m_data.SetByteOrder (lldb::endian::InlHostByteOrder());
+            m_data.SetAddressByteSize(4);
+            can_parse = true;
+            break;
 
-    case HeaderMagic64:
-        m_data.SetByteOrder (lldb::endian::InlHostByteOrder());
-        m_data.SetAddressByteSize(8);
-        can_parse = true;
-        break;
-
-    case HeaderMagic32Swapped:
-        m_data.SetByteOrder(lldb::endian::InlHostByteOrder() == eByteOrderBig ? eByteOrderLittle : eByteOrderBig);
-        m_data.SetAddressByteSize(4);
-        can_parse = true;
-        break;
-
-    case HeaderMagic64Swapped:
-        m_data.SetByteOrder(lldb::endian::InlHostByteOrder() == eByteOrderBig ? eByteOrderLittle : eByteOrderBig);
-        m_data.SetAddressByteSize(8);
-        can_parse = true;
-        break;
+        case HeaderMagic64:
+            m_data.SetByteOrder (lldb::endian::InlHostByteOrder());
+            m_data.SetAddressByteSize(8);
+            can_parse = true;
+            break;
 
-    default:
-        break;
-    }
+        case HeaderMagic32Swapped:
+            m_data.SetByteOrder(lldb::endian::InlHostByteOrder() == eByteOrderBig ? eByteOrderLittle : eByteOrderBig);
+            m_data.SetAddressByteSize(4);
+            can_parse = true;
+            break;
 
-    if (can_parse)
-    {
-        m_data.GetU32(&offset, &m_header.cputype, 6);
+        case HeaderMagic64Swapped:
+            m_data.SetByteOrder(lldb::endian::InlHostByteOrder() == eByteOrderBig ? eByteOrderLittle : eByteOrderBig);
+            m_data.SetAddressByteSize(8);
+            can_parse = true;
+            break;
 
-        ArchSpec mach_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
-        
-        if (SetModulesArchitecture (mach_arch))
+        default:
+            break;
+        }
+
+        if (can_parse)
         {
-            const size_t header_and_lc_size = m_header.sizeofcmds + MachHeaderSizeFromMagic(m_header.magic);
-            if (m_data.GetByteSize() < header_and_lc_size)
+            m_data.GetU32(&offset, &m_header.cputype, 6);
+
+            ArchSpec mach_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
+            
+            if (SetModulesArchitecture (mach_arch))
             {
-                DataBufferSP data_sp;
-                ProcessSP process_sp (m_process_wp.lock());
-                if (process_sp)
-                {
-                    data_sp = ReadMemory (process_sp, m_offset, header_and_lc_size);
-                }
-                else
+                const size_t header_and_lc_size = m_header.sizeofcmds + MachHeaderSizeFromMagic(m_header.magic);
+                if (m_data.GetByteSize() < header_and_lc_size)
                 {
-                    // Read in all only the load command data from the file on disk
-                    data_sp = m_file.ReadFileContents(m_offset, header_and_lc_size);
-                    if (data_sp->GetByteSize() != header_and_lc_size)
-                        return false;
+                    DataBufferSP data_sp;
+                    ProcessSP process_sp (m_process_wp.lock());
+                    if (process_sp)
+                    {
+                        data_sp = ReadMemory (process_sp, m_offset, header_and_lc_size);
+                    }
+                    else
+                    {
+                        // Read in all only the load command data from the file on disk
+                        data_sp = m_file.ReadFileContents(m_offset, header_and_lc_size);
+                        if (data_sp->GetByteSize() != header_and_lc_size)
+                            return false;
+                    }
+                    if (data_sp)
+                        m_data.SetData (data_sp);
                 }
-                if (data_sp)
-                    m_data.SetData (data_sp);
             }
+            return true;
+        }
+        else
+        {
+            memset(&m_header, 0, sizeof(struct mach_header));
         }
-        return true;
-    }
-    else
-    {
-        memset(&m_header, 0, sizeof(struct mach_header));
     }
     return false;
 }
@@ -580,7 +582,6 @@
 ByteOrder
 ObjectFileMachO::GetByteOrder () const
 {
-    lldb_private::Mutex::Locker locker(m_mutex);
     return m_data.GetByteOrder ();
 }
 
@@ -593,7 +594,6 @@
 size_t
 ObjectFileMachO::GetAddressByteSize () const
 {
-    lldb_private::Mutex::Locker locker(m_mutex);
     return m_data.GetAddressByteSize ();
 }
 
@@ -710,13 +710,17 @@
 Symtab *
 ObjectFileMachO::GetSymtab()
 {
-    lldb_private::Mutex::Locker symfile_locker(m_mutex);
-    if (m_symtab_ap.get() == NULL)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        m_symtab_ap.reset(new Symtab(this));
-        Mutex::Locker symtab_locker (m_symtab_ap->GetMutex());
-        ParseSymtab (true);
-        m_symtab_ap->Finalize ();
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_symtab_ap.get() == NULL)
+        {
+            m_symtab_ap.reset(new Symtab(this));
+            Mutex::Locker symtab_locker (m_symtab_ap->GetMutex());
+            ParseSymtab (true);
+            m_symtab_ap->Finalize ();
+        }
     }
     return m_symtab_ap.get();
 }
@@ -725,11 +729,15 @@
 SectionList *
 ObjectFileMachO::GetSectionList()
 {
-    lldb_private::Mutex::Locker locker(m_mutex);
-    if (m_sections_ap.get() == NULL)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        m_sections_ap.reset(new SectionList());
-        ParseSections();
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sections_ap.get() == NULL)
+        {
+            m_sections_ap.reset(new SectionList());
+            ParseSections();
+        }
     }
     return m_sections_ap.get();
 }
@@ -2172,50 +2180,58 @@
 void
 ObjectFileMachO::Dump (Stream *s)
 {
-    lldb_private::Mutex::Locker locker(m_mutex);
-    s->Printf("%p: ", this);
-    s->Indent();
-    if (m_header.magic == HeaderMagic64 || m_header.magic == HeaderMagic64Swapped)
-        s->PutCString("ObjectFileMachO64");
-    else
-        s->PutCString("ObjectFileMachO32");
-
-    ArchSpec header_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        s->Printf("%p: ", this);
+        s->Indent();
+        if (m_header.magic == HeaderMagic64 || m_header.magic == HeaderMagic64Swapped)
+            s->PutCString("ObjectFileMachO64");
+        else
+            s->PutCString("ObjectFileMachO32");
 
-    *s << ", file = '" << m_file << "', arch = " << header_arch.GetArchitectureName() << "\n";
+        ArchSpec header_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
 
-    if (m_sections_ap.get())
-        m_sections_ap->Dump(s, NULL, true, UINT32_MAX);
+        *s << ", file = '" << m_file << "', arch = " << header_arch.GetArchitectureName() << "\n";
 
-    if (m_symtab_ap.get())
-        m_symtab_ap->Dump(s, NULL, eSortOrderNone);
+        if (m_sections_ap.get())
+            m_sections_ap->Dump(s, NULL, true, UINT32_MAX);
+
+        if (m_symtab_ap.get())
+            m_symtab_ap->Dump(s, NULL, eSortOrderNone);
+    }
 }
 
 
 bool
 ObjectFileMachO::GetUUID (lldb_private::UUID* uuid)
 {
-    lldb_private::Mutex::Locker locker(m_mutex);
-    struct uuid_command load_cmd;
-    uint32_t offset = MachHeaderSizeFromMagic(m_header.magic);
-    uint32_t i;
-    for (i=0; i<m_header.ncmds; ++i)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        const uint32_t cmd_offset = offset;
-        if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
-            break;
-
-        if (load_cmd.cmd == LoadCommandUUID)
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        struct uuid_command load_cmd;
+        uint32_t offset = MachHeaderSizeFromMagic(m_header.magic);
+        uint32_t i;
+        for (i=0; i<m_header.ncmds; ++i)
         {
-            const uint8_t *uuid_bytes = m_data.PeekData(offset, 16);
-            if (uuid_bytes)
+            const uint32_t cmd_offset = offset;
+            if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
+                break;
+
+            if (load_cmd.cmd == LoadCommandUUID)
             {
-                uuid->SetBytes (uuid_bytes);
-                return true;
+                const uint8_t *uuid_bytes = m_data.PeekData(offset, 16);
+                if (uuid_bytes)
+                {
+                    uuid->SetBytes (uuid_bytes);
+                    return true;
+                }
+                return false;
             }
-            return false;
+            offset = cmd_offset + load_cmd.cmdsize;
         }
-        offset = cmd_offset + load_cmd.cmdsize;
     }
     return false;
 }
@@ -2224,45 +2240,49 @@
 uint32_t
 ObjectFileMachO::GetDependentModules (FileSpecList& files)
 {
-    lldb_private::Mutex::Locker locker(m_mutex);
-    struct load_command load_cmd;
-    uint32_t offset = MachHeaderSizeFromMagic(m_header.magic);
     uint32_t count = 0;
-    const bool resolve_path = false; // Don't resolve the dependend file paths since they may not reside on this system
-    uint32_t i;
-    for (i=0; i<m_header.ncmds; ++i)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        const uint32_t cmd_offset = offset;
-        if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
-            break;
-
-        switch (load_cmd.cmd)
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        struct load_command load_cmd;
+        uint32_t offset = MachHeaderSizeFromMagic(m_header.magic);
+        const bool resolve_path = false; // Don't resolve the dependend file paths since they may not reside on this system
+        uint32_t i;
+        for (i=0; i<m_header.ncmds; ++i)
         {
-        case LoadCommandDylibLoad:
-        case LoadCommandDylibLoadWeak:
-        case LoadCommandDylibReexport:
-        case LoadCommandDynamicLinkerLoad:
-        case LoadCommandFixedVMShlibLoad:
-        case LoadCommandDylibLoadUpward:
-            {
-                uint32_t name_offset = cmd_offset + m_data.GetU32(&offset);
-                const char *path = m_data.PeekCStr(name_offset);
-                // Skip any path that starts with '@' since these are usually:
-                // @executable_path/.../file
-                // @rpath/.../file
-                if (path && path[0] != '@')
-                {
-                    FileSpec file_spec(path, resolve_path);
-                    if (files.AppendIfUnique(file_spec))
-                        count++;
+            const uint32_t cmd_offset = offset;
+            if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
+                break;
+
+            switch (load_cmd.cmd)
+            {
+            case LoadCommandDylibLoad:
+            case LoadCommandDylibLoadWeak:
+            case LoadCommandDylibReexport:
+            case LoadCommandDynamicLinkerLoad:
+            case LoadCommandFixedVMShlibLoad:
+            case LoadCommandDylibLoadUpward:
+                {
+                    uint32_t name_offset = cmd_offset + m_data.GetU32(&offset);
+                    const char *path = m_data.PeekCStr(name_offset);
+                    // Skip any path that starts with '@' since these are usually:
+                    // @executable_path/.../file
+                    // @rpath/.../file
+                    if (path && path[0] != '@')
+                    {
+                        FileSpec file_spec(path, resolve_path);
+                        if (files.AppendIfUnique(file_spec))
+                            count++;
+                    }
                 }
-            }
-            break;
+                break;
 
-        default:
-            break;
+            default:
+                break;
+            }
+            offset = cmd_offset + load_cmd.cmdsize;
         }
-        offset = cmd_offset + load_cmd.cmdsize;
     }
     return count;
 }
@@ -2294,116 +2314,120 @@
     //
     //
 
-    lldb_private::Mutex::Locker locker(m_mutex);
-    struct load_command load_cmd;
-    uint32_t offset = MachHeaderSizeFromMagic(m_header.magic);
-    uint32_t i;
-    lldb::addr_t start_address = LLDB_INVALID_ADDRESS;
-    bool done = false;
-    
-    for (i=0; i<m_header.ncmds; ++i)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        const uint32_t cmd_offset = offset;
-        if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
-            break;
-
-        switch (load_cmd.cmd)
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        struct load_command load_cmd;
+        uint32_t offset = MachHeaderSizeFromMagic(m_header.magic);
+        uint32_t i;
+        lldb::addr_t start_address = LLDB_INVALID_ADDRESS;
+        bool done = false;
+        
+        for (i=0; i<m_header.ncmds; ++i)
         {
-        case LoadCommandUnixThread:
-        case LoadCommandThread:
+            const uint32_t cmd_offset = offset;
+            if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
+                break;
+
+            switch (load_cmd.cmd)
             {
-                while (offset < cmd_offset + load_cmd.cmdsize)
+            case LoadCommandUnixThread:
+            case LoadCommandThread:
                 {
-                    uint32_t flavor = m_data.GetU32(&offset);
-                    uint32_t count = m_data.GetU32(&offset);
-                    if (count == 0)
+                    while (offset < cmd_offset + load_cmd.cmdsize)
                     {
-                        // We've gotten off somehow, log and exit;
-                        return m_entry_point_address;
-                    }
-                    
-                    switch (m_header.cputype)
-                    {
-                    case llvm::MachO::CPUTypeARM:
-                       if (flavor == 1) // ARM_THREAD_STATE from mach/arm/thread_status.h
-                       {
-                           offset += 60;  // This is the offset of pc in the GPR thread state data structure.
-                           start_address = m_data.GetU32(&offset);
-                           done = true;
-                        }
-                    break;
-                    case llvm::MachO::CPUTypeI386:
-                       if (flavor == 1) // x86_THREAD_STATE32 from mach/i386/thread_status.h
-                       {
-                           offset += 40;  // This is the offset of eip in the GPR thread state data structure.
-                           start_address = m_data.GetU32(&offset);
-                           done = true;
+                        uint32_t flavor = m_data.GetU32(&offset);
+                        uint32_t count = m_data.GetU32(&offset);
+                        if (count == 0)
+                        {
+                            // We've gotten off somehow, log and exit;
+                            return m_entry_point_address;
                         }
-                    break;
-                    case llvm::MachO::CPUTypeX86_64:
-                       if (flavor == 4) // x86_THREAD_STATE64 from mach/i386/thread_status.h
-                       {
-                           offset += 16 * 8;  // This is the offset of rip in the GPR thread state data structure.
-                           start_address = m_data.GetU64(&offset);
-                           done = true;
+                        
+                        switch (m_header.cputype)
+                        {
+                        case llvm::MachO::CPUTypeARM:
+                           if (flavor == 1) // ARM_THREAD_STATE from mach/arm/thread_status.h
+                           {
+                               offset += 60;  // This is the offset of pc in the GPR thread state data structure.
+                               start_address = m_data.GetU32(&offset);
+                               done = true;
+                            }
+                        break;
+                        case llvm::MachO::CPUTypeI386:
+                           if (flavor == 1) // x86_THREAD_STATE32 from mach/i386/thread_status.h
+                           {
+                               offset += 40;  // This is the offset of eip in the GPR thread state data structure.
+                               start_address = m_data.GetU32(&offset);
+                               done = true;
+                            }
+                        break;
+                        case llvm::MachO::CPUTypeX86_64:
+                           if (flavor == 4) // x86_THREAD_STATE64 from mach/i386/thread_status.h
+                           {
+                               offset += 16 * 8;  // This is the offset of rip in the GPR thread state data structure.
+                               start_address = m_data.GetU64(&offset);
+                               done = true;
+                            }
+                        break;
+                        default:
+                            return m_entry_point_address;
                         }
-                    break;
-                    default:
-                        return m_entry_point_address;
+                        // Haven't found the GPR flavor yet, skip over the data for this flavor:
+                        if (done)
+                            break;
+                        offset += count * 4;
                     }
-                    // Haven't found the GPR flavor yet, skip over the data for this flavor:
-                    if (done)
-                        break;
-                    offset += count * 4;
                 }
-            }
-            break;
-        case LoadCommandMain:
-            {
-                ConstString text_segment_name ("__TEXT");
-                uint64_t entryoffset = m_data.GetU64(&offset);
-                SectionSP text_segment_sp = GetSectionList()->FindSectionByName(text_segment_name);
-                if (text_segment_sp)
+                break;
+            case LoadCommandMain:
                 {
-                    done = true;
-                    start_address = text_segment_sp->GetFileAddress() + entryoffset;
+                    ConstString text_segment_name ("__TEXT");
+                    uint64_t entryoffset = m_data.GetU64(&offset);
+                    SectionSP text_segment_sp = GetSectionList()->FindSectionByName(text_segment_name);
+                    if (text_segment_sp)
+                    {
+                        done = true;
+                        start_address = text_segment_sp->GetFileAddress() + entryoffset;
+                    }
                 }
+
+            default:
+                break;
             }
+            if (done)
+                break;
 
-        default:
-            break;
+            // Go to the next load command:
+            offset = cmd_offset + load_cmd.cmdsize;
         }
-        if (done)
-            break;
-
-        // Go to the next load command:
-        offset = cmd_offset + load_cmd.cmdsize;
-    }
-    
-    if (start_address != LLDB_INVALID_ADDRESS)
-    {
-        // We got the start address from the load commands, so now resolve that address in the sections 
-        // of this ObjectFile:
-        if (!m_entry_point_address.ResolveAddressUsingFileSections (start_address, GetSectionList()))
+        
+        if (start_address != LLDB_INVALID_ADDRESS)
         {
-            m_entry_point_address.Clear();
+            // We got the start address from the load commands, so now resolve that address in the sections 
+            // of this ObjectFile:
+            if (!m_entry_point_address.ResolveAddressUsingFileSections (start_address, GetSectionList()))
+            {
+                m_entry_point_address.Clear();
+            }
         }
-    }
-    else
-    {
-        // We couldn't read the UnixThread load command - maybe it wasn't there.  As a fallback look for the
-        // "start" symbol in the main executable.
-        
-        ModuleSP module_sp (GetModule());
-        
-        if (module_sp)
+        else
         {
-            SymbolContextList contexts;
-            SymbolContext context;
-            if (module_sp->FindSymbolsWithNameAndType(ConstString ("start"), eSymbolTypeCode, contexts))
+            // We couldn't read the UnixThread load command - maybe it wasn't there.  As a fallback look for the
+            // "start" symbol in the main executable.
+            
+            ModuleSP module_sp (GetModule());
+            
+            if (module_sp)
             {
-                if (contexts.GetContextAtIndex(0, context))
-                    m_entry_point_address = context.symbol->GetAddress();
+                SymbolContextList contexts;
+                SymbolContext context;
+                if (module_sp->FindSymbolsWithNameAndType(ConstString ("start"), eSymbolTypeCode, contexts))
+                {
+                    if (contexts.GetContextAtIndex(0, context))
+                        m_entry_point_address = context.symbol->GetAddress();
+                }
             }
         }
     }
@@ -2432,26 +2456,30 @@
 uint32_t
 ObjectFileMachO::GetNumThreadContexts ()
 {
-    lldb_private::Mutex::Locker locker(m_mutex);
-    if (!m_thread_context_offsets_valid)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        m_thread_context_offsets_valid = true;
-        uint32_t offset = MachHeaderSizeFromMagic(m_header.magic);
-        FileRangeArray::Entry file_range;
-        thread_command thread_cmd;
-        for (uint32_t i=0; i<m_header.ncmds; ++i)
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (!m_thread_context_offsets_valid)
         {
-            const uint32_t cmd_offset = offset;
-            if (m_data.GetU32(&offset, &thread_cmd, 2) == NULL)
-                break;
-            
-            if (thread_cmd.cmd == LoadCommandThread)
+            m_thread_context_offsets_valid = true;
+            uint32_t offset = MachHeaderSizeFromMagic(m_header.magic);
+            FileRangeArray::Entry file_range;
+            thread_command thread_cmd;
+            for (uint32_t i=0; i<m_header.ncmds; ++i)
             {
-                file_range.SetRangeBase (offset);
-                file_range.SetByteSize (thread_cmd.cmdsize - 8);
-                m_thread_context_offsets.Append (file_range);
+                const uint32_t cmd_offset = offset;
+                if (m_data.GetU32(&offset, &thread_cmd, 2) == NULL)
+                    break;
+                
+                if (thread_cmd.cmd == LoadCommandThread)
+                {
+                    file_range.SetRangeBase (offset);
+                    file_range.SetByteSize (thread_cmd.cmdsize - 8);
+                    m_thread_context_offsets.Append (file_range);
+                }
+                offset = cmd_offset + thread_cmd.cmdsize;
             }
-            offset = cmd_offset + thread_cmd.cmdsize;
         }
     }
     return m_thread_context_offsets.GetSize();
@@ -2460,30 +2488,35 @@
 lldb::RegisterContextSP
 ObjectFileMachO::GetThreadContextAtIndex (uint32_t idx, lldb_private::Thread &thread)
 {
-    lldb_private::Mutex::Locker locker(m_mutex);
-    if (!m_thread_context_offsets_valid)
-        GetNumThreadContexts ();
-
     lldb::RegisterContextSP reg_ctx_sp;
-    const FileRangeArray::Entry *thread_context_file_range = m_thread_context_offsets.GetEntryAtIndex (idx);
-    
-    DataExtractor data (m_data, 
-                        thread_context_file_range->GetRangeBase(), 
-                        thread_context_file_range->GetByteSize());
 
-    switch (m_header.cputype)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        case llvm::MachO::CPUTypeARM:
-            reg_ctx_sp.reset (new RegisterContextDarwin_arm_Mach (thread, data));
-            break;
-            
-        case llvm::MachO::CPUTypeI386:
-            reg_ctx_sp.reset (new RegisterContextDarwin_i386_Mach (thread, data));
-            break;
-            
-        case llvm::MachO::CPUTypeX86_64:
-            reg_ctx_sp.reset (new RegisterContextDarwin_x86_64_Mach (thread, data));
-            break;
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (!m_thread_context_offsets_valid)
+            GetNumThreadContexts ();
+
+        const FileRangeArray::Entry *thread_context_file_range = m_thread_context_offsets.GetEntryAtIndex (idx);
+        
+        DataExtractor data (m_data, 
+                            thread_context_file_range->GetRangeBase(), 
+                            thread_context_file_range->GetByteSize());
+
+        switch (m_header.cputype)
+        {
+            case llvm::MachO::CPUTypeARM:
+                reg_ctx_sp.reset (new RegisterContextDarwin_arm_Mach (thread, data));
+                break;
+                
+            case llvm::MachO::CPUTypeI386:
+                reg_ctx_sp.reset (new RegisterContextDarwin_i386_Mach (thread, data));
+                break;
+                
+            case llvm::MachO::CPUTypeX86_64:
+                reg_ctx_sp.reset (new RegisterContextDarwin_x86_64_Mach (thread, data));
+                break;
+        }
     }
     return reg_ctx_sp;
 }
@@ -2588,50 +2621,54 @@
 uint32_t
 ObjectFileMachO::GetVersion (uint32_t *versions, uint32_t num_versions)
 {
-    lldb_private::Mutex::Locker locker(m_mutex);
-    struct dylib_command load_cmd;
-    uint32_t offset = MachHeaderSizeFromMagic(m_header.magic);
-    uint32_t version_cmd = 0;
-    uint64_t version = 0;
-    uint32_t i;
-    for (i=0; i<m_header.ncmds; ++i)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        const uint32_t cmd_offset = offset;
-        if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
-            break;
-        
-        if (load_cmd.cmd == LoadCommandDylibIdent)
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        struct dylib_command load_cmd;
+        uint32_t offset = MachHeaderSizeFromMagic(m_header.magic);
+        uint32_t version_cmd = 0;
+        uint64_t version = 0;
+        uint32_t i;
+        for (i=0; i<m_header.ncmds; ++i)
         {
-            if (version_cmd == 0)
+            const uint32_t cmd_offset = offset;
+            if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
+                break;
+            
+            if (load_cmd.cmd == LoadCommandDylibIdent)
             {
-                version_cmd = load_cmd.cmd;
-                if (m_data.GetU32(&offset, &load_cmd.dylib, 4) == NULL)
-                    break;
-                version = load_cmd.dylib.current_version;
+                if (version_cmd == 0)
+                {
+                    version_cmd = load_cmd.cmd;
+                    if (m_data.GetU32(&offset, &load_cmd.dylib, 4) == NULL)
+                        break;
+                    version = load_cmd.dylib.current_version;
+                }
+                break; // Break for now unless there is another more complete version 
+                       // number load command in the future.
             }
-            break; // Break for now unless there is another more complete version 
-                   // number load command in the future.
+            offset = cmd_offset + load_cmd.cmdsize;
         }
-        offset = cmd_offset + load_cmd.cmdsize;
-    }
-    
-    if (version_cmd == LoadCommandDylibIdent)
-    {
-        if (versions != NULL && num_versions > 0)
+        
+        if (version_cmd == LoadCommandDylibIdent)
         {
-            if (num_versions > 0)
-                versions[0] = (version & 0xFFFF0000ull) >> 16;
-            if (num_versions > 1)
-                versions[1] = (version & 0x0000FF00ull) >> 8;
-            if (num_versions > 2)
-                versions[2] = (version & 0x000000FFull);
-            // Fill in an remaining version numbers with invalid values
-            for (i=3; i<num_versions; ++i)
-                versions[i] = UINT32_MAX;
-        }
-        // The LC_ID_DYLIB load command has a version with 3 version numbers
-        // in it, so always return 3
-        return 3;
+            if (versions != NULL && num_versions > 0)
+            {
+                if (num_versions > 0)
+                    versions[0] = (version & 0xFFFF0000ull) >> 16;
+                if (num_versions > 1)
+                    versions[1] = (version & 0x0000FF00ull) >> 8;
+                if (num_versions > 2)
+                    versions[2] = (version & 0x000000FFull);
+                // Fill in an remaining version numbers with invalid values
+                for (i=3; i<num_versions; ++i)
+                    versions[i] = UINT32_MAX;
+            }
+            // The LC_ID_DYLIB load command has a version with 3 version numbers
+            // in it, so always return 3
+            return 3;
+        }
     }
     return false;
 }
@@ -2639,18 +2676,22 @@
 bool
 ObjectFileMachO::GetArchitecture (ArchSpec &arch)
 {
-    lldb_private::Mutex::Locker locker(m_mutex);
-    arch.SetArchitecture (eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
-    
-    // Files with type MH_PRELOAD are currently used in cases where the image
-    // debugs at the addresses in the file itself. Below we set the OS to 
-    // unknown to make sure we use the DynamicLoaderStatic()...
-    if (m_header.filetype == HeaderFileTypePreloadedExecutable)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        arch.GetTriple().setOS (llvm::Triple::UnknownOS);
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        arch.SetArchitecture (eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
+    
+        // Files with type MH_PRELOAD are currently used in cases where the image
+        // debugs at the addresses in the file itself. Below we set the OS to 
+        // unknown to make sure we use the DynamicLoaderStatic()...
+        if (m_header.filetype == HeaderFileTypePreloadedExecutable)
+        {
+            arch.GetTriple().setOS (llvm::Triple::UnknownOS);
+        }
+        return true;
     }
-
-    return true;
+    return false;
 }
 
 

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h?rev=152679&r1=152678&r2=152679&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h Tue Mar 13 18:14:29 2012
@@ -143,7 +143,6 @@
     GetVersion (uint32_t *versions, uint32_t num_versions);
 
 protected:
-    mutable lldb_private::Mutex m_mutex;
     llvm::MachO::mach_header m_header;
     mutable std::auto_ptr<lldb_private::SectionList> m_sections_ap;
     mutable std::auto_ptr<lldb_private::Symtab> m_symtab_ap;

Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp?rev=152679&r1=152678&r2=152679&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp Tue Mar 13 18:14:29 2012
@@ -181,7 +181,6 @@
                                     addr_t offset, 
                                     addr_t length) :
     ObjectFile (module_sp, file, offset, length, dataSP),
-    m_mutex (Mutex::eMutexTypeRecursive),
     m_dos_header (),
     m_coff_header (),
     m_coff_header_opt (),
@@ -201,26 +200,30 @@
 bool
 ObjectFilePECOFF::ParseHeader ()
 {
-    Mutex::Locker locker(m_mutex);
-    m_sect_headers.clear();
-    m_data.SetByteOrder (eByteOrderLittle);
-    uint32_t offset = 0;
-    
-    if (ParseDOSHeader())
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        offset = m_dos_header.e_lfanew;
-        uint32_t pe_signature = m_data.GetU32 (&offset);
-        if (pe_signature != IMAGE_NT_SIGNATURE)
-            return false;
-        if (ParseCOFFHeader(&offset))
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        m_sect_headers.clear();
+        m_data.SetByteOrder (eByteOrderLittle);
+        uint32_t offset = 0;
+        
+        if (ParseDOSHeader())
         {
-            if (m_coff_header.hdrsize > 0)
-                ParseCOFFOptionalHeader(&offset);
-            ParseSectionHeaders (offset);
+            offset = m_dos_header.e_lfanew;
+            uint32_t pe_signature = m_data.GetU32 (&offset);
+            if (pe_signature != IMAGE_NT_SIGNATURE)
+                return false;
+            if (ParseCOFFHeader(&offset))
+            {
+                if (m_coff_header.hdrsize > 0)
+                    ParseCOFFOptionalHeader(&offset);
+                ParseSectionHeaders (offset);
+            }
+            StreamFile s(stdout, false);// REMOVE THIS LINE!!!
+            Dump(&s);// REMOVE THIS LINE!!!
+            return true;
         }
-        StreamFile s(stdout, false);// REMOVE THIS LINE!!!
-        Dump(&s);// REMOVE THIS LINE!!!
-        return true;
     }
     return false;
 }
@@ -482,69 +485,73 @@
 Symtab *
 ObjectFilePECOFF::GetSymtab()
 {
-    Mutex::Locker symfile_locker(m_mutex);
-    if (m_symtab_ap.get() == NULL)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        SectionList *sect_list = GetSectionList();
-        m_symtab_ap.reset(new Symtab(this));
-        Mutex::Locker symtab_locker (m_symtab_ap->GetMutex());
-        
-        const uint32_t num_syms = m_coff_header.nsyms;
-
-        if (num_syms > 0 && m_coff_header.symoff > 0)
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_symtab_ap.get() == NULL)
         {
-            const uint32_t symbol_size = sizeof(section_header_t);
-            const uint32_t addr_byte_size = GetAddressByteSize ();
-            const size_t symbol_data_size = num_syms * symbol_size; 
-            // Include the 4 bytes string table size at the end of the symbols
-            DataBufferSP symtab_data_sp(m_file.ReadFileContents (m_coff_header.symoff, symbol_data_size + 4));
-            DataExtractor symtab_data (symtab_data_sp, GetByteOrder(), addr_byte_size);
-            uint32_t offset = symbol_data_size;
-            const uint32_t strtab_size = symtab_data.GetU32 (&offset);
-            DataBufferSP strtab_data_sp(m_file.ReadFileContents (m_coff_header.symoff + symbol_data_size + 4, strtab_size));
-            DataExtractor strtab_data (strtab_data_sp, GetByteOrder(), addr_byte_size);
-
-            offset = 0;
-            std::string symbol_name;
-            Symbol *symbols = m_symtab_ap->Resize (num_syms);
-            for (uint32_t i=0; i<num_syms; ++i)
+            SectionList *sect_list = GetSectionList();
+            m_symtab_ap.reset(new Symtab(this));
+            Mutex::Locker symtab_locker (m_symtab_ap->GetMutex());
+            
+            const uint32_t num_syms = m_coff_header.nsyms;
+
+            if (num_syms > 0 && m_coff_header.symoff > 0)
             {
-                coff_symbol_t symbol;
-                const uint32_t symbol_offset = offset;
-                const char *symbol_name_cstr = NULL;
-                // If the first 4 bytes of the symbol string are zero, then we
-                // it is followed by a 4 byte string table offset. Else these
-                // 8 bytes contain the symbol name
-                if (symtab_data.GetU32 (&offset) == 0)
-                {
-                    // Long string that doesn't fit into the symbol table name,
-                    // so now we must read the 4 byte string table offset
-                    uint32_t strtab_offset = symtab_data.GetU32 (&offset);
-                    symbol_name_cstr = strtab_data.PeekCStr (strtab_offset);
-                    symbol_name.assign (symbol_name_cstr);
-                }
-                else
-                {
-                    // Short string that fits into the symbol table name which is 8 bytes
-                    offset += sizeof(symbol.name) - 4; // Skip remaining 
-                    symbol_name_cstr = symtab_data.PeekCStr (symbol_offset);
-                    if (symbol_name_cstr == NULL)
-                        break;
-                    symbol_name.assign (symbol_name_cstr, sizeof(symbol.name));
-                }
-                symbol.value    = symtab_data.GetU32 (&offset);
-                symbol.sect     = symtab_data.GetU16 (&offset);
-                symbol.type     = symtab_data.GetU16 (&offset);
-                symbol.storage  = symtab_data.GetU8  (&offset);
-                symbol.naux     = symtab_data.GetU8  (&offset);		
-                Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1), symbol.value);
-                symbols[i].GetMangled ().SetValue (symbol_name.c_str(), symbol_name[0]=='_' && symbol_name[1] == 'Z');
-                symbols[i].GetAddress() = symbol_addr;
+                const uint32_t symbol_size = sizeof(section_header_t);
+                const uint32_t addr_byte_size = GetAddressByteSize ();
+                const size_t symbol_data_size = num_syms * symbol_size; 
+                // Include the 4 bytes string table size at the end of the symbols
+                DataBufferSP symtab_data_sp(m_file.ReadFileContents (m_coff_header.symoff, symbol_data_size + 4));
+                DataExtractor symtab_data (symtab_data_sp, GetByteOrder(), addr_byte_size);
+                uint32_t offset = symbol_data_size;
+                const uint32_t strtab_size = symtab_data.GetU32 (&offset);
+                DataBufferSP strtab_data_sp(m_file.ReadFileContents (m_coff_header.symoff + symbol_data_size + 4, strtab_size));
+                DataExtractor strtab_data (strtab_data_sp, GetByteOrder(), addr_byte_size);
+
+                offset = 0;
+                std::string symbol_name;
+                Symbol *symbols = m_symtab_ap->Resize (num_syms);
+                for (uint32_t i=0; i<num_syms; ++i)
+                {
+                    coff_symbol_t symbol;
+                    const uint32_t symbol_offset = offset;
+                    const char *symbol_name_cstr = NULL;
+                    // If the first 4 bytes of the symbol string are zero, then we
+                    // it is followed by a 4 byte string table offset. Else these
+                    // 8 bytes contain the symbol name
+                    if (symtab_data.GetU32 (&offset) == 0)
+                    {
+                        // Long string that doesn't fit into the symbol table name,
+                        // so now we must read the 4 byte string table offset
+                        uint32_t strtab_offset = symtab_data.GetU32 (&offset);
+                        symbol_name_cstr = strtab_data.PeekCStr (strtab_offset);
+                        symbol_name.assign (symbol_name_cstr);
+                    }
+                    else
+                    {
+                        // Short string that fits into the symbol table name which is 8 bytes
+                        offset += sizeof(symbol.name) - 4; // Skip remaining 
+                        symbol_name_cstr = symtab_data.PeekCStr (symbol_offset);
+                        if (symbol_name_cstr == NULL)
+                            break;
+                        symbol_name.assign (symbol_name_cstr, sizeof(symbol.name));
+                    }
+                    symbol.value    = symtab_data.GetU32 (&offset);
+                    symbol.sect     = symtab_data.GetU16 (&offset);
+                    symbol.type     = symtab_data.GetU16 (&offset);
+                    symbol.storage  = symtab_data.GetU8  (&offset);
+                    symbol.naux     = symtab_data.GetU8  (&offset);		
+                    Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1), symbol.value);
+                    symbols[i].GetMangled ().SetValue (symbol_name.c_str(), symbol_name[0]=='_' && symbol_name[1] == 'Z');
+                    symbols[i].GetAddress() = symbol_addr;
 
-                if (symbol.naux > 0)
-                    i += symbol.naux;
+                    if (symbol.naux > 0)
+                        i += symbol.naux;
+                }
+                
             }
-            
         }
     }
     return m_symtab_ap.get();
@@ -554,89 +561,93 @@
 SectionList *
 ObjectFilePECOFF::GetSectionList()
 {
-    Mutex::Locker symfile_locker(m_mutex);
-    if (m_sections_ap.get() == NULL)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        m_sections_ap.reset(new SectionList());
-        const uint32_t nsects = m_sect_headers.size();
-        ModuleSP module_sp (GetModule());
-        for (uint32_t idx = 0; idx<nsects; ++idx)
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sections_ap.get() == NULL)
         {
-            std::string sect_name;
-            GetSectionName (sect_name, m_sect_headers[idx]);
-            ConstString const_sect_name (sect_name.c_str());
-            static ConstString g_code_sect_name (".code");
-            static ConstString g_CODE_sect_name ("CODE");
-            static ConstString g_data_sect_name (".data");
-            static ConstString g_DATA_sect_name ("DATA");
-            static ConstString g_bss_sect_name (".bss");
-            static ConstString g_BSS_sect_name ("BSS");
-            static ConstString g_debug_sect_name (".debug");
-            static ConstString g_reloc_sect_name (".reloc");
-            static ConstString g_stab_sect_name (".stab");
-            static ConstString g_stabstr_sect_name (".stabstr");
-            SectionType section_type = eSectionTypeOther;
-            if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_CODE && 
-                ((const_sect_name == g_code_sect_name) || (const_sect_name == g_CODE_sect_name)))
-            {
-                section_type = eSectionTypeCode;
-            }
-            else if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_INITIALIZED_DATA && 
-                     ((const_sect_name == g_data_sect_name) || (const_sect_name == g_DATA_sect_name)))
-            {
-                section_type = eSectionTypeData;
-            }
-            else if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA && 
-                     ((const_sect_name == g_bss_sect_name) || (const_sect_name == g_BSS_sect_name)))
+            m_sections_ap.reset(new SectionList());
+            const uint32_t nsects = m_sect_headers.size();
+            ModuleSP module_sp (GetModule());
+            for (uint32_t idx = 0; idx<nsects; ++idx)
             {
-                if (m_sect_headers[idx].size == 0)
-                    section_type = eSectionTypeZeroFill;
-                else
+                std::string sect_name;
+                GetSectionName (sect_name, m_sect_headers[idx]);
+                ConstString const_sect_name (sect_name.c_str());
+                static ConstString g_code_sect_name (".code");
+                static ConstString g_CODE_sect_name ("CODE");
+                static ConstString g_data_sect_name (".data");
+                static ConstString g_DATA_sect_name ("DATA");
+                static ConstString g_bss_sect_name (".bss");
+                static ConstString g_BSS_sect_name ("BSS");
+                static ConstString g_debug_sect_name (".debug");
+                static ConstString g_reloc_sect_name (".reloc");
+                static ConstString g_stab_sect_name (".stab");
+                static ConstString g_stabstr_sect_name (".stabstr");
+                SectionType section_type = eSectionTypeOther;
+                if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_CODE && 
+                    ((const_sect_name == g_code_sect_name) || (const_sect_name == g_CODE_sect_name)))
+                {
+                    section_type = eSectionTypeCode;
+                }
+                else if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_INITIALIZED_DATA && 
+                         ((const_sect_name == g_data_sect_name) || (const_sect_name == g_DATA_sect_name)))
+                {
                     section_type = eSectionTypeData;
-            }
-            else if (const_sect_name == g_debug_sect_name)
-            {
-                section_type = eSectionTypeDebug;
-            }
-            else if (const_sect_name == g_stabstr_sect_name)
-            {
-                section_type = eSectionTypeDataCString;
-            }
-            else if (const_sect_name == g_reloc_sect_name)
-            {
-                section_type = eSectionTypeOther;
-            }
-            else if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_CODE)
-            {
-                section_type = eSectionTypeCode;
-            }
-            else if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_INITIALIZED_DATA)
-            {
-                section_type = eSectionTypeData;
-            }
-            else if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
-            {
-                if (m_sect_headers[idx].size == 0)
-                    section_type = eSectionTypeZeroFill;
-                else
+                }
+                else if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA && 
+                         ((const_sect_name == g_bss_sect_name) || (const_sect_name == g_BSS_sect_name)))
+                {
+                    if (m_sect_headers[idx].size == 0)
+                        section_type = eSectionTypeZeroFill;
+                    else
+                        section_type = eSectionTypeData;
+                }
+                else if (const_sect_name == g_debug_sect_name)
+                {
+                    section_type = eSectionTypeDebug;
+                }
+                else if (const_sect_name == g_stabstr_sect_name)
+                {
+                    section_type = eSectionTypeDataCString;
+                }
+                else if (const_sect_name == g_reloc_sect_name)
+                {
+                    section_type = eSectionTypeOther;
+                }
+                else if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_CODE)
+                {
+                    section_type = eSectionTypeCode;
+                }
+                else if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_INITIALIZED_DATA)
+                {
                     section_type = eSectionTypeData;
-            }
+                }
+                else if (m_sect_headers[idx].flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
+                {
+                    if (m_sect_headers[idx].size == 0)
+                        section_type = eSectionTypeZeroFill;
+                    else
+                        section_type = eSectionTypeData;
+                }
 
-            // Use a segment ID of the segment index shifted left by 8 so they
-            // never conflict with any of the sections.
-            SectionSP section_sp (new Section (module_sp,                    // Module to which this section belongs
-                                               idx + 1,                      // Section ID is the 1 based segment index shifted right by 8 bits as not to collide with any of the 256 section IDs that are possible
-                                               const_sect_name,              // Name of this section
-                                               section_type,                    // This section is a container of other sections.
-                                               m_sect_headers[idx].vmaddr,   // File VM address == addresses as they are found in the object file
-                                               m_sect_headers[idx].vmsize,   // VM size in bytes of this section
-                                               m_sect_headers[idx].offset,   // Offset to the data for this section in the file
-                                               m_sect_headers[idx].size,     // Size in bytes of this section as found in the the file
-                                               m_sect_headers[idx].flags));  // Flags for this section
+                // Use a segment ID of the segment index shifted left by 8 so they
+                // never conflict with any of the sections.
+                SectionSP section_sp (new Section (module_sp,                    // Module to which this section belongs
+                                                   idx + 1,                      // Section ID is the 1 based segment index shifted right by 8 bits as not to collide with any of the 256 section IDs that are possible
+                                                   const_sect_name,              // Name of this section
+                                                   section_type,                    // This section is a container of other sections.
+                                                   m_sect_headers[idx].vmaddr,   // File VM address == addresses as they are found in the object file
+                                                   m_sect_headers[idx].vmsize,   // VM size in bytes of this section
+                                                   m_sect_headers[idx].offset,   // Offset to the data for this section in the file
+                                                   m_sect_headers[idx].size,     // Size in bytes of this section as found in the the file
+                                                   m_sect_headers[idx].flags));  // Flags for this section
 
-            //section_sp->SetIsEncrypted (segment_is_encrypted);
+                //section_sp->SetIsEncrypted (segment_is_encrypted);
 
-            m_sections_ap->AddSection(section_sp);
+                m_sections_ap->AddSection(section_sp);
+            }
         }
     }
     return m_sections_ap.get();
@@ -664,33 +675,37 @@
 void 
 ObjectFilePECOFF::Dump(Stream *s)
 {
-    Mutex::Locker locker(m_mutex);
-    s->Printf("%p: ", this);
-    s->Indent();
-    s->PutCString("ObjectFilePECOFF");
-    
-    ArchSpec header_arch;
-    GetArchitecture (header_arch);
-    
-    *s << ", file = '" << m_file << "', arch = " << header_arch.GetArchitectureName() << "\n";
-    
-    if (m_sections_ap.get())
-        m_sections_ap->Dump(s, NULL, true, UINT32_MAX);
-    
-    if (m_symtab_ap.get())
-        m_symtab_ap->Dump(s, NULL, eSortOrderNone);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        s->Printf("%p: ", this);
+        s->Indent();
+        s->PutCString("ObjectFilePECOFF");
+        
+        ArchSpec header_arch;
+        GetArchitecture (header_arch);
+        
+        *s << ", file = '" << m_file << "', arch = " << header_arch.GetArchitectureName() << "\n";
+        
+        if (m_sections_ap.get())
+            m_sections_ap->Dump(s, NULL, true, UINT32_MAX);
+        
+        if (m_symtab_ap.get())
+            m_symtab_ap->Dump(s, NULL, eSortOrderNone);
 
-    if (m_dos_header.e_magic)
-        DumpDOSHeader (s, m_dos_header);
-    if (m_coff_header.machine)
-    {
-        DumpCOFFHeader (s, m_coff_header);
-        if (m_coff_header.hdrsize)
-            DumpOptCOFFHeader (s, m_coff_header_opt);
-    }
-    s->EOL();
-    DumpSectionHeaders(s);
-    s->EOL();    
+        if (m_dos_header.e_magic)
+            DumpDOSHeader (s, m_dos_header);
+        if (m_coff_header.machine)
+        {
+            DumpCOFFHeader (s, m_coff_header);
+            if (m_coff_header.hdrsize)
+                DumpOptCOFFHeader (s, m_coff_header_opt);
+        }
+        s->EOL();
+        DumpSectionHeaders(s);
+        s->EOL();
+    }
 }
 
 //----------------------------------------------------------------------

Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h?rev=152679&r1=152678&r2=152679&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h Tue Mar 13 18:14:29 2012
@@ -12,7 +12,6 @@
 
 #include <vector>
 
-#include "lldb/Host/Mutex.h"
 #include "lldb/Symbol/ObjectFile.h"
 
 class ObjectFilePECOFF : 
@@ -228,7 +227,6 @@
 	typedef SectionHeaderColl::iterator			SectionHeaderCollIter;
 	typedef SectionHeaderColl::const_iterator	SectionHeaderCollConstIter;
 private:
-    mutable lldb_private::Mutex m_mutex;
     mutable std::auto_ptr<lldb_private::SectionList> m_sections_ap;
     mutable std::auto_ptr<lldb_private::Symtab> m_symtab_ap;
 	dos_header_t		m_dos_header;

Modified: lldb/trunk/source/Symbol/SymbolVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolVendor.cpp?rev=152679&r1=152678&r2=152679&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolVendor.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolVendor.cpp Tue Mar 13 18:14:29 2012
@@ -68,7 +68,6 @@
 //----------------------------------------------------------------------
 SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp) :
     ModuleChild (module_sp),
-    m_mutex (Mutex::eMutexTypeRecursive),
     m_type_list(),
     m_compile_units(),
     m_sym_file_ap()
@@ -88,29 +87,37 @@
 void
 SymbolVendor::AddSymbolFileRepresentation(const ObjectFileSP &objfile_sp)
 {
-    Mutex::Locker locker(m_mutex);
-    if (objfile_sp)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        m_objfile_sp = objfile_sp;
-        m_sym_file_ap.reset(SymbolFile::FindPlugin(objfile_sp.get()));
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (objfile_sp)
+        {
+            m_objfile_sp = objfile_sp;
+            m_sym_file_ap.reset(SymbolFile::FindPlugin(objfile_sp.get()));
+        }
     }
 }
 
 bool
 SymbolVendor::SetCompileUnitAtIndex (CompUnitSP& cu, uint32_t idx)
 {
-    Mutex::Locker locker(m_mutex);
-    const uint32_t num_compile_units = GetNumCompileUnits();
-    if (idx < num_compile_units)
-    {
-        // Fire off an assertion if this compile unit already exists for now.
-        // The partial parsing should take care of only setting the compile
-        // unit once, so if this assertion fails, we need to make sure that
-        // we don't have a race condition, or have a second parse of the same
-        // compile unit.
-        assert(m_compile_units[idx].get() == NULL);
-        m_compile_units[idx] = cu;
-        return true;
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        const uint32_t num_compile_units = GetNumCompileUnits();
+        if (idx < num_compile_units)
+        {
+            // Fire off an assertion if this compile unit already exists for now.
+            // The partial parsing should take care of only setting the compile
+            // unit once, so if this assertion fails, we need to make sure that
+            // we don't have a race condition, or have a second parse of the same
+            // compile unit.
+            assert(m_compile_units[idx].get() == NULL);
+            m_compile_units[idx] = cu;
+            return true;
+        }
     }
     return false;
 }
@@ -118,16 +125,20 @@
 uint32_t
 SymbolVendor::GetNumCompileUnits()
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_compile_units.empty())
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        if (m_sym_file_ap.get())
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_compile_units.empty())
         {
-            // Resize our array of compile unit shared pointers -- which will
-            // each remain NULL until someone asks for the actual compile unit
-            // information. When this happens, the symbol file will be asked
-            // to parse this compile unit information.
-            m_compile_units.resize(m_sym_file_ap->GetNumCompileUnits());
+            if (m_sym_file_ap.get())
+            {
+                // Resize our array of compile unit shared pointers -- which will
+                // each remain NULL until someone asks for the actual compile unit
+                // information. When this happens, the symbol file will be asked
+                // to parse this compile unit information.
+                m_compile_units.resize(m_sym_file_ap->GetNumCompileUnits());
+            }
         }
     }
     return m_compile_units.size();
@@ -136,63 +147,91 @@
 size_t
 SymbolVendor::ParseCompileUnitFunctions (const SymbolContext &sc)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->ParseCompileUnitFunctions(sc);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->ParseCompileUnitFunctions(sc);
+    }
     return 0;
 }
 
 bool
 SymbolVendor::ParseCompileUnitLineTable (const SymbolContext &sc)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->ParseCompileUnitLineTable(sc);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->ParseCompileUnitLineTable(sc);
+    }
     return false;
 }
 
 bool
 SymbolVendor::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->ParseCompileUnitSupportFiles(sc, support_files);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->ParseCompileUnitSupportFiles(sc, support_files);
+    }
     return false;
 }
 
 size_t
 SymbolVendor::ParseFunctionBlocks (const SymbolContext &sc)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->ParseFunctionBlocks(sc);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->ParseFunctionBlocks(sc);
+    }
     return 0;
 }
 
 size_t
 SymbolVendor::ParseTypes (const SymbolContext &sc)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->ParseTypes(sc);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->ParseTypes(sc);
+    }
     return 0;
 }
 
 size_t
 SymbolVendor::ParseVariablesForContext (const SymbolContext& sc)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->ParseVariablesForContext(sc);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->ParseVariablesForContext(sc);
+    }
     return 0;
 }
 
 Type*
 SymbolVendor::ResolveTypeUID(lldb::user_id_t type_uid)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->ResolveTypeUID(type_uid);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->ResolveTypeUID(type_uid);
+    }
     return NULL;
 }
 
@@ -200,54 +239,78 @@
 uint32_t
 SymbolVendor::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->ResolveSymbolContext(so_addr, resolve_scope, sc);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->ResolveSymbolContext(so_addr, resolve_scope, sc);
+    }
     return 0;
 }
 
 uint32_t
 SymbolVendor::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope, sc_list);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope, sc_list);
+    }
     return 0;
 }
 
 uint32_t
 SymbolVendor::FindGlobalVariables (const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->FindGlobalVariables(name, namespace_decl, append, max_matches, variables);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->FindGlobalVariables(name, namespace_decl, append, max_matches, variables);
+    }
     return 0;
 }
 
 uint32_t
 SymbolVendor::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->FindGlobalVariables(regex, append, max_matches, variables);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->FindGlobalVariables(regex, append, max_matches, variables);
+    }
     return 0;
 }
 
 uint32_t
 SymbolVendor::FindFunctions(const ConstString &name, const ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list);
+    }
     return 0;
 }
 
 uint32_t
 SymbolVendor::FindFunctions(const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->FindFunctions(regex, include_inlines, append, sc_list);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->FindFunctions(regex, include_inlines, append, sc_list);
+    }
     return 0;
 }
 
@@ -255,9 +318,13 @@
 uint32_t
 SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, TypeList& types)
 {
-    Mutex::Locker locker(m_mutex);
-    if (m_sym_file_ap.get())
-        return m_sym_file_ap->FindTypes(sc, name, namespace_decl, append, max_matches, types);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            return m_sym_file_ap->FindTypes(sc, name, namespace_decl, append, max_matches, types);
+    }
     if (!append)
         types.Clear();
     return 0;
@@ -266,66 +333,75 @@
 ClangNamespaceDecl
 SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *parent_namespace_decl)
 {
-    Mutex::Locker locker(m_mutex);
     ClangNamespaceDecl namespace_decl;
-    if (m_sym_file_ap.get())
-        namespace_decl = m_sym_file_ap->FindNamespace (sc, name, parent_namespace_decl);
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
+    {
+        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+        if (m_sym_file_ap.get())
+            namespace_decl = m_sym_file_ap->FindNamespace (sc, name, parent_namespace_decl);
+    }
     return namespace_decl;
 }
 
 void
 SymbolVendor::Dump(Stream *s)
 {
-    Mutex::Locker locker(m_mutex);
-    bool show_context = false;
-
-    s->Printf("%p: ", this);
-    s->Indent();
-    s->PutCString("SymbolVendor");
-    if (m_sym_file_ap.get())
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        ObjectFile *objfile = m_sym_file_ap->GetObjectFile();
-        if (objfile)
+        bool show_context = false;
+
+        s->Printf("%p: ", this);
+        s->Indent();
+        s->PutCString("SymbolVendor");
+        if (m_sym_file_ap.get())
         {
-            const FileSpec &objfile_file_spec = objfile->GetFileSpec();
-            if (objfile_file_spec)
+            ObjectFile *objfile = m_sym_file_ap->GetObjectFile();
+            if (objfile)
             {
-                s->PutCString(" (");
-                objfile_file_spec.Dump(s);
-                s->PutChar(')');
+                const FileSpec &objfile_file_spec = objfile->GetFileSpec();
+                if (objfile_file_spec)
+                {
+                    s->PutCString(" (");
+                    objfile_file_spec.Dump(s);
+                    s->PutChar(')');
+                }
             }
         }
-    }
-    s->EOL();
-    s->IndentMore();
-    m_type_list.Dump(s, show_context);
+        s->EOL();
+        s->IndentMore();
+        m_type_list.Dump(s, show_context);
+
+        CompileUnitConstIter cu_pos, cu_end;
+        cu_end = m_compile_units.end();
+        for (cu_pos = m_compile_units.begin(); cu_pos != cu_end; ++cu_pos)
+        {
+            // We currently only dump the compile units that have been parsed
+            if (cu_pos->get())
+                (*cu_pos)->Dump(s, show_context);
+        }
 
-    CompileUnitConstIter cu_pos, cu_end;
-    cu_end = m_compile_units.end();
-    for (cu_pos = m_compile_units.begin(); cu_pos != cu_end; ++cu_pos)
-    {
-        // We currently only dump the compile units that have been parsed
-        if (cu_pos->get())
-            (*cu_pos)->Dump(s, show_context);
+        s->IndentLess();
     }
-
-    s->IndentLess();
-
 }
 
 CompUnitSP
 SymbolVendor::GetCompileUnitAtIndex(uint32_t idx)
 {
-    Mutex::Locker locker(m_mutex);
     CompUnitSP cu_sp;
-    const uint32_t num_compile_units = GetNumCompileUnits();
-    if (idx < num_compile_units)
+    ModuleSP module_sp(GetModule());
+    if (module_sp)
     {
-        cu_sp = m_compile_units[idx];
-        if (cu_sp.get() == NULL)
+        const uint32_t num_compile_units = GetNumCompileUnits();
+        if (idx < num_compile_units)
         {
-            m_compile_units[idx] = m_sym_file_ap->ParseCompileUnitAtIndex(idx);
             cu_sp = m_compile_units[idx];
+            if (cu_sp.get() == NULL)
+            {
+                m_compile_units[idx] = m_sym_file_ap->ParseCompileUnitAtIndex(idx);
+                cu_sp = m_compile_units[idx];
+            }
         }
     }
     return cu_sp;





More information about the lldb-commits mailing list