summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Module.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-07-10 01:23:25 +0000
committerGreg Clayton <gclayton@apple.com>2013-07-10 01:23:25 +0000
commit3046e668301ec9df4ead087fdc906877b9dcbf82 (patch)
treeff149c296cddf3415649f2571282ef53b3554fbd /lldb/source/Core/Module.cpp
parent8978a9dd0a42139809f56b6df47a0663f341918b (diff)
downloadbcm5719-llvm-3046e668301ec9df4ead087fdc906877b9dcbf82.tar.gz
bcm5719-llvm-3046e668301ec9df4ead087fdc906877b9dcbf82.zip
Cleanup on the unified section list changes. Main changes are:
- ObjectFile::GetSymtab() and ObjectFile::ClearSymtab() no longer takes any flags - Module coordinates with the object files and contain a unified section list so that object file and symbol file can share sections when they need to, yet contain their own sections. Other cleanups: - Fixed Symbol::GetByteSize() to not have the symbol table compute the byte sizes on the fly - Modified the ObjectFileMachO class to compute symbol sizes all at once efficiently - Modified the Symtab class to store a file address lookup table for more efficient lookups - Removed Section::Finalize() and SectionList::Finalize() as they did nothing - Improved performance of the detection of symbol files that have debug maps by excluding stripped files and core files, debug files, object files and stubs - Added the ability to tell if an ObjectFile has been stripped with ObjectFile::IsStripped() (used this for the above performance improvement) llvm-svn: 185990
Diffstat (limited to 'lldb/source/Core/Module.cpp')
-rw-r--r--lldb/source/Core/Module.cpp72
1 files changed, 37 insertions, 35 deletions
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index e5df43287d1..f8e2f8871cb 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -245,7 +245,7 @@ Module::~Module()
// function calls back into this module object. The ordering is important
// here because symbol files can require the module object file. So we tear
// down the symbol file first, then the object file.
- m_unified_sections_ap.reset();
+ m_sections_ap.reset();
m_symfile_ap.reset();
m_objfile_sp.reset();
}
@@ -441,9 +441,9 @@ Module::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr)
{
Mutex::Locker locker (m_mutex);
Timer scoped_timer(__PRETTY_FUNCTION__, "Module::ResolveFileAddress (vm_addr = 0x%" PRIx64 ")", vm_addr);
- ObjectFile* ofile = GetObjectFile();
- if (ofile)
- return so_addr.ResolveAddressUsingFileSections(vm_addr, ofile->GetSectionList());
+ SectionList *section_list = GetSectionList();
+ if (section_list)
+ return so_addr.ResolveAddressUsingFileSections(vm_addr, section_list);
return false;
}
@@ -1114,24 +1114,31 @@ Module::GetObjectFile()
// architecture since it might differ in vendor/os if some parts were
// unknown.
m_objfile_sp->GetArchitecture (m_arch);
-
- // Populate m_unified_sections_ap with sections from objfile.
- SectionList *section_list = m_objfile_sp->GetSectionList();
- if (section_list)
- {
- m_unified_sections_ap.reset(new SectionList());
- section_list->Copy (m_unified_sections_ap.get());
- m_unified_sections_ap->Finalize();
- }
}
}
return m_objfile_sp.get();
}
SectionList *
+Module::GetSectionList()
+{
+ // Populate m_unified_sections_ap with sections from objfile.
+ if (m_sections_ap.get() == NULL)
+ {
+ ObjectFile *obj_file = GetObjectFile();
+ if (obj_file)
+ obj_file->CreateSections(*GetUnifiedSectionList());
+ }
+ return m_sections_ap.get();
+}
+
+SectionList *
Module::GetUnifiedSectionList()
{
- return m_unified_sections_ap.get();
+ // Populate m_unified_sections_ap with sections from objfile.
+ if (m_sections_ap.get() == NULL)
+ m_sections_ap.reset(new SectionList());
+ return m_sections_ap.get();
}
const Symbol *
@@ -1246,7 +1253,7 @@ Module::SetSymbolFileFileSpec (const FileSpec &file)
// Remove any sections in the unified section list that come from the current symbol vendor.
if (m_symfile_ap)
{
- SectionList *section_list = GetUnifiedSectionList();
+ SectionList *section_list = GetSectionList();
SymbolFile *symbol_file = m_symfile_ap->GetSymbolFile();
if (section_list && symbol_file)
{
@@ -1259,10 +1266,9 @@ Module::SetSymbolFileFileSpec (const FileSpec &file)
lldb::SectionSP section_sp (section_list->GetSectionAtIndex (idx - 1));
if (section_sp->GetObjectFile() == obj_file)
{
- m_unified_sections_ap->DeleteSection (idx - 1);
+ section_list->DeleteSection (idx - 1);
}
}
- m_unified_sections_ap->Finalize();
}
}
}
@@ -1287,7 +1293,7 @@ Module::IsLoadedInTarget (Target *target)
ObjectFile *obj_file = GetObjectFile();
if (obj_file)
{
- SectionList *sections = obj_file->GetSectionList();
+ SectionList *sections = GetSectionList();
if (sections != NULL)
{
size_t num_sections = sections->GetSize();
@@ -1394,26 +1400,22 @@ bool
Module::SetLoadAddress (Target &target, lldb::addr_t offset, bool &changed)
{
size_t num_loaded_sections = 0;
- ObjectFile *objfile = GetObjectFile();
- if (objfile)
+ SectionList *section_list = GetSectionList ();
+ if (section_list)
{
- SectionList *section_list = objfile->GetSectionList ();
- if (section_list)
+ const size_t num_sections = section_list->GetSize();
+ size_t sect_idx = 0;
+ for (sect_idx = 0; sect_idx < num_sections; ++sect_idx)
{
- const size_t num_sections = section_list->GetSize();
- size_t sect_idx = 0;
- for (sect_idx = 0; sect_idx < num_sections; ++sect_idx)
+ // Iterate through the object file sections to find the
+ // first section that starts of file offset zero and that
+ // has bytes in the file...
+ SectionSP section_sp (section_list->GetSectionAtIndex (sect_idx));
+ // Only load non-thread specific sections when given a slide
+ if (section_sp && !section_sp->IsThreadSpecific())
{
- // Iterate through the object file sections to find the
- // first section that starts of file offset zero and that
- // has bytes in the file...
- SectionSP section_sp (section_list->GetSectionAtIndex (sect_idx));
- // Only load non-thread specific sections when given a slide
- if (section_sp && !section_sp->IsThreadSpecific())
- {
- if (target.GetSectionLoadList().SetSectionLoadAddress (section_sp, section_sp->GetFileAddress() + offset))
- ++num_loaded_sections;
- }
+ if (target.GetSectionLoadList().SetSectionLoadAddress (section_sp, section_sp->GetFileAddress() + offset))
+ ++num_loaded_sections;
}
}
}
OpenPOWER on IntegriCloud