[Lldb-commits] [lldb] r107100 - in /lldb/trunk: include/lldb/Core/ModuleList.h include/lldb/Core/Section.h source/Commands/CommandObjectImage.cpp source/Core/ModuleList.cpp source/Core/Section.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Greg Clayton gclayton at apple.com
Mon Jun 28 16:51:11 PDT 2010


Author: gclayton
Date: Mon Jun 28 18:51:11 2010
New Revision: 107100

URL: http://llvm.org/viewvc/llvm-project?rev=107100&view=rev
Log:
Fixed debug map in executable + DWARF in .o debugging on Mac OS X.

Added the ability to dump any file in the global module cache using any of
the "image dump" commands. This allows us to dump the .o files that are used
with DWARF + .o since they don't belong the the target list for the current
target.


Modified:
    lldb/trunk/include/lldb/Core/ModuleList.h
    lldb/trunk/include/lldb/Core/Section.h
    lldb/trunk/source/Commands/CommandObjectImage.cpp
    lldb/trunk/source/Core/ModuleList.cpp
    lldb/trunk/source/Core/Section.cpp
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/include/lldb/Core/ModuleList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=107100&r1=107099&r2=107100&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleList.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleList.h Mon Jun 28 18:51:11 2010
@@ -327,6 +327,13 @@
                      lldb::ModuleSP *old_module_sp_ptr,
                      bool *did_create_ptr);
 
+    static size_t
+    FindSharedModules (const FileSpec& in_file_spec,
+                       const ArchSpec& arch,
+                       const UUID *uuid_ptr,
+                       const ConstString *object_name_ptr,
+                       ModuleList &matching_module_list);
+
 protected:
     //------------------------------------------------------------------
     // Class typedefs.

Modified: lldb/trunk/include/lldb/Core/Section.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=107100&r1=107099&r2=107100&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Section.h (original)
+++ lldb/trunk/include/lldb/Core/Section.h Mon Jun 28 18:51:11 2010
@@ -51,9 +51,6 @@
     lldb::SectionSP
     FindSectionByName (const ConstString &section_dstr) const;
 
-//    lldb::SectionSP
-//    FindSectionByNames (const char *sect, ...) const;
-
     lldb::SectionSP
     FindSectionByID (lldb::user_id_t sect_id) const;
 
@@ -71,7 +68,10 @@
 
     // Get the number of sections in this list only
     size_t
-    GetSize () const;
+    GetSize () const
+    {
+        return m_sections.size();
+    }
 
     // Get the number of sections in this list, and any contained child sections
     size_t
@@ -122,10 +122,16 @@
     ContainsFileAddress (lldb::addr_t vm_addr) const;
 
     SectionList&
-    GetChildren ();
+    GetChildren ()
+    {
+        return m_children;
+    }
 
     const SectionList&
-    GetChildren () const;
+    GetChildren () const
+    {
+        return m_children;
+    }
 
     void
     Dump (Stream *s, Process *process) const;
@@ -140,31 +146,70 @@
     ResolveContainedAddress (lldb::addr_t offset, Address &so_addr) const;
 
     uint64_t
-    GetFileOffset () const;
+    GetFileOffset () const
+    {
+        return m_file_offset;
+    }
+
+    void
+    SetFileOffset (uint64_t file_offset) 
+    {
+        m_file_offset = file_offset;
+    }
 
     uint64_t
-    GetFileSize () const;
+    GetFileSize () const
+    {
+        return m_file_size;
+    }
+
+    void
+    SetFileSize (uint64_t file_size)
+    {
+        m_file_size = file_size;
+    }
 
     lldb::addr_t
     GetFileAddress () const;
 
     lldb::addr_t
-    GetOffset () const;
+    GetOffset () const
+    {
+        // This section has a parent which means m_file_addr is an offset.
+        if (m_parent)
+            return m_file_addr;
 
-    lldb::addr_t
-    GetByteSize () const;
+        // This section has no parent, so there is no offset to be had
+        return 0;
+    }
 
-    void
-    SetByteSize (lldb::addr_t byte_size);
 
+    lldb::addr_t
+    GetByteSize () const
+    {
+        return m_byte_size;
+    }
+    
+    void
+    SetByteSize (lldb::addr_t byte_size)
+    {
+        m_byte_size = byte_size;
+    }
+    
     size_t
     GetSectionDataFromImage (const DataExtractor& image_data, DataExtractor& section_data) const;
 
     bool
-    IsFake() const;
+    IsFake() const
+    {
+        return m_fake;
+    }
 
     void
-    SetIsFake(bool fake);
+    SetIsFake(bool fake)
+    {
+        m_fake = fake;
+    }
 
     bool
     IsDescendant (const Section *section);
@@ -191,10 +236,16 @@
     ContainsLinkedFileAddress (lldb::addr_t vm_addr) const;
 
     const Section *
-    GetLinkedSection () const;
+    GetLinkedSection () const
+    {
+        return m_linked_section;
+    }
 
     uint64_t
-    GetLinkedOffset () const;
+    GetLinkedOffset () const
+    {
+        return m_linked_offset;
+    }
 
     lldb::addr_t
     GetLinkedFileAddress () const;

Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=107100&r1=107099&r2=107100&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectImage.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectImage.cpp Mon Jun 28 18:51:11 2010
@@ -544,8 +544,18 @@
                 {
                     FileSpec image_file(arg_cstr);
                     ModuleList matching_modules;
-                    const size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules);
+                    size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules);
 
+                    // Not found in our module list for our target, check the main
+                    // shared module list in case it is a extra file used somewhere
+                    // else
+                    if (num_matching_modules == 0)
+                        num_matching_modules = ModuleList::FindSharedModules (image_file, 
+                                                                              target->GetArchitecture(), 
+                                                                              NULL, 
+                                                                              NULL, 
+                                                                              matching_modules);
+                    
                     if (num_matching_modules > 0)
                     {
                         for (size_t i=0; i<num_matching_modules; ++i)
@@ -642,8 +652,18 @@
                 {
                     FileSpec image_file(arg_cstr);
                     ModuleList matching_modules;
-                    const size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules);
+                    size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules);
 
+                    // Not found in our module list for our target, check the main
+                    // shared module list in case it is a extra file used somewhere
+                    // else
+                    if (num_matching_modules == 0)
+                        num_matching_modules = ModuleList::FindSharedModules (image_file, 
+                                                                              target->GetArchitecture(), 
+                                                                              NULL, 
+                                                                              NULL, 
+                                                                              matching_modules);
+                    
                     if (num_matching_modules > 0)
                     {
                         for (size_t i=0; i<num_matching_modules; ++i)
@@ -739,8 +759,18 @@
                 {
                     FileSpec image_file(arg_cstr);
                     ModuleList matching_modules;
-                    const size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules);
+                    size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules);
 
+                    // Not found in our module list for our target, check the main
+                    // shared module list in case it is a extra file used somewhere
+                    // else
+                    if (num_matching_modules == 0)
+                        num_matching_modules = ModuleList::FindSharedModules (image_file, 
+                                                                              target->GetArchitecture(), 
+                                                                              NULL, 
+                                                                              NULL, 
+                                                                              matching_modules);
+                    
                     if (num_matching_modules > 0)
                     {
                         for (size_t i=0; i<num_matching_modules; ++i)
@@ -1343,8 +1373,18 @@
                 {
                     FileSpec image_file(arg_cstr);
                     ModuleList matching_modules;
-                    const size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules);
+                    size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules);
 
+                    // Not found in our module list for our target, check the main
+                    // shared module list in case it is a extra file used somewhere
+                    // else
+                    if (num_matching_modules == 0)
+                        num_matching_modules = ModuleList::FindSharedModules (image_file, 
+                                                                              target->GetArchitecture(), 
+                                                                              NULL, 
+                                                                              NULL, 
+                                                                              matching_modules);
+                    
                     if (num_matching_modules > 0)
                     {
                         for (size_t i=0; i<num_matching_modules; ++i)

Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=107100&r1=107099&r2=107100&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Mon Jun 28 18:51:11 2010
@@ -437,6 +437,20 @@
     return module_sp;
 }
 
+size_t
+ModuleList::FindSharedModules 
+(
+    const FileSpec& in_file_spec,
+    const ArchSpec& arch,
+    const UUID *uuid_ptr,
+    const ConstString *object_name_ptr,
+    ModuleList &matching_module_list
+)
+{
+    ModuleList &shared_module_list = GetSharedModuleList ();
+    Mutex::Locker locker(shared_module_list.m_modules_mutex);
+    return shared_module_list.FindModules (&in_file_spec, &arch, uuid_ptr, object_name_ptr, matching_module_list);
+}
 
 Error
 ModuleList::GetSharedModule

Modified: lldb/trunk/source/Core/Section.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=107100&r1=107099&r2=107100&view=diff
==============================================================================
--- lldb/trunk/source/Core/Section.cpp (original)
+++ lldb/trunk/source/Core/Section.cpp Mon Jun 28 18:51:11 2010
@@ -45,32 +45,6 @@
 {
 }
 
-//Section::Section
-//(
-//    Section *parent,
-//    Module* module,
-//    user_id_t sect_id,
-//    const ConstString &name,
-//    const AddressRange *file_vm_range,
-//    uint64_t file_offset,
-//    uint64_t file_size,
-//    uint32_t flags
-//) :
-//    ModuleChild     (module),
-//    UserID          (sect_id),
-//    Flags           (flags),
-//    m_parent        (parent),
-//    m_name          (name),
-//    m_range (),
-//    m_file_offset   (file_offset),
-//    m_file_size     (file_size),
-//    m_children      (),
-//    m_fake          (false)
-//{
-//    if (file_vm_range)
-//        m_range = *file_vm_range;
-//}
-
 Section::~Section()
 {
 }
@@ -114,18 +88,6 @@
     return m_name;
 }
 
-SectionList&
-Section::GetChildren()
-{
-    return m_children;
-}
-
-const SectionList&
-Section::GetChildren() const
-{
-    return m_children;
-}
-
 addr_t
 Section::GetFileAddress () const
 {
@@ -148,31 +110,6 @@
     return LLDB_INVALID_ADDRESS;
 }
 
-addr_t
-Section::GetOffset () const
-{
-    if (m_parent)
-    {
-        // This section has a parent which means m_file_addr is an offset.
-        return m_file_addr;
-    }
-
-    // This section has no parent, so there is no offset to be had
-    return 0;
-}
-
-addr_t
-Section::GetByteSize () const
-{
-    return m_byte_size;
-}
-
-void
-Section::SetByteSize (addr_t byte_size)
-{
-    m_byte_size = byte_size;
-}
-
 
 addr_t
 Section::GetLoadBaseAddress (Process *process) const
@@ -225,18 +162,6 @@
     return true;
 }
 
-uint64_t
-Section::GetFileOffset() const
-{
-    return m_file_offset;
-}
-
-uint64_t
-Section::GetFileSize() const
-{
-    return m_file_size;
-}
-
 bool
 Section::ContainsFileAddress (addr_t vm_addr) const
 {
@@ -449,19 +374,6 @@
 }
 
 bool
-Section::IsFake() const
-{
-    return m_fake;
-}
-
-void
-Section::SetIsFake(bool fake)
-{
-    m_fake = fake;
-}
-
-
-bool
 Section::IsDescendant (const Section *section)
 {
     if (this == section)
@@ -498,18 +410,6 @@
     m_linked_offset  = linked_offset;
 }
 
-const Section *
-Section::GetLinkedSection () const
-{
-    return m_linked_section;
-}
-
-uint64_t
-Section::GetLinkedOffset () const
-{
-    return m_linked_offset;
-}
-
 #pragma mark SectionList
 
 SectionList::SectionList () :
@@ -579,12 +479,6 @@
 
 
 size_t
-SectionList::GetSize () const
-{
-    return m_sections.size();
-}
-
-size_t
 SectionList::GetNumSections (uint32_t depth) const
 {
     size_t count = m_sections.size();
@@ -631,21 +525,6 @@
     }
     return sect_sp;
 }
-//
-//SectionSP
-//SectionList::FindSectionByNames (const char *s, ...) const
-//{
-//    SectionSP sect_sp;
-//    va_list ap;
-//    va_start(ap, s);
-//    uint32_t idx = 0;
-//    for (const char *sect_name = s; sect_name != NULL; sect_name = va_arg(ap, const char *))
-//    {
-//        printf("[%u] %s\n", idx++, sect_name);
-//    }
-//    va_end(ap);
-//    return sect_sp;
-//}
 
 SectionSP
 SectionList::FindSectionByID (user_id_t sect_id) const

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=107100&r1=107099&r2=107100&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Mon Jun 28 18:51:11 2010
@@ -341,6 +341,20 @@
                                     segment->GetChildren().Slide (-slide_amount, false);
                                     segment->SetByteSize (curr_seg_max_addr - sect64_min_addr);
                                 }
+
+                                // Grow the section size as needed.
+                                if (sect64.offset)
+                                {
+                                    const lldb::addr_t segment_min_file_offset = segment->GetFileOffset();
+                                    const lldb::addr_t segment_max_file_offset = segment_min_file_offset + segment->GetFileSize();
+
+                                    const lldb::addr_t section_min_file_offset = sect64.offset;
+                                    const lldb::addr_t section_max_file_offset = section_min_file_offset + sect64.size;
+                                    const lldb::addr_t new_file_offset = std::min (section_min_file_offset, segment_min_file_offset);
+                                    const lldb::addr_t new_file_size = std::max (section_max_file_offset, segment_max_file_offset) - new_file_offset;
+                                    segment->SetFileOffset (new_file_offset);
+                                    segment->SetFileSize (new_file_size);
+                                }
                             }
                             else
                             {





More information about the lldb-commits mailing list