[Lldb-commits] [lldb] r174222 - <rdar://problem/13092722>

Greg Clayton gclayton at apple.com
Fri Feb 1 13:38:35 PST 2013


Author: gclayton
Date: Fri Feb  1 15:38:35 2013
New Revision: 174222

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

Fix in loading mach files from memory when using DynamicLoaderMacOSXDYLD.

Removed the uuid mismatch warning that could be spit out and any time during debugging and removed the test case that was looking for that. Currently the "add-dsym" or "target symbols add" command will report an error when the UUID's don't match.

Be more careful when checking and resolving section + offset addresses to make sure none of the base addresses are invalid.


Removed:
    lldb/trunk/test/warnings/uuid/TestUUIDMismatchWanring.py
Modified:
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/source/API/SBModule.cpp
    lldb/trunk/source/Host/macosx/Symbols.cpp
    lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
    lldb/trunk/source/Symbol/ObjectFile.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/SectionLoadList.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=174222&r1=174221&r2=174222&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Fri Feb  1 15:38:35 2013
@@ -2890,9 +2890,7 @@ public:
     
     lldb::ModuleSP
     ReadModuleFromMemory (const FileSpec& file_spec, 
-                          lldb::addr_t header_addr,
-                          bool add_image_to_target,
-                          bool load_sections_in_target);
+                          lldb::addr_t header_addr);
 
     //------------------------------------------------------------------
     /// Attempt to get the attributes for a region of memory in the process.

Modified: lldb/trunk/source/API/SBModule.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=174222&r1=174221&r2=174222&view=diff
==============================================================================
--- lldb/trunk/source/API/SBModule.cpp (original)
+++ lldb/trunk/source/API/SBModule.cpp Fri Feb  1 15:38:35 2013
@@ -50,12 +50,14 @@ SBModule::SBModule (lldb::SBProcess &pro
     ProcessSP process_sp (process.GetSP());
     if (process_sp)
     {
-        const bool add_image_to_target = true;
-        const bool load_image_sections_in_target = true;
-        m_opaque_sp = process_sp->ReadModuleFromMemory (FileSpec(), 
-                                                        header_addr, 
-                                                        add_image_to_target,
-                                                        load_image_sections_in_target);
+        m_opaque_sp = process_sp->ReadModuleFromMemory (FileSpec(), header_addr);
+        if (m_opaque_sp)
+        {
+            Target &target = process_sp->GetTarget();
+            bool changed = false;
+            m_opaque_sp->SetLoadAddress(target, 0, changed);
+            target.GetImages().Append(m_opaque_sp);
+        }
     }
 }
 

Modified: lldb/trunk/source/Host/macosx/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=174222&r1=174221&r2=174222&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Symbols.cpp (original)
+++ lldb/trunk/source/Host/macosx/Symbols.cpp Fri Feb  1 15:38:35 2013
@@ -124,18 +124,6 @@ SkinnyMachOFileContainsArchAndUUID
             lldb_private::UUID file_uuid (data.GetData(&data_offset, 16), 16);
             if (file_uuid == *uuid)
                 return true;
-
-            // Emit some warning messages since the UUIDs do not match!
-            char path_buf[PATH_MAX];
-            path_buf[0] = '\0';
-            const char *path = file_spec.GetPath(path_buf, PATH_MAX) ? path_buf
-                                                                     : file_spec.GetFilename().AsCString();
-            StreamString ss_m_uuid, ss_o_uuid;
-            uuid->Dump(&ss_m_uuid);
-            file_uuid.Dump(&ss_o_uuid);
-            Host::SystemLog (Host::eSystemLogWarning, 
-                             "warning: UUID mismatch detected between binary (%s) and:\n\t'%s' (%s)\n", 
-                             ss_m_uuid.GetData(), path, ss_o_uuid.GetData());
             return false;
         }
         data_offset = cmd_offset + cmd_size;

Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=174222&r1=174221&r2=174222&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Fri Feb  1 15:38:35 2013
@@ -420,7 +420,7 @@ DynamicLoaderDarwinKernel::CheckForKerne
         && (header.flags & llvm::MachO::HeaderFlagBitIsDynamicLinkObject) == 0)
     {
         // Create a full module to get the UUID
-        ModuleSP memory_module_sp = process->ReadModuleFromMemory (FileSpec ("temp_mach_kernel", false), addr, false, false);
+        ModuleSP memory_module_sp = process->ReadModuleFromMemory (FileSpec ("temp_mach_kernel", false), addr);
         if (!memory_module_sp.get())
             return UUID();
 
@@ -557,7 +557,7 @@ DynamicLoaderDarwinKernel::OSKextLoadedK
         else
             file_spec.SetFile (name, false);
         
-        memory_module_sp = process->ReadModuleFromMemory (file_spec, address, false, false);
+        memory_module_sp = process->ReadModuleFromMemory (file_spec, address);
         if (memory_module_sp && !uuid_is_valid)
         {
             uuid = memory_module_sp->GetUUID();

Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=174222&r1=174221&r2=174222&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Fri Feb  1 15:38:35 2013
@@ -273,30 +273,33 @@ DynamicLoaderMacOSXDYLD::LocateDYLD()
         // mach header for dyld, or it might point to the 
         // dyld_all_image_infos struct
         const addr_t shlib_addr = m_process->GetImageInfoAddress ();
-        ByteOrder byte_order = m_process->GetTarget().GetArchitecture().GetByteOrder();
-        uint8_t buf[4];
-        DataExtractor data (buf, sizeof(buf), byte_order, 4);
-        Error error;
-        if (m_process->ReadMemory (shlib_addr, buf, 4, error) == 4)
+        if (shlib_addr != LLDB_INVALID_ADDRESS)
         {
-            lldb::offset_t offset = 0;
-            uint32_t magic = data.GetU32 (&offset);
-            switch (magic)
-            {
-            case llvm::MachO::HeaderMagic32:
-            case llvm::MachO::HeaderMagic64:
-            case llvm::MachO::HeaderMagic32Swapped:
-            case llvm::MachO::HeaderMagic64Swapped:
-                m_process_image_addr_is_all_images_infos = false;
-                return ReadDYLDInfoFromMemoryAndSetNotificationCallback(shlib_addr);
-                
-            default:
-                break;
+            ByteOrder byte_order = m_process->GetTarget().GetArchitecture().GetByteOrder();
+            uint8_t buf[4];
+            DataExtractor data (buf, sizeof(buf), byte_order, 4);
+            Error error;
+            if (m_process->ReadMemory (shlib_addr, buf, 4, error) == 4)
+            {
+                lldb::offset_t offset = 0;
+                uint32_t magic = data.GetU32 (&offset);
+                switch (magic)
+                {
+                case llvm::MachO::HeaderMagic32:
+                case llvm::MachO::HeaderMagic64:
+                case llvm::MachO::HeaderMagic32Swapped:
+                case llvm::MachO::HeaderMagic64Swapped:
+                    m_process_image_addr_is_all_images_infos = false;
+                    return ReadDYLDInfoFromMemoryAndSetNotificationCallback(shlib_addr);
+                    
+                default:
+                    break;
+                }
             }
+            // Maybe it points to the all image infos?
+            m_dyld_all_image_infos_addr = shlib_addr;
+            m_process_image_addr_is_all_images_infos = true;
         }
-        // Maybe it points to the all image infos?
-        m_dyld_all_image_infos_addr = shlib_addr;
-        m_process_image_addr_is_all_images_infos = true;
     }
 
     if (m_dyld_all_image_infos_addr != LLDB_INVALID_ADDRESS)
@@ -333,13 +336,13 @@ DynamicLoaderMacOSXDYLD::LocateDYLD()
 }
 
 ModuleSP
-DynamicLoaderMacOSXDYLD::FindTargetModuleForDYLDImageInfo (const DYLDImageInfo &image_info, bool can_create, bool *did_create_ptr)
+DynamicLoaderMacOSXDYLD::FindTargetModuleForDYLDImageInfo (DYLDImageInfo &image_info, bool can_create, bool *did_create_ptr)
 {
     if (did_create_ptr)
         *did_create_ptr = false;
     
-    
-    const ModuleList &target_images = m_process->GetTarget().GetImages();
+    Target &target = m_process->GetTarget();
+    const ModuleList &target_images = target.GetImages();
     ModuleSpec module_spec (image_info.file_spec, image_info.GetArchitecture ());
     module_spec.GetUUID() = image_info.uuid;
     ModuleSP module_sp (target_images.FindFirstModule (module_spec));
@@ -356,16 +359,9 @@ DynamicLoaderMacOSXDYLD::FindTargetModul
     {
         if (can_create)
         {
-            module_sp = m_process->GetTarget().GetSharedModule (module_spec);
+            module_sp = target.GetSharedModule (module_spec);
             if (!module_sp || module_sp->GetObjectFile() == NULL)
-            {
-                const bool add_image_to_target = true;
-                const bool load_image_sections_in_target = false;
-                module_sp = m_process->ReadModuleFromMemory (image_info.file_spec,
-                                                             image_info.address,
-                                                             add_image_to_target,
-                                                             load_image_sections_in_target);
-            }
+                module_sp = m_process->ReadModuleFromMemory (image_info.file_spec, image_info.address);
 
             if (did_create_ptr)
                 *did_create_ptr = (bool) module_sp;
@@ -399,12 +395,14 @@ DynamicLoaderMacOSXDYLD::ReadDYLDInfoFro
                 }
             }
 
+            Target &target = m_process->GetTarget();
+
             if (m_dyld_all_image_infos_addr == LLDB_INVALID_ADDRESS && dyld_module_sp.get())
             {
                 static ConstString g_dyld_all_image_infos ("dyld_all_image_infos");
                 const Symbol *symbol = dyld_module_sp->FindFirstSymbolWithNameAndType (g_dyld_all_image_infos, eSymbolTypeData);
                 if (symbol)
-                    m_dyld_all_image_infos_addr = symbol->GetAddress().GetLoadAddress(&m_process->GetTarget());
+                    m_dyld_all_image_infos_addr = symbol->GetAddress().GetLoadAddress(&target);
             }
 
             // Update all image infos
@@ -417,13 +415,12 @@ DynamicLoaderMacOSXDYLD::ReadDYLDInfoFro
             /// unique!
             if (dyld_module_sp)
             {
-                if (m_process->GetTarget().GetImages().AppendIfNeeded (dyld_module_sp))
-                    UpdateImageLoadAddress(dyld_module_sp.get(), m_dyld);
+                target.GetImages().AppendIfNeeded (dyld_module_sp);
 
                 // At this point we should have read in dyld's module, and so we should set breakpoints in it:
                 ModuleList modules;
                 modules.Append(dyld_module_sp);
-                m_process->GetTarget().ModulesDidLoad(modules);
+                target.ModulesDidLoad(modules);
             }
             return true;
         }
@@ -437,40 +434,6 @@ DynamicLoaderMacOSXDYLD::NeedToLocateDYL
     return m_dyld_all_image_infos_addr == LLDB_INVALID_ADDRESS;
 }
 
-bool
-DynamicLoaderMacOSXDYLD::UpdateCommPageLoadAddress(Module *module)
-{
-    bool changed = false;
-    if (module)
-    {
-        ObjectFile *image_object_file = module->GetObjectFile();
-        if (image_object_file)
-        {
-            SectionList *section_list = image_object_file->GetSectionList ();
-            if (section_list)
-            {
-                const size_t num_sections = section_list->GetSize();
-                for (size_t i=0; i<num_sections; ++i)
-                {
-                    SectionSP section_sp (section_list->GetSectionAtIndex (i));
-                    if (section_sp)
-                    {
-                        const addr_t new_section_load_addr = section_sp->GetFileAddress ();
-                        const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section_sp);
-                        if (old_section_load_addr == LLDB_INVALID_ADDRESS ||
-                            old_section_load_addr != new_section_load_addr)
-                        {
-                            if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section_sp, section_sp->GetFileAddress ()))
-                                changed = true;
-                        }
-                    }
-                }
-            }
-        }
-    }
-    return changed;
-}
-
 //----------------------------------------------------------------------
 // Update the load addresses for all segments in MODULE using the
 // updated INFO that is passed in.
@@ -566,6 +529,14 @@ DynamicLoaderMacOSXDYLD::UpdateImageLoad
             }
         }
     }
+    // We might have an in memory image that was loaded as soon as it was created
+    if (info.load_stop_id == m_process->GetStopID())
+        changed = true;
+    else if (changed)
+    {
+        // Update the stop ID when this library was updated
+        info.load_stop_id = m_process->GetStopID();
+    }
     return changed;
 }
 
@@ -843,6 +814,8 @@ DynamicLoaderMacOSXDYLD::AddModulesUsing
     // Now add these images to the main list.
     ModuleList loaded_module_list;
     LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER));
+    Target &target = m_process->GetTarget();
+    ModuleList& target_images = target.GetImages();
     
     for (uint32_t idx = 0; idx < image_infos.size(); ++idx)
     {
@@ -871,26 +844,31 @@ DynamicLoaderMacOSXDYLD::AddModulesUsing
                     Section *commpage_section = sections->FindSectionByName(commpage_dbstr).get();
                     if (commpage_section)
                     {
-                        const ModuleList& target_images = m_process->GetTarget().GetImages();
                         ModuleSpec module_spec (objfile->GetFileSpec(), image_infos[idx].GetArchitecture ());
                         module_spec.GetObjectName() = commpage_dbstr;
                         ModuleSP commpage_image_module_sp(target_images.FindFirstModule (module_spec));
                         if (!commpage_image_module_sp)
                         {
                             module_spec.SetObjectOffset (objfile->GetOffset() + commpage_section->GetFileOffset());
-                            commpage_image_module_sp  = m_process->GetTarget().GetSharedModule (module_spec);
+                            commpage_image_module_sp  = target.GetSharedModule (module_spec);
                             if (!commpage_image_module_sp || commpage_image_module_sp->GetObjectFile() == NULL)
                             {
-                                const bool add_image_to_target = true;
-                                const bool load_image_sections_in_target = false;
                                 commpage_image_module_sp = m_process->ReadModuleFromMemory (image_infos[idx].file_spec,
-                                                                                            image_infos[idx].address,
-                                                                                            add_image_to_target,
-                                                                                            load_image_sections_in_target);
+                                                                                            image_infos[idx].address);
+                                // Always load a memory image right away in the target in case
+                                // we end up trying to read the symbol table from memory... The
+                                // __LINKEDIT will need to be mapped so we can figure out where
+                                // the symbol table bits are...
+                                bool changed = false;
+                                UpdateImageLoadAddress (commpage_image_module_sp.get(), image_infos[idx]);
+                                target.GetImages().Append(commpage_image_module_sp);
+                                if (changed)
+                                {
+                                    image_infos[idx].load_stop_id = m_process->GetStopID();
+                                    loaded_module_list.AppendIfNeeded (commpage_image_module_sp);
+                                }
                             }
                         }
-                        if (commpage_image_module_sp)
-                            UpdateCommPageLoadAddress (commpage_image_module_sp.get());
                     }
                 }
             }
@@ -902,6 +880,7 @@ DynamicLoaderMacOSXDYLD::AddModulesUsing
             // shared libraries each time.
             if (UpdateImageLoadAddress (image_module_sp.get(), image_infos[idx]))
             {
+                target_images.AppendIfNeeded(image_module_sp);
                 loaded_module_list.AppendIfNeeded (image_module_sp);
             }
         }
@@ -1343,32 +1322,18 @@ DynamicLoaderMacOSXDYLD::UpdateImageInfo
         }
     }
 
+    Target &target = m_process->GetTarget();
+
     if (exe_idx < image_infos.size())
     {
         const bool can_create = true;
         ModuleSP exe_module_sp (FindTargetModuleForDYLDImageInfo (image_infos[exe_idx], can_create, NULL));
 
-        if (!exe_module_sp)
-        {
-            ArchSpec exe_arch_spec (image_infos[exe_idx].GetArchitecture ());
-            ModuleSpec module_spec (image_infos[exe_idx].file_spec, 
-                                    image_infos[exe_idx].GetArchitecture ());
-            module_spec.GetUUID() = image_infos[exe_idx].uuid;
-            exe_module_sp = m_process->GetTarget().GetSharedModule (module_spec);
-            if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL)
-            {
-                const bool add_image_to_target = true;
-                const bool load_image_sections_in_target = false;
-                exe_module_sp = m_process->ReadModuleFromMemory (image_infos[exe_idx].file_spec,
-                                                                 image_infos[exe_idx].address,
-                                                                 add_image_to_target,
-                                                                 load_image_sections_in_target);                
-            }
-        }
-        
         if (exe_module_sp)
         {
-            if (exe_module_sp.get() != m_process->GetTarget().GetExecutableModulePointer())
+            UpdateImageLoadAddress (exe_module_sp.get(), image_infos[exe_idx]);
+
+            if (exe_module_sp.get() != target.GetExecutableModulePointer())
             {
                 // Don't load dependent images since we are in dyld where we will know
                 // and find out about all images that are loaded

Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h?rev=174222&r1=174221&r2=174222&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h Fri Feb  1 15:38:35 2013
@@ -178,6 +178,7 @@ protected:
         lldb_private::UUID uuid;            // UUID for this dylib if it has one, else all zeros
         llvm::MachO::mach_header header;    // The mach header for this image
         std::vector<Segment> segments;      // All segment vmaddr and vmsize pairs for this executable (from memory of inferior)
+        uint32_t load_stop_id;              // The process stop ID that the sections for this image were loadeded
 
         DYLDImageInfo() :
             address(LLDB_INVALID_ADDRESS),
@@ -186,7 +187,8 @@ protected:
             file_spec(),
             uuid(),
             header(),
-            segments()
+            segments(),
+            load_stop_id(0)
         {
         }
 
@@ -203,6 +205,7 @@ protected:
             }
             uuid.Clear();
             segments.clear();
+            load_stop_id = 0;
         }
 
         bool
@@ -316,7 +319,7 @@ protected:
                             DYLDImageInfo& info);
 
     lldb::ModuleSP
-    FindTargetModuleForDYLDImageInfo (const DYLDImageInfo &image_info,
+    FindTargetModuleForDYLDImageInfo (DYLDImageInfo &image_info,
                                       bool can_create,
                                       bool *did_create_ptr);
 
@@ -358,9 +361,6 @@ protected:
                                           bool update_executable);
 
     bool
-    UpdateCommPageLoadAddress (lldb_private::Module *module);
-
-    bool
     ReadImageInfos (lldb::addr_t image_infos_addr, 
                     uint32_t image_infos_count, 
                     DYLDImageInfo::collection &image_infos);

Modified: lldb/trunk/source/Symbol/ObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=174222&r1=174221&r2=174222&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ObjectFile.cpp (original)
+++ lldb/trunk/source/Symbol/ObjectFile.cpp Fri Feb  1 15:38:35 2013
@@ -364,7 +364,9 @@ ObjectFile::ReadSectionData (const Secti
         if (process_sp)
         {
             Error error;
-            return process_sp->ReadMemory (section->GetLoadBaseAddress (&process_sp->GetTarget()) + section_offset, dst, dst_len, error);
+            const addr_t base_load_addr = section->GetLoadBaseAddress (&process_sp->GetTarget());
+            if (base_load_addr != LLDB_INVALID_ADDRESS)
+                return process_sp->ReadMemory (base_load_addr + section_offset, dst, dst_len, error);
         }
     }
     else
@@ -406,13 +408,17 @@ ObjectFile::ReadSectionData (const Secti
         ProcessSP process_sp (m_process_wp.lock());
         if (process_sp)
         {
-            DataBufferSP data_sp (ReadMemory (process_sp, section->GetLoadBaseAddress (&process_sp->GetTarget()), section->GetByteSize()));
-            if (data_sp)
+            const addr_t base_load_addr = section->GetLoadBaseAddress (&process_sp->GetTarget());
+            if (base_load_addr != LLDB_INVALID_ADDRESS)
             {
-                section_data.SetData (data_sp, 0, data_sp->GetByteSize());
-                section_data.SetByteOrder (process_sp->GetByteOrder());
-                section_data.SetAddressByteSize (process_sp->GetAddressByteSize());
-                return section_data.GetByteSize();
+                DataBufferSP data_sp (ReadMemory (process_sp, base_load_addr, section->GetByteSize()));
+                if (data_sp)
+                {
+                    section_data.SetData (data_sp, 0, data_sp->GetByteSize());
+                    section_data.SetByteOrder (process_sp->GetByteOrder());
+                    section_data.SetAddressByteSize (process_sp->GetAddressByteSize());
+                    return section_data.GetByteSize();
+                }
             }
         }
     }

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=174222&r1=174221&r2=174222&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Fri Feb  1 15:38:35 2013
@@ -2666,9 +2666,7 @@ Process::DeallocateMemory (addr_t ptr)
 
 ModuleSP
 Process::ReadModuleFromMemory (const FileSpec& file_spec, 
-                               lldb::addr_t header_addr, 
-                               bool add_image_to_target,
-                               bool load_sections_in_target)
+                               lldb::addr_t header_addr)
 {
     ModuleSP module_sp (new Module (file_spec, ArchSpec()));
     if (module_sp)
@@ -2676,18 +2674,7 @@ Process::ReadModuleFromMemory (const Fil
         Error error;
         ObjectFile *objfile = module_sp->GetMemoryObjectFile (shared_from_this(), header_addr, error);
         if (objfile)
-        {
-            if (add_image_to_target)
-            {
-                m_target.GetImages().Append(module_sp);
-                if (load_sections_in_target)
-                {
-                    bool changed = false;
-                    module_sp->SetLoadAddress (m_target, 0, changed);
-                }
-            }
             return module_sp;
-        }
     }
     return ModuleSP();
 }

Modified: lldb/trunk/source/Target/SectionLoadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/SectionLoadList.cpp?rev=174222&r1=174221&r2=174222&view=diff
==============================================================================
--- lldb/trunk/source/Target/SectionLoadList.cpp (original)
+++ lldb/trunk/source/Target/SectionLoadList.cpp Fri Feb  1 15:38:35 2013
@@ -216,9 +216,10 @@ SectionLoadList::ResolveLoadAddress (add
         {
             if (load_addr != pos->first && pos != m_addr_to_sect.begin())
                 --pos;
-            if (load_addr >= pos->first)
+            const addr_t pos_load_addr = pos->first;
+            if (load_addr >= pos_load_addr)
             {
-                addr_t offset = load_addr - pos->first;
+                addr_t offset = load_addr - pos_load_addr;
                 if (offset < pos->second->GetByteSize())
                 {
                     // We have found the top level section, now we need to find the

Removed: lldb/trunk/test/warnings/uuid/TestUUIDMismatchWanring.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/warnings/uuid/TestUUIDMismatchWanring.py?rev=174221&view=auto
==============================================================================
--- lldb/trunk/test/warnings/uuid/TestUUIDMismatchWanring.py (original)
+++ lldb/trunk/test/warnings/uuid/TestUUIDMismatchWanring.py (removed)
@@ -1,113 +0,0 @@
-"""Test that the 'warning: UUID mismatch detected ...' message is emitted if a
-dsym in vicinity of the executable does not match its UUID."""
-
-import os, time
-import unittest2
-import lldb
-import pexpect
-from lldbtest import *
-
- at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
-class UUIDMismatchWarningCase(TestBase):
-
-    mydir = os.path.join("warnings", "uuid")
-
-    @classmethod
-    def classCleanup(cls):
-        """Cleanup the test byproducts."""
-        cls.RemoveTempFile("child_send.txt")
-        cls.RemoveTempFile("child_read.txt")
-
-    def setUp(self):
-        TestBase.setUp(self)
-        self.template = 'main.cpp.template'
-        self.source = 'main.cpp'
-        self.teardown_hook_added = False
-
-    def test_uuid_mismatch_warning(self):
-        """Test that the 'warning: UUID mismatch detected ...' message is emitted."""
-
-        # Call the program generator to produce main.cpp, version 1.
-        self.generate_main_cpp(version=1)
-        self.line_to_break = line_number(self.source, '// Set breakpoint here.')
-        self.buildDsym(clean=True)
-
-        # Insert some delay and then call the program generator to produce main.cpp, version 2.
-        time.sleep(5)
-        self.generate_main_cpp(version=101)
-        # Now call make again, but this time don't generate the dSYM.
-        self.buildDwarf(clean=False)
-
-        self.exe_name = 'a.out'
-        self.check_executable_and_dsym(self.exe_name)
-
-    def generate_main_cpp(self, version=0):
-        """Generate main.cpp from main.cpp.template."""
-        temp = os.path.join(os.getcwd(), self.template)
-        with open(temp, 'r') as f:
-            content = f.read()
-
-        new_content = content.replace('%ADD_EXTRA_CODE%',
-                                      'printf("This is version %d\\n");' % version)
-        src = os.path.join(os.getcwd(), self.source)
-        with open(src, 'w') as f:
-            f.write(new_content)
-
-        # The main.cpp has been generated, add a teardown hook to remove it.
-        if not self.teardown_hook_added:
-            self.addTearDownHook(lambda: os.remove(src))
-            self.teardown_hook_added = True
-
-    def check_executable_and_dsym(self, exe_name):
-        """Sanity check executable compiled from the auto-generated program."""
-
-        # The default lldb prompt.
-        prompt = "(lldb) "
-
-        # So that the child gets torn down after the test.
-        self.child = pexpect.spawn('%s %s' % (self.lldbHere, self.lldbOption))
-        child = self.child
-        # Turn on logging for input/output to/from the child.
-        with open('child_send.txt', 'w') as f_send:
-            with open('child_read.txt', 'w') as f_read:
-                child.logfile_send = f_send
-                child.logfile_read = f_read
-
-                child.expect_exact(prompt)
-                child.setecho(True)
-
-                # Execute the file command, followed by a breakpoint set, the
-                # UUID mismatch warning should be generated by then.
-
-                child.sendline("file %s" % exe_name)
-                child.expect_exact(prompt)
-                child.sendline("breakpoint set -f %s -l %d" % (self.source, self.line_to_break))
-                child.expect_exact(prompt)
-                child.sendline("run")
-                child.expect_exact(prompt)
-
-        # Now that the necessary logging is done, restore logfile to None to
-        # stop further logging.
-        child.logfile_send = None
-        child.logfile_read = None
-        
-        with open('child_send.txt', 'r') as fs:
-            if self.TraceOn():
-                print "\n\nContents of child_send.txt:"
-                print fs.read()
-        with open('child_read.txt', 'r') as fr:
-            from_child = fr.read()
-            if self.TraceOn():
-                print "\n\nContents of child_read.txt:"
-                print from_child
-
-            # Test that lldb emits the "UUID mismatch detected" message.
-            self.expect(from_child, msg="UUID mismatch expected!", exe=False,
-                substrs = ['warning: UUID mismatch detected'])
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()





More information about the lldb-commits mailing list