[Lldb-commits] [lldb] r185990 - Cleanup on the unified section list changes. Main changes are:
Greg Clayton
gclayton at apple.com
Tue Jul 9 18:23:25 PDT 2013
Author: gclayton
Date: Tue Jul 9 20:23:25 2013
New Revision: 185990
URL: http://llvm.org/viewvc/llvm-project?rev=185990&view=rev
Log:
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)
Modified:
lldb/trunk/include/lldb/Core/Module.h
lldb/trunk/include/lldb/Core/RangeMap.h
lldb/trunk/include/lldb/Core/Section.h
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/include/lldb/Symbol/Symbol.h
lldb/trunk/include/lldb/Symbol/SymbolVendor.h
lldb/trunk/include/lldb/Symbol/Symtab.h
lldb/trunk/source/API/SBModule.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Core/Section.cpp
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.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/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
lldb/trunk/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
lldb/trunk/source/Symbol/ObjectFile.cpp
lldb/trunk/source/Symbol/Symbol.cpp
lldb/trunk/source/Symbol/SymbolFile.cpp
lldb/trunk/source/Symbol/SymbolVendor.cpp
lldb/trunk/source/Symbol/Symtab.cpp
Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Tue Jul 9 20:23:25 2013
@@ -651,8 +651,8 @@ public:
/// Unified module section list.
//------------------------------------------------------------------
virtual SectionList *
- GetUnifiedSectionList ();
-
+ GetSectionList ();
+
uint32_t
GetVersion (uint32_t *versions, uint32_t num_versions);
@@ -1000,7 +1000,7 @@ protected:
std::unique_ptr<SymbolVendor> m_symfile_ap; ///< A pointer to the symbol vendor for this module.
ClangASTContext m_ast; ///< The AST context for this module.
PathMappingList m_source_mappings; ///< Module specific source remappings for when you have debug info for a module that doesn't match where the sources currently are
- std::unique_ptr<lldb_private::SectionList> m_unified_sections_ap; ///< Unified section list for module.
+ std::unique_ptr<lldb_private::SectionList> m_sections_ap; ///< Unified section list for module that is used by the ObjectFile and and ObjectFile instances for the debug info
bool m_did_load_objfile:1,
m_did_load_symbol_vendor:1,
@@ -1059,9 +1059,12 @@ protected:
bool
SetArchitecture (const ArchSpec &new_arch);
-
+ SectionList *
+ GetUnifiedSectionList();
+
friend class ModuleList;
friend class ObjectFile;
+ friend class SymbolFile;
private:
Modified: lldb/trunk/include/lldb/Core/RangeMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RangeMap.h?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/RangeMap.h (original)
+++ lldb/trunk/include/lldb/Core/RangeMap.h Tue Jul 9 20:23:25 2013
@@ -1138,6 +1138,39 @@ namespace lldb_private {
}
}
+ // Calculate the byte size of ranges with zero byte sizes by finding
+ // the next entry with a base address > the current base address
+ void
+ CalculateSizesOfZeroByteSizeRanges ()
+ {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert (IsSorted());
+#endif
+ typename Collection::iterator pos;
+ typename Collection::iterator end;
+ typename Collection::iterator next;
+ for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
+ {
+ if (pos->GetByteSize() == 0)
+ {
+ // Watch out for multiple entries with same address and make sure
+ // we find an entry that is greater than the current base address
+ // before we use that for the size
+ auto curr_base = pos->GetRangeBase();
+ for (next = pos + 1; next != end; ++next)
+ {
+ auto next_base = next->GetRangeBase();
+ if (next_base > curr_base)
+ {
+ pos->SetByteSize (next_base - curr_base);
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
void
Clear ()
{
Modified: lldb/trunk/include/lldb/Core/Section.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Section.h (original)
+++ lldb/trunk/include/lldb/Core/Section.h Tue Jul 9 20:23:25 2013
@@ -34,8 +34,8 @@ public:
~SectionList();
- bool
- Copy (SectionList* dest_section_list);
+ SectionList &
+ operator =(const SectionList& rhs);
size_t
AddSection (const lldb::SectionSP& section_sp);
@@ -91,17 +91,6 @@ public:
size_t
Slide (lldb::addr_t slide_amount, bool slide_children);
- // Update all section lookup caches
- void
- Finalize ();
-
- // Each time Finalize() is called with changes, revision id increments.
- uint32_t
- GetRevisionID() const
- {
- return m_revision_id;
- }
-
void
Clear ()
{
@@ -109,8 +98,6 @@ public:
}
protected:
- bool m_changed;
- uint32_t m_revision_id;
collection m_sections;
};
@@ -283,13 +270,6 @@ public:
m_thread_specific = b;
}
- // Update all section lookup caches
- void
- Finalize ()
- {
- m_children.Finalize();
- }
-
ObjectFile *
GetObjectFile ()
{
Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Tue Jul 9 20:23:25 2013
@@ -80,11 +80,6 @@ public:
eStrataRawImage
} Strata;
- typedef enum
- {
- eSymtabFromUnifiedSectionList = 0x0001 /// Return symbol table from unified module section list
- } SymtabFlags;
-
//------------------------------------------------------------------
/// Construct with a parent module, offset, and header data.
///
@@ -353,7 +348,10 @@ public:
/// The list of sections contained in this object file.
//------------------------------------------------------------------
virtual SectionList *
- GetSectionList () = 0;
+ GetSectionList ();
+
+ virtual void
+ CreateSections (SectionList &unified_section_list) = 0;
//------------------------------------------------------------------
/// Gets the symbol table for the currently selected architecture
@@ -362,15 +360,21 @@ public:
/// Symbol table parsing can be deferred by ObjectFile instances
/// until this accessor is called the first time.
///
- /// @param[in] flags
- /// eSymtabFromUnifiedSectionList: Whether to get symbol table
- /// for unified module section list, or object file.
- ///
/// @return
/// The symbol table for this object file.
//------------------------------------------------------------------
virtual Symtab *
- GetSymtab (uint32_t flags = 0) = 0;
+ GetSymtab () = 0;
+
+ //------------------------------------------------------------------
+ /// Detect if this object file has been stripped of local symbols.
+ ///
+ /// @return
+ /// Return \b true if the object file has been stripped of local
+ /// symbols.
+ //------------------------------------------------------------------
+ virtual bool
+ IsStripped () = 0;
//------------------------------------------------------------------
/// Frees the symbol table.
@@ -385,7 +389,7 @@ public:
/// The symbol table for this object file.
//------------------------------------------------------------------
virtual void
- ClearSymtab (uint32_t flags = 0);
+ ClearSymtab ();
//------------------------------------------------------------------
/// Gets the UUID for this object file.
@@ -676,8 +680,6 @@ protected:
const lldb::addr_t m_memory_addr;
std::unique_ptr<lldb_private::SectionList> m_sections_ap;
std::unique_ptr<lldb_private::Symtab> m_symtab_ap;
- std::unique_ptr<lldb_private::Symtab> m_symtab_unified_ap; ///< Unified section list symbol table.
- uint32_t m_symtab_unified_revisionid; ///< Unified section list symbol table revision id for when m_symtab_unified_ap was last modified.
//------------------------------------------------------------------
/// Sets the architecture for a module. At present the architecture
Modified: lldb/trunk/include/lldb/Symbol/Symbol.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Symbol.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symbol.h Tue Jul 9 20:23:25 2013
@@ -210,13 +210,19 @@ public:
bool
IsIndirect () const;
+ bool
+ GetByteSizeIsValid () const
+ {
+ return m_size_is_valid;
+ }
+
lldb::addr_t
GetByteSize () const;
void
SetByteSize (lldb::addr_t size)
{
- m_calculated_size = size > 0;
+ m_size_is_valid = size > 0;
m_addr_range.SetByteSize(size);
}
@@ -298,7 +304,7 @@ protected:
m_is_external:1, // non-zero if this symbol is globally visible
m_size_is_sibling:1, // m_size contains the index of this symbol's sibling
m_size_is_synthesized:1,// non-zero if this symbol's size was calculated using a delta between this symbol and the next
- m_calculated_size:1,
+ m_size_is_valid:1,
m_demangled_is_synthesized:1, // The demangled name was created should not be used for expressions or other lookups
m_type:8;
Mangled m_mangled; // uniqued symbol name/mangled name pair
Modified: lldb/trunk/include/lldb/Symbol/SymbolVendor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolVendor.h?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolVendor.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolVendor.h Tue Jul 9 20:23:25 2013
@@ -38,7 +38,7 @@ class SymbolVendor :
public:
static SymbolVendor*
FindPlugin (const lldb::ModuleSP &module_sp,
- lldb_private::Stream *feedback_strm);
+ Stream *feedback_strm);
//------------------------------------------------------------------
// Constructors and Destructors
@@ -126,7 +126,7 @@ public:
size_t max_matches,
TypeList& types);
- virtual lldb_private::ClangNamespaceDecl
+ virtual ClangNamespaceDecl
FindNamespace (const SymbolContext& sc,
const ConstString &name,
const ClangNamespaceDecl *parent_namespace_decl);
@@ -154,9 +154,9 @@ public:
}
virtual size_t
- GetTypes (lldb_private::SymbolContextScope *sc_scope,
+ GetTypes (SymbolContextScope *sc_scope,
uint32_t type_mask,
- lldb_private::TypeList &type_list);
+ TypeList &type_list);
SymbolFile *
GetSymbolFile()
@@ -175,7 +175,7 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
+ virtual ConstString
GetPluginName();
virtual uint32_t
Modified: lldb/trunk/include/lldb/Symbol/Symtab.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Symtab.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symtab.h Tue Jul 9 20:23:25 2013
@@ -14,6 +14,7 @@
#include <vector>
#include "lldb/lldb-private.h"
+#include "lldb/Core/RangeMap.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/Symbol.h"
@@ -72,7 +73,7 @@ public:
Symbol * FindSymbolContainingFileAddress (lldb::addr_t file_addr, const uint32_t* indexes, uint32_t num_indexes);
Symbol * FindSymbolContainingFileAddress (lldb::addr_t file_addr);
size_t FindFunctionSymbols (const ConstString &name, uint32_t name_type_mask, SymbolContextList& sc_list);
- size_t CalculateSymbolSize (Symbol *symbol);
+ void CalculateSymbolSizes ();
void SortSymbolIndexesByValue (std::vector<uint32_t>& indexes, bool remove_duplicates) const;
@@ -98,19 +99,19 @@ protected:
typedef std::vector<Symbol> collection;
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
-
+ typedef RangeDataVector<lldb::addr_t, lldb::addr_t, uint32_t> FileRangeToIndexMap;
void InitNameIndexes ();
void InitAddressIndexes ();
ObjectFile * m_objfile;
collection m_symbols;
- std::vector<uint32_t> m_addr_indexes;
+ FileRangeToIndexMap m_file_addr_to_index;
UniqueCStringMap<uint32_t> m_name_to_index;
UniqueCStringMap<uint32_t> m_basename_to_index;
UniqueCStringMap<uint32_t> m_method_to_index;
UniqueCStringMap<uint32_t> m_selector_to_index;
mutable Mutex m_mutex; // Provide thread safety for this symbol table
- bool m_addr_indexes_computed:1,
+ bool m_file_addr_to_index_computed:1,
m_name_indexes_computed:1;
private:
Modified: lldb/trunk/source/API/SBModule.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/API/SBModule.cpp (original)
+++ lldb/trunk/source/API/SBModule.cpp Tue Jul 9 20:23:25 2013
@@ -406,7 +406,7 @@ SBModule::GetNumSections ()
{
// Give the symbol vendor a chance to add to the unified section list.
module_sp->GetSymbolVendor();
- SectionList *section_list = module_sp->GetUnifiedSectionList();
+ SectionList *section_list = module_sp->GetSectionList();
if (section_list)
return section_list->GetSize();
}
@@ -422,7 +422,7 @@ SBModule::GetSectionAtIndex (size_t idx)
{
// Give the symbol vendor a chance to add to the unified section list.
module_sp->GetSymbolVendor();
- SectionList *section_list = module_sp->GetUnifiedSectionList ();
+ SectionList *section_list = module_sp->GetSectionList ();
if (section_list)
sb_section.SetSP(section_list->GetSectionAtIndex (idx));
@@ -587,7 +587,7 @@ SBModule::FindSection (const char *sect_
{
// Give the symbol vendor a chance to add to the unified section list.
module_sp->GetSymbolVendor();
- SectionList *section_list = module_sp->GetUnifiedSectionList();
+ SectionList *section_list = module_sp->GetSectionList();
if (section_list)
{
ConstString const_sect_name(sect_name);
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Jul 9 20:23:25 2013
@@ -1453,7 +1453,7 @@ DumpModuleSections (CommandInterpreter &
{
if (module)
{
- SectionList *section_list = module->GetUnifiedSectionList();
+ SectionList *section_list = module->GetSectionList();
if (section_list)
{
strm.Printf ("Sections for '%s' (%s):\n",
@@ -2804,7 +2804,7 @@ protected:
ObjectFile *objfile = module->GetObjectFile();
if (objfile)
{
- SectionList *section_list = objfile->GetSectionList();
+ SectionList *section_list = module->GetSectionList();
if (section_list)
{
bool changed = false;
Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Tue Jul 9 20:23:25 2013
@@ -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
{
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 Fil
// 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 Fil
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;
}
}
}
Modified: lldb/trunk/source/Core/Section.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Core/Section.cpp (original)
+++ lldb/trunk/source/Core/Section.cpp Tue Jul 9 20:23:25 2013
@@ -292,8 +292,6 @@ Section::Slide (addr_t slide_amount, boo
#pragma mark SectionList
SectionList::SectionList () :
- m_changed(false),
- m_revision_id(0),
m_sections()
{
}
@@ -303,22 +301,17 @@ SectionList::~SectionList ()
{
}
-bool
-SectionList::Copy (SectionList *dest_section_list)
+SectionList &
+SectionList::operator = (const SectionList& rhs)
{
- if (dest_section_list)
- {
- dest_section_list->m_sections = m_sections;
- dest_section_list->m_changed = true;
- return true;
- }
- return false;
+ if (this != &rhs)
+ m_sections = rhs.m_sections;
+ return *this;
}
size_t
SectionList::AddSection (const lldb::SectionSP& section_sp)
{
- m_changed = true;
assert (section_sp.get());
size_t section_index = m_sections.size();
m_sections.push_back(section_sp);
@@ -331,7 +324,6 @@ SectionList::DeleteSection (size_t idx)
{
if (idx < m_sections.size())
{
- m_changed = true;
m_sections.erase (m_sections.begin() + idx);
return true;
}
@@ -361,7 +353,6 @@ SectionList::AddUniqueSection (const lld
size_t sect_idx = FindSectionIndex (sect_sp.get());
if (sect_idx == UINT32_MAX)
{
- m_changed = true;
sect_idx = AddSection (sect_sp);
}
return sect_idx;
@@ -375,7 +366,6 @@ SectionList::ReplaceSection (user_id_t s
{
if ((*sect_iter)->GetID() == sect_id)
{
- m_changed = true;
*sect_iter = sect_sp;
return true;
}
@@ -552,22 +542,3 @@ SectionList::Slide (addr_t slide_amount,
}
return count;
}
-
-void
-SectionList::Finalize ()
-{
- for (const_iterator si = m_sections.begin(), se = m_sections.end();
- si != se;
- ++si)
- {
- Section *sect = si->get();
-
- sect->GetChildren().Finalize();
- }
-
- if (m_changed)
- {
- m_revision_id++;
- m_changed = false;
- }
-}
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Jul 9 20:23:25 2013
@@ -1524,13 +1524,8 @@ ClangExpressionDeclMap::GetVariableValue
if (!var_sc.module_sp)
return NULL;
-
- ObjectFile *object_file = var_sc.module_sp->GetObjectFile();
-
- if (!object_file)
- return NULL;
-
- Address so_addr(var_location->GetScalar().ULongLong(), object_file->GetSectionList());
+
+ Address so_addr(var_location->GetScalar().ULongLong(), var_sc.module_sp->GetSectionList());
lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Tue Jul 9 20:23:25 2013
@@ -312,7 +312,7 @@ AppleObjCRuntime::GetObjCVersion (Proces
if (!ofile)
return eObjC_VersionUnknown;
- SectionList *sections = ofile->GetSectionList();
+ SectionList *sections = module_sp->GetSectionList();
if (!sections)
return eObjC_VersionUnknown;
SectionSP v1_telltale_section_sp = sections->FindSectionByName(ConstString ("__OBJC"));
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Tue Jul 9 20:23:25 2013
@@ -2189,7 +2189,7 @@ AppleObjCRuntimeV2::GetSharedCacheReadOn
if (objc_object)
{
- SectionList *section_list = objc_object->GetSectionList();
+ SectionList *section_list = objc_module_sp->GetSectionList();
if (section_list)
{
Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Tue Jul 9 20:23:25 2013
@@ -513,22 +513,6 @@ ObjectFileELF::GetDependentModules(FileS
return num_specs;
}
-user_id_t
-ObjectFileELF::GetSectionIndexByType(unsigned type)
-{
- if (!ParseSectionHeaders())
- return 0;
-
- for (SectionHeaderCollIter sh_pos = m_section_headers.begin();
- sh_pos != m_section_headers.end(); ++sh_pos)
- {
- if (sh_pos->sh_type == type)
- return SectionIndex(sh_pos);
- }
-
- return 0;
-}
-
Address
ObjectFileELF::GetImageInfoAddress()
{
@@ -539,28 +523,27 @@ ObjectFileELF::GetImageInfoAddress()
if (!section_list)
return Address();
- user_id_t dynsym_id = GetSectionIndexByType(SHT_DYNAMIC);
- if (!dynsym_id)
+ // Find the SHT_DYNAMIC (.dynamic) section.
+ SectionSP dynsym_section_sp (section_list->FindSectionByType (eSectionTypeELFDynamicLinkInfo, true));
+ if (!dynsym_section_sp)
return Address();
+ assert (dynsym_section_sp->GetObjectFile() == this);
+ user_id_t dynsym_id = dynsym_section_sp->GetID();
const ELFSectionHeaderInfo *dynsym_hdr = GetSectionHeaderByIndex(dynsym_id);
if (!dynsym_hdr)
return Address();
- SectionSP dynsym_section_sp (section_list->FindSectionByID(dynsym_id));
- if (dynsym_section_sp)
+ for (size_t i = 0; i < m_dynamic_symbols.size(); ++i)
{
- for (size_t i = 0; i < m_dynamic_symbols.size(); ++i)
- {
- ELFDynamic &symbol = m_dynamic_symbols[i];
+ ELFDynamic &symbol = m_dynamic_symbols[i];
- if (symbol.d_tag == DT_DEBUG)
- {
- // Compute the offset as the number of previous entries plus the
- // size of d_tag.
- addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize();
- return Address(dynsym_section_sp, offset);
- }
+ if (symbol.d_tag == DT_DEBUG)
+ {
+ // Compute the offset as the number of previous entries plus the
+ // size of d_tag.
+ addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize();
+ return Address(dynsym_section_sp, offset);
}
}
@@ -570,26 +553,19 @@ ObjectFileELF::GetImageInfoAddress()
lldb_private::Address
ObjectFileELF::GetEntryPointAddress ()
{
- SectionList *sections;
- addr_t offset;
-
if (m_entry_point_address.IsValid())
return m_entry_point_address;
if (!ParseHeader() || !IsExecutable())
return m_entry_point_address;
- sections = GetSectionList();
- offset = m_header.e_entry;
+ SectionList *section_list = GetSectionList();
+ addr_t offset = m_header.e_entry;
- if (!sections)
- {
+ if (!section_list)
m_entry_point_address.SetOffset(offset);
- return m_entry_point_address;
- }
-
- m_entry_point_address.ResolveAddressUsingFileSections(offset, sections);
-
+ else
+ m_entry_point_address.ResolveAddressUsingFileSections(offset, section_list);
return m_entry_point_address;
}
@@ -607,32 +583,22 @@ ObjectFileELF::ParseDependentModules()
if (!ParseSectionHeaders())
return 0;
- // Locate the dynamic table.
- user_id_t dynsym_id = 0;
- user_id_t dynstr_id = 0;
- for (SectionHeaderCollIter sh_pos = m_section_headers.begin();
- sh_pos != m_section_headers.end(); ++sh_pos)
- {
- if (sh_pos->sh_type == SHT_DYNAMIC)
- {
- dynsym_id = SectionIndex(sh_pos);
- dynstr_id = sh_pos->sh_link + 1; // Section ID's are 1 based.
- break;
- }
- }
-
- if (!(dynsym_id && dynstr_id))
- return 0;
-
SectionList *section_list = GetSectionList();
if (!section_list)
return 0;
- // Resolve and load the dynamic table entries and corresponding string
- // table.
- Section *dynsym = section_list->FindSectionByID(dynsym_id).get();
- Section *dynstr = section_list->FindSectionByID(dynstr_id).get();
- if (!(dynsym && dynstr))
+ // Find the SHT_DYNAMIC section.
+ Section *dynsym = section_list->FindSectionByType (eSectionTypeELFDynamicLinkInfo, true).get();
+ if (!dynsym)
+ return 0;
+ assert (dynsym->GetObjectFile() == this);
+
+ const ELFSectionHeaderInfo *header = GetSectionHeaderByIndex (dynsym->GetID());
+ if (!header)
+ return 0;
+ // sh_link: section header index of string table used by entries in the section.
+ Section *dynstr = section_list->FindSectionByID (header->sh_link + 1).get();
+ if (!dynstr)
return 0;
DataExtractor dynsym_data;
@@ -844,30 +810,6 @@ ObjectFileELF::ParseSectionHeaders()
return GetSectionHeaderInfo(m_section_headers, m_data, m_header, m_uuid, m_gnu_debuglink_file, m_gnu_debuglink_crc);
}
-lldb::user_id_t
-ObjectFileELF::GetSectionIndexByName(const char *name)
-{
- if (!ParseSectionHeaders())
- return 0;
-
- // Search the collection of section headers for one with a matching name.
- for (SectionHeaderCollIter I = m_section_headers.begin();
- I != m_section_headers.end(); ++I)
- {
- const char *sectionName = I->section_name.AsCString();
-
- if (!sectionName)
- return 0;
-
- if (strcmp(name, sectionName) != 0)
- continue;
-
- return SectionIndex(I);
- }
-
- return 0;
-}
-
const ObjectFileELF::ELFSectionHeaderInfo *
ObjectFileELF::GetSectionHeaderByIndex(lldb::user_id_t id)
{
@@ -880,14 +822,10 @@ ObjectFileELF::GetSectionHeaderByIndex(l
return NULL;
}
-
-SectionList *
-ObjectFileELF::GetSectionList()
+void
+ObjectFileELF::CreateSections(SectionList &unified_section_list)
{
- if (m_sections_ap.get())
- return m_sections_ap.get();
-
- if (ParseSectionHeaders())
+ if (!m_sections_ap.get() && ParseSectionHeaders())
{
m_sections_ap.reset(new SectionList());
@@ -982,40 +920,75 @@ ObjectFileELF::GetSectionList()
break;
}
- SectionSP section_sp(new Section(
- GetModule(), // Module to which this section belongs.
- this, // ObjectFile to which this section belongs and should read section data from.
- SectionIndex(I), // Section ID.
- name, // Section name.
- sect_type, // Section type.
- header.sh_addr, // VM address.
- vm_size, // VM size in bytes of this section.
- header.sh_offset, // Offset of this section in the file.
- file_size, // Size of the section as found in the file.
- header.sh_flags)); // Flags for this section.
+ SectionSP section_sp (new Section(GetModule(), // Module to which this section belongs.
+ this, // ObjectFile to which this section belongs and should read section data from.
+ SectionIndex(I), // Section ID.
+ name, // Section name.
+ sect_type, // Section type.
+ header.sh_addr, // VM address.
+ vm_size, // VM size in bytes of this section.
+ header.sh_offset, // Offset of this section in the file.
+ file_size, // Size of the section as found in the file.
+ header.sh_flags)); // Flags for this section.
if (is_thread_specific)
section_sp->SetIsThreadSpecific (is_thread_specific);
m_sections_ap->AddSection(section_sp);
}
-
- m_sections_ap->Finalize(); // Now that we're done adding sections, finalize to build fast-lookup caches
}
- return m_sections_ap.get();
+ if (m_sections_ap.get())
+ {
+ if (GetType() == eTypeDebugInfo)
+ {
+ static const SectionType g_sections[] =
+ {
+ eSectionTypeDWARFDebugAranges,
+ eSectionTypeDWARFDebugInfo,
+ eSectionTypeDWARFDebugAbbrev,
+ eSectionTypeDWARFDebugFrame,
+ eSectionTypeDWARFDebugLine,
+ eSectionTypeDWARFDebugStr,
+ eSectionTypeDWARFDebugLoc,
+ eSectionTypeDWARFDebugMacInfo,
+ eSectionTypeDWARFDebugPubNames,
+ eSectionTypeDWARFDebugPubTypes,
+ eSectionTypeDWARFDebugRanges,
+ eSectionTypeELFSymbolTable,
+ };
+ SectionList *elf_section_list = m_sections_ap.get();
+ for (size_t idx = 0; idx < sizeof(g_sections) / sizeof(g_sections[0]); ++idx)
+ {
+ SectionType section_type = g_sections[idx];
+ SectionSP section_sp (elf_section_list->FindSectionByType (section_type, true));
+ if (section_sp)
+ {
+ SectionSP module_section_sp (unified_section_list.FindSectionByType (section_type, true));
+ if (module_section_sp)
+ unified_section_list.ReplaceSection (module_section_sp->GetID(), section_sp);
+ else
+ unified_section_list.AddSection (section_sp);
+ }
+ }
+ }
+ else
+ {
+ unified_section_list = *m_sections_ap;
+ }
+ }
}
+// private
unsigned
-ObjectFileELF::ParseSymbols(Symtab *symtab,
- user_id_t start_id,
- SectionList *section_list,
- const ELFSectionHeaderInfo *symtab_shdr,
- const DataExtractor &symtab_data,
- const DataExtractor &strtab_data)
+ObjectFileELF::ParseSymbols (Symtab *symtab,
+ user_id_t start_id,
+ SectionList *section_list,
+ const size_t num_symbols,
+ const DataExtractor &symtab_data,
+ const DataExtractor &strtab_data)
{
ELFSymbol symbol;
lldb::offset_t offset = 0;
- const size_t num_symbols = symtab_data.GetByteSize() / symtab_shdr->sh_entsize;
static ConstString text_section_name(".text");
static ConstString init_section_name(".init");
@@ -1128,21 +1101,18 @@ ObjectFileELF::ParseSymbols(Symtab *symt
}
}
- // If the symbol section we've found has no data (SHT_NOBITS), then check the module
- // for the main object file and use the section there if it has data. This can happen
- // if we're parsing the debug file and the it has no .text section, for example.
+ // If the symbol section we've found has no data (SHT_NOBITS), then check the module section
+ // list. This can happen if we're parsing the debug file and it has no .text section, for example.
if (symbol_section_sp && (symbol_section_sp->GetFileSize() == 0))
{
ModuleSP module_sp(GetModule());
if (module_sp)
{
- ObjectFile *obj_file = module_sp->GetObjectFile();
- // Check if we've got a different object file than ourselves.
- if (obj_file && (obj_file != this))
+ SectionList *module_section_list = module_sp->GetSectionList();
+ if (module_section_list && module_section_list != section_list)
{
const ConstString §_name = symbol_section_sp->GetName();
- SectionList *obj_file_section_list = obj_file->GetSectionList();
- lldb::SectionSP section_sp (obj_file_section_list->FindSectionByName (sect_name));
+ lldb::SectionSP section_sp (module_section_list->FindSectionByName (sect_name));
if (section_sp && section_sp->GetFileSize())
{
symbol_section_sp = section_sp;
@@ -1178,32 +1148,46 @@ ObjectFileELF::ParseSymbols(Symtab *symt
}
unsigned
-ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, user_id_t start_id, user_id_t symtab_id)
+ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, user_id_t start_id, lldb_private::Section *symtab)
{
- // Parse in the section list if needed.
- SectionList *section_list = GetSectionList();
+ if (symtab->GetObjectFile() != this)
+ {
+ // If the symbol table section is owned by a different object file, have it do the
+ // parsing.
+ ObjectFileELF *obj_file_elf = static_cast<ObjectFileELF *>(symtab->GetObjectFile());
+ return obj_file_elf->ParseSymbolTable (symbol_table, start_id, symtab);
+ }
+
+ // Get section list for this object file.
+ SectionList *section_list = m_sections_ap.get();
if (!section_list)
return 0;
- const ELFSectionHeaderInfo *symtab_hdr = &m_section_headers[symtab_id - 1];
+ user_id_t symtab_id = symtab->GetID();
+ const ELFSectionHeaderInfo *symtab_hdr = GetSectionHeaderByIndex(symtab_id);
assert(symtab_hdr->sh_type == SHT_SYMTAB ||
symtab_hdr->sh_type == SHT_DYNSYM);
+ // sh_link: section header index of associated string table.
// Section ID's are ones based.
user_id_t strtab_id = symtab_hdr->sh_link + 1;
-
- Section *symtab = section_list->FindSectionByID(symtab_id).get();
Section *strtab = section_list->FindSectionByID(strtab_id).get();
+
unsigned num_symbols = 0;
if (symtab && strtab)
{
+ assert (symtab->GetObjectFile() == this);
+ assert (strtab->GetObjectFile() == this);
+
DataExtractor symtab_data;
DataExtractor strtab_data;
if (ReadSectionData(symtab, symtab_data) &&
ReadSectionData(strtab, strtab_data))
{
+ size_t num_symbols = symtab_data.GetByteSize() / symtab_hdr->sh_entsize;
+
num_symbols = ParseSymbols(symbol_table, start_id,
- section_list, symtab_hdr,
+ section_list, num_symbols,
symtab_data, strtab_data);
}
}
@@ -1217,17 +1201,15 @@ ObjectFileELF::ParseDynamicSymbols()
if (m_dynamic_symbols.size())
return m_dynamic_symbols.size();
- user_id_t dyn_id = GetSectionIndexByType(SHT_DYNAMIC);
- if (!dyn_id)
- return 0;
-
SectionList *section_list = GetSectionList();
if (!section_list)
return 0;
- Section *dynsym = section_list->FindSectionByID(dyn_id).get();
+ // Find the SHT_DYNAMIC section.
+ Section *dynsym = section_list->FindSectionByType (eSectionTypeELFDynamicLinkInfo, true).get();
if (!dynsym)
return 0;
+ assert (dynsym->GetObjectFile() == this);
ELFDynamic symbol;
DataExtractor dynsym_data;
@@ -1360,7 +1342,7 @@ ObjectFileELF::ParseTrampolineSymbols(Sy
{
assert(rel_hdr->sh_type == SHT_RELA || rel_hdr->sh_type == SHT_REL);
- // The link field points to the associated symbol table. The info field
+ // The link field points to the associated symbol table. The info field
// points to the section holding the plt.
user_id_t symtab_id = rel_hdr->sh_link;
user_id_t plt_id = rel_hdr->sh_info;
@@ -1380,7 +1362,7 @@ ObjectFileELF::ParseTrampolineSymbols(Sy
if (!sym_hdr)
return 0;
- SectionList *section_list = GetSectionList();
+ SectionList *section_list = m_sections_ap.get();
if (!section_list)
return 0;
@@ -1396,6 +1378,7 @@ ObjectFileELF::ParseTrampolineSymbols(Sy
if (!symtab)
return 0;
+ // sh_link points to associated string table.
Section *strtab = section_list->FindSectionByID(sym_hdr->sh_link + 1).get();
if (!strtab)
return 0;
@@ -1430,82 +1413,68 @@ ObjectFileELF::ParseTrampolineSymbols(Sy
}
Symtab *
-ObjectFileELF::GetSymtab(uint32_t flags)
+ObjectFileELF::GetSymtab()
{
ModuleSP module_sp(GetModule());
- if (module_sp)
- {
- lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+ if (!module_sp)
+ return NULL;
- bool from_unified_section_list = !!(flags & eSymtabFromUnifiedSectionList);
- SectionList *section_list = from_unified_section_list ? module_sp->GetUnifiedSectionList() : GetSectionList();
+ // We always want to use the main object file so we (hopefully) only have one cached copy
+ // of our symtab, dynamic sections, etc.
+ ObjectFile *module_obj_file = module_sp->GetObjectFile();
+ if (module_obj_file && module_obj_file != this)
+ return module_obj_file->GetSymtab();
+
+ if (m_symtab_ap.get() == NULL)
+ {
+ SectionList *section_list = GetSectionList();
if (!section_list)
return NULL;
- // If we're doing the unified section list and it has been modified, then clear our
- // cache and reload the symbols. If needed, we could check on only the sections that
- // we use to create the symbol table...
- std::unique_ptr<lldb_private::Symtab> &symtab_ap = from_unified_section_list ? m_symtab_unified_ap : m_symtab_ap;
- if (from_unified_section_list && (m_symtab_unified_revisionid != section_list->GetRevisionID()))
- {
- symtab_ap.reset();
- m_symtab_unified_revisionid = section_list->GetRevisionID();
- }
- else if (symtab_ap.get())
- {
- return symtab_ap.get();
- }
+ uint64_t symbol_id = 0;
+ lldb_private::Mutex::Locker locker(module_sp->GetMutex());
- Symtab *symbol_table = new Symtab(this);
- symtab_ap.reset(symbol_table);
+ m_symtab_ap.reset(new Symtab(this));
// Sharable objects and dynamic executables usually have 2 distinct symbol
// tables, one named ".symtab", and the other ".dynsym". The dynsym is a smaller
// version of the symtab that only contains global symbols. The information found
// in the dynsym is therefore also found in the symtab, while the reverse is not
// necessarily true.
- Section *section_sym = section_list->FindSectionByType (eSectionTypeELFSymbolTable, true).get();
- if (!section_sym)
+ Section *symtab = section_list->FindSectionByType (eSectionTypeELFSymbolTable, true).get();
+ if (!symtab)
{
// The symtab section is non-allocable and can be stripped, so if it doesn't exist
// then use the dynsym section which should always be there.
- section_sym = section_list->FindSectionByType (eSectionTypeELFDynamicSymbols, true).get();
+ symtab = section_list->FindSectionByType (eSectionTypeELFDynamicSymbols, true).get();
}
+ if (symtab)
+ symbol_id += ParseSymbolTable (m_symtab_ap.get(), symbol_id, symtab);
- uint64_t symbol_id = 0;
- if (section_sym)
- {
- user_id_t section_id = section_sym->GetID();
- ObjectFileELF *obj_file_elf = static_cast<ObjectFileELF *>(section_sym->GetObjectFile());
-
- symbol_id += obj_file_elf->ParseSymbolTable (symbol_table, symbol_id, section_id);
- }
-
- Section *section = section_list->FindSectionByType (eSectionTypeELFDynamicLinkInfo, true).get();
- if (section)
- {
- ObjectFileELF *obj_file_elf = static_cast<ObjectFileELF *>(section->GetObjectFile());
-
- // Synthesize trampoline symbols to help navigate the PLT.
- const ELFDynamic *symbol = obj_file_elf->FindDynamicSymbol(DT_JMPREL);
- if (symbol)
+ // Synthesize trampoline symbols to help navigate the PLT.
+ const ELFDynamic *symbol = FindDynamicSymbol(DT_JMPREL);
+ if (symbol)
+ {
+ addr_t addr = symbol->d_ptr;
+ Section *reloc_section = section_list->FindSectionContainingFileAddress(addr).get();
+ if (reloc_section)
{
- addr_t addr = symbol->d_ptr;
- Section *reloc_section = section_list->FindSectionContainingFileAddress(addr).get();
- if (reloc_section)
- {
- user_id_t reloc_id = reloc_section->GetID();
- const ELFSectionHeaderInfo *reloc_header = obj_file_elf->GetSectionHeaderByIndex(reloc_id);
- assert(reloc_header);
+ user_id_t reloc_id = reloc_section->GetID();
+ const ELFSectionHeaderInfo *reloc_header = GetSectionHeaderByIndex(reloc_id);
+ assert(reloc_header);
- obj_file_elf->ParseTrampolineSymbols(symbol_table, symbol_id, reloc_header, reloc_id);
- }
+ ParseTrampolineSymbols (m_symtab_ap.get(), symbol_id, reloc_header, reloc_id);
}
}
-
- return symbol_table;
}
- return NULL;
+ return m_symtab_ap.get();
+}
+
+bool
+ObjectFileELF::IsStripped ()
+{
+ // TODO: determine this for ELF
+ return false;
}
//===----------------------------------------------------------------------===//
Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h Tue Jul 9 20:23:25 2013
@@ -100,10 +100,13 @@ public:
GetAddressByteSize() const;
virtual lldb_private::Symtab *
- GetSymtab(uint32_t flags = 0);
+ GetSymtab();
- virtual lldb_private::SectionList *
- GetSectionList();
+ virtual bool
+ IsStripped ();
+
+ virtual void
+ CreateSections (lldb_private::SectionList &unified_section_list);
virtual void
Dump(lldb_private::Stream *s);
@@ -232,14 +235,14 @@ private:
unsigned
ParseSymbolTable(lldb_private::Symtab *symbol_table,
lldb::user_id_t start_id,
- lldb::user_id_t symtab_id);
+ lldb_private::Section *symtab);
/// Helper routine for ParseSymbolTable().
unsigned
ParseSymbols(lldb_private::Symtab *symbol_table,
lldb::user_id_t start_id,
lldb_private::SectionList *section_list,
- const ELFSectionHeaderInfo *symtab_shdr,
+ const size_t num_symbols,
const lldb_private::DataExtractor &symtab_data,
const lldb_private::DataExtractor &strtab_data);
@@ -252,17 +255,6 @@ private:
const ELFSectionHeaderInfo *rela_hdr,
lldb::user_id_t section_id);
- /// Utility method for looking up a section given its name. Returns the
- /// index of the corresponding section or zero if no section with the given
- /// name can be found (note that section indices are always 1 based, and so
- /// section index 0 is never valid).
- lldb::user_id_t
- GetSectionIndexByName(const char *name);
-
- // Returns the ID of the first section that has the given type.
- lldb::user_id_t
- GetSectionIndexByType(unsigned type);
-
/// Returns the section header with the given id or NULL.
const ELFSectionHeaderInfo *
GetSectionHeaderByIndex(lldb::user_id_t id);
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=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Jul 9 20:23:25 2013
@@ -895,7 +895,7 @@ ObjectFileMachO::GetAddressClass (lldb::
}
Symtab *
-ObjectFileMachO::GetSymtab(uint32_t flags)
+ObjectFileMachO::GetSymtab()
{
ModuleSP module_sp(GetModule());
if (module_sp)
@@ -905,409 +905,462 @@ ObjectFileMachO::GetSymtab(uint32_t flag
{
m_symtab_ap.reset(new Symtab(this));
Mutex::Locker symtab_locker (m_symtab_ap->GetMutex());
- ParseSymtab (true);
+ ParseSymtab ();
m_symtab_ap->Finalize ();
}
}
return m_symtab_ap.get();
}
-
-SectionList *
-ObjectFileMachO::GetSectionList()
+bool
+ObjectFileMachO::IsStripped ()
{
- ModuleSP module_sp(GetModule());
- if (module_sp)
+ if (m_dysymtab.cmd == 0)
{
- lldb_private::Mutex::Locker locker(module_sp->GetMutex());
- if (m_sections_ap.get() == NULL)
+ ModuleSP module_sp(GetModule());
+ if (module_sp)
{
- m_sections_ap.reset(new SectionList());
- ParseSections();
+ lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
+ for (uint32_t i=0; i<m_header.ncmds; ++i)
+ {
+ const lldb::offset_t load_cmd_offset = offset;
+
+ load_command lc;
+ if (m_data.GetU32(&offset, &lc.cmd, 2) == NULL)
+ break;
+ if (lc.cmd == LoadCommandDynamicSymtabInfo)
+ {
+ m_dysymtab.cmd = lc.cmd;
+ m_dysymtab.cmdsize = lc.cmdsize;
+ if (m_data.GetU32 (&offset, &m_dysymtab.ilocalsym, (sizeof(m_dysymtab) / sizeof(uint32_t)) - 2) == NULL)
+ {
+ // Clear m_dysymtab if we were unable to read all items from the load command
+ ::memset (&m_dysymtab, 0, sizeof(m_dysymtab));
+ }
+ }
+ offset = load_cmd_offset + lc.cmdsize;
+ }
}
}
- return m_sections_ap.get();
+ if (m_dysymtab.cmd)
+ return m_dysymtab.nlocalsym == 0;
+ return false;
}
-
-size_t
-ObjectFileMachO::ParseSections ()
+void
+ObjectFileMachO::CreateSections (SectionList &unified_section_list)
{
- lldb::user_id_t segID = 0;
- lldb::user_id_t sectID = 0;
- lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
- uint32_t i;
- const bool is_core = GetType() == eTypeCoreFile;
- //bool dump_sections = false;
- ModuleSP module_sp (GetModule());
- // First look up any LC_ENCRYPTION_INFO load commands
- typedef RangeArray<uint32_t, uint32_t, 8> EncryptedFileRanges;
- EncryptedFileRanges encrypted_file_ranges;
- encryption_info_command encryption_cmd;
- for (i=0; i<m_header.ncmds; ++i)
+ if (!m_sections_ap.get())
{
- const lldb::offset_t load_cmd_offset = offset;
- if (m_data.GetU32(&offset, &encryption_cmd, 2) == NULL)
- break;
-
- if (encryption_cmd.cmd == LoadCommandEncryptionInfo)
+ m_sections_ap.reset(new SectionList());
+
+ const bool is_dsym = (m_header.filetype == HeaderFileTypeDSYM);
+ lldb::user_id_t segID = 0;
+ lldb::user_id_t sectID = 0;
+ lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
+ uint32_t i;
+ const bool is_core = GetType() == eTypeCoreFile;
+ //bool dump_sections = false;
+ ModuleSP module_sp (GetModule());
+ // First look up any LC_ENCRYPTION_INFO load commands
+ typedef RangeArray<uint32_t, uint32_t, 8> EncryptedFileRanges;
+ EncryptedFileRanges encrypted_file_ranges;
+ encryption_info_command encryption_cmd;
+ for (i=0; i<m_header.ncmds; ++i)
{
- if (m_data.GetU32(&offset, &encryption_cmd.cryptoff, 3))
+ const lldb::offset_t load_cmd_offset = offset;
+ if (m_data.GetU32(&offset, &encryption_cmd, 2) == NULL)
+ break;
+
+ if (encryption_cmd.cmd == LoadCommandEncryptionInfo)
{
- if (encryption_cmd.cryptid != 0)
+ if (m_data.GetU32(&offset, &encryption_cmd.cryptoff, 3))
{
- EncryptedFileRanges::Entry entry;
- entry.SetRangeBase(encryption_cmd.cryptoff);
- entry.SetByteSize(encryption_cmd.cryptsize);
- encrypted_file_ranges.Append(entry);
+ if (encryption_cmd.cryptid != 0)
+ {
+ EncryptedFileRanges::Entry entry;
+ entry.SetRangeBase(encryption_cmd.cryptoff);
+ entry.SetByteSize(encryption_cmd.cryptsize);
+ encrypted_file_ranges.Append(entry);
+ }
}
}
+ offset = load_cmd_offset + encryption_cmd.cmdsize;
}
- offset = load_cmd_offset + encryption_cmd.cmdsize;
- }
- offset = MachHeaderSizeFromMagic(m_header.magic);
+ offset = MachHeaderSizeFromMagic(m_header.magic);
- struct segment_command_64 load_cmd;
- for (i=0; i<m_header.ncmds; ++i)
- {
- const lldb::offset_t load_cmd_offset = offset;
- if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
- break;
-
- if (load_cmd.cmd == LoadCommandSegment32 || load_cmd.cmd == LoadCommandSegment64)
+ struct segment_command_64 load_cmd;
+ for (i=0; i<m_header.ncmds; ++i)
{
- if (m_data.GetU8(&offset, (uint8_t*)load_cmd.segname, 16))
+ const lldb::offset_t load_cmd_offset = offset;
+ if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
+ break;
+
+ if (load_cmd.cmd == LoadCommandSegment32 || load_cmd.cmd == LoadCommandSegment64)
{
- load_cmd.vmaddr = m_data.GetAddress(&offset);
- load_cmd.vmsize = m_data.GetAddress(&offset);
- load_cmd.fileoff = m_data.GetAddress(&offset);
- load_cmd.filesize = m_data.GetAddress(&offset);
- if (m_length != 0 && load_cmd.filesize != 0)
- {
- if (load_cmd.fileoff > m_length)
- {
- // We have a load command that says it extends past the end of hte file. This is likely
- // a corrupt file. We don't have any way to return an error condition here (this method
- // was likely invokved from something like ObjectFile::GetSectionList()) -- all we can do
- // is null out the SectionList vector and if a process has been set up, dump a message
- // to stdout. The most common case here is core file debugging with a truncated file.
- const char *lc_segment_name = load_cmd.cmd == LoadCommandSegment64 ? "LC_SEGMENT_64" : "LC_SEGMENT";
- GetModule()->ReportError("is a corrupt mach-o file: load command %u %s has a fileoff (0x%" PRIx64 ") that extends beyond the end of the file (0x%" PRIx64 ")",
- i,
- lc_segment_name,
- load_cmd.fileoff,
- m_length);
-
- load_cmd.fileoff = 0;
- load_cmd.filesize = 0;
- }
-
- if (load_cmd.fileoff + load_cmd.filesize > m_length)
+ if (m_data.GetU8(&offset, (uint8_t*)load_cmd.segname, 16))
+ {
+ bool add_section = true;
+ bool add_to_unified = true;
+ ConstString const_segname (load_cmd.segname, std::min<size_t>(strlen(load_cmd.segname), sizeof(load_cmd.segname)));
+
+ SectionSP unified_section_sp(unified_section_list.FindSectionByName(const_segname));
+ if (is_dsym && unified_section_sp)
{
- // We have a load command that says it extends past the end of hte file. This is likely
- // a corrupt file. We don't have any way to return an error condition here (this method
- // was likely invokved from something like ObjectFile::GetSectionList()) -- all we can do
- // is null out the SectionList vector and if a process has been set up, dump a message
- // to stdout. The most common case here is core file debugging with a truncated file.
- const char *lc_segment_name = load_cmd.cmd == LoadCommandSegment64 ? "LC_SEGMENT_64" : "LC_SEGMENT";
- GetModule()->ReportError("is a corrupt mach-o file: load command %u %s has a fileoff + filesize (0x%" PRIx64 ") that extends beyond the end of the file (0x%" PRIx64 "), the segment will be truncated",
- i,
- lc_segment_name,
- load_cmd.fileoff + load_cmd.filesize,
- m_length);
+ if (const_segname == GetSegmentNameLINKEDIT())
+ {
+ // We need to keep the __LINKEDIT segment private to this object file only
+ add_to_unified = false;
+ }
+ else
+ {
+ // This is the dSYM file and this section has already been created by
+ // the object file, no need to create it.
+ add_section = false;
+ }
+ }
+ load_cmd.vmaddr = m_data.GetAddress(&offset);
+ load_cmd.vmsize = m_data.GetAddress(&offset);
+ load_cmd.fileoff = m_data.GetAddress(&offset);
+ load_cmd.filesize = m_data.GetAddress(&offset);
+ if (m_length != 0 && load_cmd.filesize != 0)
+ {
+ if (load_cmd.fileoff > m_length)
+ {
+ // We have a load command that says it extends past the end of hte file. This is likely
+ // a corrupt file. We don't have any way to return an error condition here (this method
+ // was likely invokved from something like ObjectFile::GetSectionList()) -- all we can do
+ // is null out the SectionList vector and if a process has been set up, dump a message
+ // to stdout. The most common case here is core file debugging with a truncated file.
+ const char *lc_segment_name = load_cmd.cmd == LoadCommandSegment64 ? "LC_SEGMENT_64" : "LC_SEGMENT";
+ GetModule()->ReportError("is a corrupt mach-o file: load command %u %s has a fileoff (0x%" PRIx64 ") that extends beyond the end of the file (0x%" PRIx64 ")",
+ i,
+ lc_segment_name,
+ load_cmd.fileoff,
+ m_length);
+
+ load_cmd.fileoff = 0;
+ load_cmd.filesize = 0;
+ }
- // Tuncase the length
- load_cmd.filesize = m_length - load_cmd.fileoff;
+ if (load_cmd.fileoff + load_cmd.filesize > m_length)
+ {
+ // We have a load command that says it extends past the end of hte file. This is likely
+ // a corrupt file. We don't have any way to return an error condition here (this method
+ // was likely invokved from something like ObjectFile::GetSectionList()) -- all we can do
+ // is null out the SectionList vector and if a process has been set up, dump a message
+ // to stdout. The most common case here is core file debugging with a truncated file.
+ const char *lc_segment_name = load_cmd.cmd == LoadCommandSegment64 ? "LC_SEGMENT_64" : "LC_SEGMENT";
+ GetModule()->ReportError("is a corrupt mach-o file: load command %u %s has a fileoff + filesize (0x%" PRIx64 ") that extends beyond the end of the file (0x%" PRIx64 "), the segment will be truncated",
+ i,
+ lc_segment_name,
+ load_cmd.fileoff + load_cmd.filesize,
+ m_length);
+
+ // Tuncase the length
+ load_cmd.filesize = m_length - load_cmd.fileoff;
+ }
}
- }
- if (m_data.GetU32(&offset, &load_cmd.maxprot, 4))
- {
-
- const bool segment_is_encrypted = (load_cmd.flags & SegmentCommandFlagBitProtectedVersion1) != 0;
-
- // Keep a list of mach segments around in case we need to
- // get at data that isn't stored in the abstracted Sections.
- m_mach_segments.push_back (load_cmd);
-
- ConstString segment_name (load_cmd.segname, std::min<size_t>(strlen(load_cmd.segname), sizeof(load_cmd.segname)));
- // Use a segment ID of the segment index shifted left by 8 so they
- // never conflict with any of the sections.
- SectionSP segment_sp;
- if (segment_name || is_core)
+ if (m_data.GetU32(&offset, &load_cmd.maxprot, 4))
{
- segment_sp.reset(new Section (module_sp, // Module to which this section belongs
- this, // Object file to which this sections belongs
- ++segID << 8, // 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
- segment_name, // Name of this section
- eSectionTypeContainer, // This section is a container of other sections.
- load_cmd.vmaddr, // File VM address == addresses as they are found in the object file
- load_cmd.vmsize, // VM size in bytes of this section
- load_cmd.fileoff, // Offset to the data for this section in the file
- load_cmd.filesize, // Size in bytes of this section as found in the the file
- load_cmd.flags)); // Flags for this section
- segment_sp->SetIsEncrypted (segment_is_encrypted);
- m_sections_ap->AddSection(segment_sp);
- }
+ const bool segment_is_encrypted = (load_cmd.flags & SegmentCommandFlagBitProtectedVersion1) != 0;
- struct section_64 sect64;
- ::memset (§64, 0, sizeof(sect64));
- // Push a section into our mach sections for the section at
- // index zero (NListSectionNoSection) if we don't have any
- // mach sections yet...
- if (m_mach_sections.empty())
- m_mach_sections.push_back(sect64);
- uint32_t segment_sect_idx;
- const lldb::user_id_t first_segment_sectID = sectID + 1;
+ // Keep a list of mach segments around in case we need to
+ // get at data that isn't stored in the abstracted Sections.
+ m_mach_segments.push_back (load_cmd);
+ // Use a segment ID of the segment index shifted left by 8 so they
+ // never conflict with any of the sections.
+ SectionSP segment_sp;
+ if (add_section && (const_segname || is_core))
+ {
+ segment_sp.reset(new Section (module_sp, // Module to which this section belongs
+ this, // Object file to which this sections belongs
+ ++segID << 8, // 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_segname, // Name of this section
+ eSectionTypeContainer, // This section is a container of other sections.
+ load_cmd.vmaddr, // File VM address == addresses as they are found in the object file
+ load_cmd.vmsize, // VM size in bytes of this section
+ load_cmd.fileoff, // Offset to the data for this section in the file
+ load_cmd.filesize, // Size in bytes of this section as found in the the file
+ load_cmd.flags)); // Flags for this section
+
+ segment_sp->SetIsEncrypted (segment_is_encrypted);
+ m_sections_ap->AddSection(segment_sp);
+ if (add_to_unified)
+ unified_section_list.AddSection(segment_sp);
+ }
+ else if (unified_section_sp)
+ {
+ m_sections_ap->AddSection(unified_section_sp);
+ }
+
+ struct section_64 sect64;
+ ::memset (§64, 0, sizeof(sect64));
+ // Push a section into our mach sections for the section at
+ // index zero (NListSectionNoSection) if we don't have any
+ // mach sections yet...
+ if (m_mach_sections.empty())
+ m_mach_sections.push_back(sect64);
+ uint32_t segment_sect_idx;
+ const lldb::user_id_t first_segment_sectID = sectID + 1;
- const uint32_t num_u32s = load_cmd.cmd == LoadCommandSegment32 ? 7 : 8;
- for (segment_sect_idx=0; segment_sect_idx<load_cmd.nsects; ++segment_sect_idx)
- {
- if (m_data.GetU8(&offset, (uint8_t*)sect64.sectname, sizeof(sect64.sectname)) == NULL)
- break;
- if (m_data.GetU8(&offset, (uint8_t*)sect64.segname, sizeof(sect64.segname)) == NULL)
- break;
- sect64.addr = m_data.GetAddress(&offset);
- sect64.size = m_data.GetAddress(&offset);
- if (m_data.GetU32(&offset, §64.offset, num_u32s) == NULL)
- break;
+ const uint32_t num_u32s = load_cmd.cmd == LoadCommandSegment32 ? 7 : 8;
+ for (segment_sect_idx=0; segment_sect_idx<load_cmd.nsects; ++segment_sect_idx)
+ {
+ if (m_data.GetU8(&offset, (uint8_t*)sect64.sectname, sizeof(sect64.sectname)) == NULL)
+ break;
+ if (m_data.GetU8(&offset, (uint8_t*)sect64.segname, sizeof(sect64.segname)) == NULL)
+ break;
+ sect64.addr = m_data.GetAddress(&offset);
+ sect64.size = m_data.GetAddress(&offset);
- // Keep a list of mach sections around in case we need to
- // get at data that isn't stored in the abstracted Sections.
- m_mach_sections.push_back (sect64);
+ if (m_data.GetU32(&offset, §64.offset, num_u32s) == NULL)
+ break;
- ConstString section_name (sect64.sectname, std::min<size_t>(strlen(sect64.sectname), sizeof(sect64.sectname)));
- if (!segment_name)
- {
- // We have a segment with no name so we need to conjure up
- // segments that correspond to the section's segname if there
- // isn't already such a section. If there is such a section,
- // we resize the section so that it spans all sections.
- // We also mark these sections as fake so address matches don't
- // hit if they land in the gaps between the child sections.
- segment_name.SetTrimmedCStringWithLength(sect64.segname, sizeof(sect64.segname));
- segment_sp = m_sections_ap->FindSectionByName (segment_name);
- if (segment_sp.get())
+ // Keep a list of mach sections around in case we need to
+ // get at data that isn't stored in the abstracted Sections.
+ m_mach_sections.push_back (sect64);
+
+ if (add_section)
{
- Section *segment = segment_sp.get();
- // Grow the section size as needed.
- const lldb::addr_t sect64_min_addr = sect64.addr;
- const lldb::addr_t sect64_max_addr = sect64_min_addr + sect64.size;
- const lldb::addr_t curr_seg_byte_size = segment->GetByteSize();
- const lldb::addr_t curr_seg_min_addr = segment->GetFileAddress();
- const lldb::addr_t curr_seg_max_addr = curr_seg_min_addr + curr_seg_byte_size;
- if (sect64_min_addr >= curr_seg_min_addr)
+ ConstString section_name (sect64.sectname, std::min<size_t>(strlen(sect64.sectname), sizeof(sect64.sectname)));
+ if (!const_segname)
{
- const lldb::addr_t new_seg_byte_size = sect64_max_addr - curr_seg_min_addr;
- // Only grow the section size if needed
- if (new_seg_byte_size > curr_seg_byte_size)
- segment->SetByteSize (new_seg_byte_size);
+ // We have a segment with no name so we need to conjure up
+ // segments that correspond to the section's segname if there
+ // isn't already such a section. If there is such a section,
+ // we resize the section so that it spans all sections.
+ // We also mark these sections as fake so address matches don't
+ // hit if they land in the gaps between the child sections.
+ const_segname.SetTrimmedCStringWithLength(sect64.segname, sizeof(sect64.segname));
+ segment_sp = unified_section_list.FindSectionByName (const_segname);
+ if (segment_sp.get())
+ {
+ Section *segment = segment_sp.get();
+ // Grow the section size as needed.
+ const lldb::addr_t sect64_min_addr = sect64.addr;
+ const lldb::addr_t sect64_max_addr = sect64_min_addr + sect64.size;
+ const lldb::addr_t curr_seg_byte_size = segment->GetByteSize();
+ const lldb::addr_t curr_seg_min_addr = segment->GetFileAddress();
+ const lldb::addr_t curr_seg_max_addr = curr_seg_min_addr + curr_seg_byte_size;
+ if (sect64_min_addr >= curr_seg_min_addr)
+ {
+ const lldb::addr_t new_seg_byte_size = sect64_max_addr - curr_seg_min_addr;
+ // Only grow the section size if needed
+ if (new_seg_byte_size > curr_seg_byte_size)
+ segment->SetByteSize (new_seg_byte_size);
+ }
+ else
+ {
+ // We need to change the base address of the segment and
+ // adjust the child section offsets for all existing children.
+ const lldb::addr_t slide_amount = sect64_min_addr - curr_seg_min_addr;
+ segment->Slide(slide_amount, false);
+ 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
+ {
+ // Create a fake section for the section's named segment
+ segment_sp.reset(new Section (segment_sp, // Parent section
+ module_sp, // Module to which this section belongs
+ this, // Object file to which this section belongs
+ ++segID << 8, // 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_segname, // Name of this section
+ eSectionTypeContainer, // This section is a container of other sections.
+ sect64.addr, // File VM address == addresses as they are found in the object file
+ sect64.size, // VM size in bytes of this section
+ sect64.offset, // Offset to the data for this section in the file
+ sect64.offset ? sect64.size : 0, // Size in bytes of this section as found in the the file
+ load_cmd.flags)); // Flags for this section
+ segment_sp->SetIsFake(true);
+
+ m_sections_ap->AddSection(segment_sp);
+ if (add_to_unified)
+ unified_section_list.AddSection(segment_sp);
+ segment_sp->SetIsEncrypted (segment_is_encrypted);
+ }
}
- else
+ assert (segment_sp.get());
+
+ uint32_t mach_sect_type = sect64.flags & SectionFlagMaskSectionType;
+ static ConstString g_sect_name_objc_data ("__objc_data");
+ static ConstString g_sect_name_objc_msgrefs ("__objc_msgrefs");
+ static ConstString g_sect_name_objc_selrefs ("__objc_selrefs");
+ static ConstString g_sect_name_objc_classrefs ("__objc_classrefs");
+ static ConstString g_sect_name_objc_superrefs ("__objc_superrefs");
+ static ConstString g_sect_name_objc_const ("__objc_const");
+ static ConstString g_sect_name_objc_classlist ("__objc_classlist");
+ static ConstString g_sect_name_cfstring ("__cfstring");
+
+ static ConstString g_sect_name_dwarf_debug_abbrev ("__debug_abbrev");
+ static ConstString g_sect_name_dwarf_debug_aranges ("__debug_aranges");
+ static ConstString g_sect_name_dwarf_debug_frame ("__debug_frame");
+ static ConstString g_sect_name_dwarf_debug_info ("__debug_info");
+ static ConstString g_sect_name_dwarf_debug_line ("__debug_line");
+ static ConstString g_sect_name_dwarf_debug_loc ("__debug_loc");
+ static ConstString g_sect_name_dwarf_debug_macinfo ("__debug_macinfo");
+ static ConstString g_sect_name_dwarf_debug_pubnames ("__debug_pubnames");
+ static ConstString g_sect_name_dwarf_debug_pubtypes ("__debug_pubtypes");
+ static ConstString g_sect_name_dwarf_debug_ranges ("__debug_ranges");
+ static ConstString g_sect_name_dwarf_debug_str ("__debug_str");
+ static ConstString g_sect_name_dwarf_apple_names ("__apple_names");
+ static ConstString g_sect_name_dwarf_apple_types ("__apple_types");
+ static ConstString g_sect_name_dwarf_apple_namespaces ("__apple_namespac");
+ static ConstString g_sect_name_dwarf_apple_objc ("__apple_objc");
+ static ConstString g_sect_name_eh_frame ("__eh_frame");
+ static ConstString g_sect_name_DATA ("__DATA");
+ static ConstString g_sect_name_TEXT ("__TEXT");
+
+ SectionType sect_type = eSectionTypeOther;
+
+ if (section_name == g_sect_name_dwarf_debug_abbrev)
+ sect_type = eSectionTypeDWARFDebugAbbrev;
+ else if (section_name == g_sect_name_dwarf_debug_aranges)
+ sect_type = eSectionTypeDWARFDebugAranges;
+ else if (section_name == g_sect_name_dwarf_debug_frame)
+ sect_type = eSectionTypeDWARFDebugFrame;
+ else if (section_name == g_sect_name_dwarf_debug_info)
+ sect_type = eSectionTypeDWARFDebugInfo;
+ else if (section_name == g_sect_name_dwarf_debug_line)
+ sect_type = eSectionTypeDWARFDebugLine;
+ else if (section_name == g_sect_name_dwarf_debug_loc)
+ sect_type = eSectionTypeDWARFDebugLoc;
+ else if (section_name == g_sect_name_dwarf_debug_macinfo)
+ sect_type = eSectionTypeDWARFDebugMacInfo;
+ else if (section_name == g_sect_name_dwarf_debug_pubnames)
+ sect_type = eSectionTypeDWARFDebugPubNames;
+ else if (section_name == g_sect_name_dwarf_debug_pubtypes)
+ sect_type = eSectionTypeDWARFDebugPubTypes;
+ else if (section_name == g_sect_name_dwarf_debug_ranges)
+ sect_type = eSectionTypeDWARFDebugRanges;
+ else if (section_name == g_sect_name_dwarf_debug_str)
+ sect_type = eSectionTypeDWARFDebugStr;
+ else if (section_name == g_sect_name_dwarf_apple_names)
+ sect_type = eSectionTypeDWARFAppleNames;
+ else if (section_name == g_sect_name_dwarf_apple_types)
+ sect_type = eSectionTypeDWARFAppleTypes;
+ else if (section_name == g_sect_name_dwarf_apple_namespaces)
+ sect_type = eSectionTypeDWARFAppleNamespaces;
+ else if (section_name == g_sect_name_dwarf_apple_objc)
+ sect_type = eSectionTypeDWARFAppleObjC;
+ else if (section_name == g_sect_name_objc_selrefs)
+ sect_type = eSectionTypeDataCStringPointers;
+ else if (section_name == g_sect_name_objc_msgrefs)
+ sect_type = eSectionTypeDataObjCMessageRefs;
+ else if (section_name == g_sect_name_eh_frame)
+ sect_type = eSectionTypeEHFrame;
+ else if (section_name == g_sect_name_cfstring)
+ sect_type = eSectionTypeDataObjCCFStrings;
+ else if (section_name == g_sect_name_objc_data ||
+ section_name == g_sect_name_objc_classrefs ||
+ section_name == g_sect_name_objc_superrefs ||
+ section_name == g_sect_name_objc_const ||
+ section_name == g_sect_name_objc_classlist)
{
- // We need to change the base address of the segment and
- // adjust the child section offsets for all existing children.
- const lldb::addr_t slide_amount = sect64_min_addr - curr_seg_min_addr;
- segment->Slide(slide_amount, false);
- segment->GetChildren().Slide(-slide_amount, false);
- segment->SetByteSize (curr_seg_max_addr - sect64_min_addr);
+ sect_type = eSectionTypeDataPointers;
}
- // Grow the section size as needed.
- if (sect64.offset)
+ if (sect_type == eSectionTypeOther)
{
- 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);
+ switch (mach_sect_type)
+ {
+ // TODO: categorize sections by other flags for regular sections
+ case SectionTypeRegular:
+ if (segment_sp->GetName() == g_sect_name_TEXT)
+ sect_type = eSectionTypeCode;
+ else if (segment_sp->GetName() == g_sect_name_DATA)
+ sect_type = eSectionTypeData;
+ else
+ sect_type = eSectionTypeOther;
+ break;
+ case SectionTypeZeroFill: sect_type = eSectionTypeZeroFill; break;
+ case SectionTypeCStringLiterals: sect_type = eSectionTypeDataCString; break; // section with only literal C strings
+ case SectionType4ByteLiterals: sect_type = eSectionTypeData4; break; // section with only 4 byte literals
+ case SectionType8ByteLiterals: sect_type = eSectionTypeData8; break; // section with only 8 byte literals
+ case SectionTypeLiteralPointers: sect_type = eSectionTypeDataPointers; break; // section with only pointers to literals
+ case SectionTypeNonLazySymbolPointers: sect_type = eSectionTypeDataPointers; break; // section with only non-lazy symbol pointers
+ case SectionTypeLazySymbolPointers: sect_type = eSectionTypeDataPointers; break; // section with only lazy symbol pointers
+ case SectionTypeSymbolStubs: sect_type = eSectionTypeCode; break; // section with only symbol stubs, byte size of stub in the reserved2 field
+ case SectionTypeModuleInitFunctionPointers: sect_type = eSectionTypeDataPointers; break; // section with only function pointers for initialization
+ case SectionTypeModuleTermFunctionPointers: sect_type = eSectionTypeDataPointers; break; // section with only function pointers for termination
+ case SectionTypeCoalesced: sect_type = eSectionTypeOther; break;
+ case SectionTypeZeroFillLarge: sect_type = eSectionTypeZeroFill; break;
+ case SectionTypeInterposing: sect_type = eSectionTypeCode; break; // section with only pairs of function pointers for interposing
+ case SectionType16ByteLiterals: sect_type = eSectionTypeData16; break; // section with only 16 byte literals
+ case SectionTypeDTraceObjectFormat: sect_type = eSectionTypeDebug; break;
+ case SectionTypeLazyDylibSymbolPointers: sect_type = eSectionTypeDataPointers; break;
+ default: break;
+ }
}
- }
- else
- {
- // Create a fake section for the section's named segment
- segment_sp.reset(new Section (segment_sp, // Parent section
- module_sp, // Module to which this section belongs
- this, // Object file to which this section belongs
- ++segID << 8, // 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
- segment_name, // Name of this section
- eSectionTypeContainer, // This section is a container of other sections.
- sect64.addr, // File VM address == addresses as they are found in the object file
- sect64.size, // VM size in bytes of this section
- sect64.offset, // Offset to the data for this section in the file
- sect64.offset ? sect64.size : 0, // Size in bytes of this section as found in the the file
- load_cmd.flags)); // Flags for this section
- segment_sp->SetIsFake(true);
- m_sections_ap->AddSection(segment_sp);
- segment_sp->SetIsEncrypted (segment_is_encrypted);
- }
- }
- assert (segment_sp.get());
- uint32_t mach_sect_type = sect64.flags & SectionFlagMaskSectionType;
- static ConstString g_sect_name_objc_data ("__objc_data");
- static ConstString g_sect_name_objc_msgrefs ("__objc_msgrefs");
- static ConstString g_sect_name_objc_selrefs ("__objc_selrefs");
- static ConstString g_sect_name_objc_classrefs ("__objc_classrefs");
- static ConstString g_sect_name_objc_superrefs ("__objc_superrefs");
- static ConstString g_sect_name_objc_const ("__objc_const");
- static ConstString g_sect_name_objc_classlist ("__objc_classlist");
- static ConstString g_sect_name_cfstring ("__cfstring");
-
- static ConstString g_sect_name_dwarf_debug_abbrev ("__debug_abbrev");
- static ConstString g_sect_name_dwarf_debug_aranges ("__debug_aranges");
- static ConstString g_sect_name_dwarf_debug_frame ("__debug_frame");
- static ConstString g_sect_name_dwarf_debug_info ("__debug_info");
- static ConstString g_sect_name_dwarf_debug_line ("__debug_line");
- static ConstString g_sect_name_dwarf_debug_loc ("__debug_loc");
- static ConstString g_sect_name_dwarf_debug_macinfo ("__debug_macinfo");
- static ConstString g_sect_name_dwarf_debug_pubnames ("__debug_pubnames");
- static ConstString g_sect_name_dwarf_debug_pubtypes ("__debug_pubtypes");
- static ConstString g_sect_name_dwarf_debug_ranges ("__debug_ranges");
- static ConstString g_sect_name_dwarf_debug_str ("__debug_str");
- static ConstString g_sect_name_dwarf_apple_names ("__apple_names");
- static ConstString g_sect_name_dwarf_apple_types ("__apple_types");
- static ConstString g_sect_name_dwarf_apple_namespaces ("__apple_namespac");
- static ConstString g_sect_name_dwarf_apple_objc ("__apple_objc");
- static ConstString g_sect_name_eh_frame ("__eh_frame");
- static ConstString g_sect_name_DATA ("__DATA");
- static ConstString g_sect_name_TEXT ("__TEXT");
-
- SectionType sect_type = eSectionTypeOther;
-
- if (section_name == g_sect_name_dwarf_debug_abbrev)
- sect_type = eSectionTypeDWARFDebugAbbrev;
- else if (section_name == g_sect_name_dwarf_debug_aranges)
- sect_type = eSectionTypeDWARFDebugAranges;
- else if (section_name == g_sect_name_dwarf_debug_frame)
- sect_type = eSectionTypeDWARFDebugFrame;
- else if (section_name == g_sect_name_dwarf_debug_info)
- sect_type = eSectionTypeDWARFDebugInfo;
- else if (section_name == g_sect_name_dwarf_debug_line)
- sect_type = eSectionTypeDWARFDebugLine;
- else if (section_name == g_sect_name_dwarf_debug_loc)
- sect_type = eSectionTypeDWARFDebugLoc;
- else if (section_name == g_sect_name_dwarf_debug_macinfo)
- sect_type = eSectionTypeDWARFDebugMacInfo;
- else if (section_name == g_sect_name_dwarf_debug_pubnames)
- sect_type = eSectionTypeDWARFDebugPubNames;
- else if (section_name == g_sect_name_dwarf_debug_pubtypes)
- sect_type = eSectionTypeDWARFDebugPubTypes;
- else if (section_name == g_sect_name_dwarf_debug_ranges)
- sect_type = eSectionTypeDWARFDebugRanges;
- else if (section_name == g_sect_name_dwarf_debug_str)
- sect_type = eSectionTypeDWARFDebugStr;
- else if (section_name == g_sect_name_dwarf_apple_names)
- sect_type = eSectionTypeDWARFAppleNames;
- else if (section_name == g_sect_name_dwarf_apple_types)
- sect_type = eSectionTypeDWARFAppleTypes;
- else if (section_name == g_sect_name_dwarf_apple_namespaces)
- sect_type = eSectionTypeDWARFAppleNamespaces;
- else if (section_name == g_sect_name_dwarf_apple_objc)
- sect_type = eSectionTypeDWARFAppleObjC;
- else if (section_name == g_sect_name_objc_selrefs)
- sect_type = eSectionTypeDataCStringPointers;
- else if (section_name == g_sect_name_objc_msgrefs)
- sect_type = eSectionTypeDataObjCMessageRefs;
- else if (section_name == g_sect_name_eh_frame)
- sect_type = eSectionTypeEHFrame;
- else if (section_name == g_sect_name_cfstring)
- sect_type = eSectionTypeDataObjCCFStrings;
- else if (section_name == g_sect_name_objc_data ||
- section_name == g_sect_name_objc_classrefs ||
- section_name == g_sect_name_objc_superrefs ||
- section_name == g_sect_name_objc_const ||
- section_name == g_sect_name_objc_classlist)
- {
- sect_type = eSectionTypeDataPointers;
- }
+ SectionSP section_sp(new Section (segment_sp,
+ module_sp,
+ this,
+ ++sectID,
+ section_name,
+ sect_type,
+ sect64.addr - segment_sp->GetFileAddress(),
+ sect64.size,
+ sect64.offset,
+ sect64.offset == 0 ? 0 : sect64.size,
+ sect64.flags));
+ // Set the section to be encrypted to match the segment
+
+ bool section_is_encrypted = false;
+ if (!segment_is_encrypted && load_cmd.filesize != 0)
+ section_is_encrypted = encrypted_file_ranges.FindEntryThatContains(sect64.offset) != NULL;
- if (sect_type == eSectionTypeOther)
- {
- switch (mach_sect_type)
- {
- // TODO: categorize sections by other flags for regular sections
- case SectionTypeRegular:
- if (segment_sp->GetName() == g_sect_name_TEXT)
- sect_type = eSectionTypeCode;
- else if (segment_sp->GetName() == g_sect_name_DATA)
- sect_type = eSectionTypeData;
- else
- sect_type = eSectionTypeOther;
- break;
- case SectionTypeZeroFill: sect_type = eSectionTypeZeroFill; break;
- case SectionTypeCStringLiterals: sect_type = eSectionTypeDataCString; break; // section with only literal C strings
- case SectionType4ByteLiterals: sect_type = eSectionTypeData4; break; // section with only 4 byte literals
- case SectionType8ByteLiterals: sect_type = eSectionTypeData8; break; // section with only 8 byte literals
- case SectionTypeLiteralPointers: sect_type = eSectionTypeDataPointers; break; // section with only pointers to literals
- case SectionTypeNonLazySymbolPointers: sect_type = eSectionTypeDataPointers; break; // section with only non-lazy symbol pointers
- case SectionTypeLazySymbolPointers: sect_type = eSectionTypeDataPointers; break; // section with only lazy symbol pointers
- case SectionTypeSymbolStubs: sect_type = eSectionTypeCode; break; // section with only symbol stubs, byte size of stub in the reserved2 field
- case SectionTypeModuleInitFunctionPointers: sect_type = eSectionTypeDataPointers; break; // section with only function pointers for initialization
- case SectionTypeModuleTermFunctionPointers: sect_type = eSectionTypeDataPointers; break; // section with only function pointers for termination
- case SectionTypeCoalesced: sect_type = eSectionTypeOther; break;
- case SectionTypeZeroFillLarge: sect_type = eSectionTypeZeroFill; break;
- case SectionTypeInterposing: sect_type = eSectionTypeCode; break; // section with only pairs of function pointers for interposing
- case SectionType16ByteLiterals: sect_type = eSectionTypeData16; break; // section with only 16 byte literals
- case SectionTypeDTraceObjectFormat: sect_type = eSectionTypeDebug; break;
- case SectionTypeLazyDylibSymbolPointers: sect_type = eSectionTypeDataPointers; break;
- default: break;
- }
- }
+ section_sp->SetIsEncrypted (segment_is_encrypted || section_is_encrypted);
+ segment_sp->GetChildren().AddSection(section_sp);
- SectionSP section_sp(new Section (segment_sp,
- module_sp,
- this,
- ++sectID,
- section_name,
- sect_type,
- sect64.addr - segment_sp->GetFileAddress(),
- sect64.size,
- sect64.offset,
- sect64.offset == 0 ? 0 : sect64.size,
- sect64.flags));
- // Set the section to be encrypted to match the segment
-
- bool section_is_encrypted = false;
- if (!segment_is_encrypted && load_cmd.filesize != 0)
- section_is_encrypted = encrypted_file_ranges.FindEntryThatContains(sect64.offset) != NULL;
-
- section_sp->SetIsEncrypted (segment_is_encrypted || section_is_encrypted);
- segment_sp->GetChildren().AddSection(section_sp);
-
- if (segment_sp->IsFake())
- {
- segment_sp.reset();
- segment_name.Clear();
+ if (segment_sp->IsFake())
+ {
+ segment_sp.reset();
+ const_segname.Clear();
+ }
+ }
}
- }
- if (segment_sp && m_header.filetype == HeaderFileTypeDSYM)
- {
- if (first_segment_sectID <= sectID)
+ if (segment_sp && is_dsym)
{
- lldb::user_id_t sect_uid;
- for (sect_uid = first_segment_sectID; sect_uid <= sectID; ++sect_uid)
+ if (first_segment_sectID <= sectID)
{
- SectionSP curr_section_sp(segment_sp->GetChildren().FindSectionByID (sect_uid));
- SectionSP next_section_sp;
- if (sect_uid + 1 <= sectID)
- next_section_sp = segment_sp->GetChildren().FindSectionByID (sect_uid+1);
-
- if (curr_section_sp.get())
+ lldb::user_id_t sect_uid;
+ for (sect_uid = first_segment_sectID; sect_uid <= sectID; ++sect_uid)
{
- if (curr_section_sp->GetByteSize() == 0)
+ SectionSP curr_section_sp(segment_sp->GetChildren().FindSectionByID (sect_uid));
+ SectionSP next_section_sp;
+ if (sect_uid + 1 <= sectID)
+ next_section_sp = segment_sp->GetChildren().FindSectionByID (sect_uid+1);
+
+ if (curr_section_sp.get())
{
- if (next_section_sp.get() != NULL)
- curr_section_sp->SetByteSize ( next_section_sp->GetFileAddress() - curr_section_sp->GetFileAddress() );
- else
- curr_section_sp->SetByteSize ( load_cmd.vmsize );
+ if (curr_section_sp->GetByteSize() == 0)
+ {
+ if (next_section_sp.get() != NULL)
+ curr_section_sp->SetByteSize ( next_section_sp->GetFileAddress() - curr_section_sp->GetFileAddress() );
+ else
+ curr_section_sp->SetByteSize ( load_cmd.vmsize );
+ }
}
}
}
@@ -1315,22 +1368,20 @@ ObjectFileMachO::ParseSections ()
}
}
}
- }
- else if (load_cmd.cmd == LoadCommandDynamicSymtabInfo)
- {
- m_dysymtab.cmd = load_cmd.cmd;
- m_dysymtab.cmdsize = load_cmd.cmdsize;
- m_data.GetU32 (&offset, &m_dysymtab.ilocalsym, (sizeof(m_dysymtab) / sizeof(uint32_t)) - 2);
- }
+ else if (load_cmd.cmd == LoadCommandDynamicSymtabInfo)
+ {
+ m_dysymtab.cmd = load_cmd.cmd;
+ m_dysymtab.cmdsize = load_cmd.cmdsize;
+ m_data.GetU32 (&offset, &m_dysymtab.ilocalsym, (sizeof(m_dysymtab) / sizeof(uint32_t)) - 2);
+ }
- offset = load_cmd_offset + load_cmd.cmdsize;
+ offset = load_cmd_offset + load_cmd.cmdsize;
+ }
+
+// StreamFile s(stdout, false); // REMOVE THIS LINE
+// s.Printf ("Sections for %s:\n", m_file.GetPath().c_str());// REMOVE THIS LINE
+// m_sections_ap->Dump(&s, NULL, true, UINT32_MAX);// REMOVE THIS LINE
}
-// if (dump_sections)
-// {
-// StreamFile s(stdout);
-// m_sections_ap->Dump(&s, true);
-// }
- return sectID; // Return the number of sections we registered with the module
}
class MachSymtabSectionInfo
@@ -1403,7 +1454,7 @@ protected:
};
size_t
-ObjectFileMachO::ParseSymtab (bool minimize)
+ObjectFileMachO::ParseSymtab ()
{
Timer scoped_timer(__PRETTY_FUNCTION__,
"ObjectFileMachO::ParseSymtab () module = %s",
@@ -2044,8 +2095,7 @@ ObjectFileMachO::ParseSymtab (bool minim
// We don't really need the end function STAB as it contains the size which
// we already placed with the original symbol, so don't add it if we want a
// minimal symbol table
- if (minimize)
- add_nlist = false;
+ add_nlist = false;
}
}
break;
@@ -2067,17 +2117,8 @@ ObjectFileMachO::ParseSymtab (bool minim
// N_BNSYM
// We use the current number of symbols in the symbol table in lieu of
// using nlist_idx in case we ever start trimming entries out
- if (minimize)
- {
- // Skip these if we want minimal symbol tables
- add_nlist = false;
- }
- else
- {
- symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
- N_NSYM_indexes.push_back(sym_idx);
- type = eSymbolTypeScopeBegin;
- }
+ // Skip these if we want minimal symbol tables
+ add_nlist = false;
break;
case StabEndSymbol:
@@ -2085,22 +2126,8 @@ ObjectFileMachO::ParseSymtab (bool minim
// Set the size of the N_BNSYM to the terminating index of this N_ENSYM
// so that we can always skip the entire symbol if we need to navigate
// more quickly at the source level when parsing STABS
- if (minimize)
- {
- // Skip these if we want minimal symbol tables
- add_nlist = false;
- }
- else
- {
- if ( !N_NSYM_indexes.empty() )
- {
- symbol_ptr = symtab->SymbolAtIndex(N_NSYM_indexes.back());
- symbol_ptr->SetByteSize(sym_idx + 1);
- symbol_ptr->SetSizeIsSibling(true);
- N_NSYM_indexes.pop_back();
- }
- type = eSymbolTypeScopeEnd;
- }
+ // Skip these if we want minimal symbol tables
+ add_nlist = false;
break;
@@ -2130,15 +2157,14 @@ ObjectFileMachO::ParseSymtab (bool minim
type = eSymbolTypeSourceFile;
if (symbol_name == NULL)
{
- if (minimize)
- add_nlist = false;
+ add_nlist = false;
if (N_SO_index != UINT32_MAX)
{
// Set the size of the N_SO to the terminating index of this N_SO
// so that we can always skip the entire N_SO if we need to navigate
// more quickly at the source level when parsing STABS
symbol_ptr = symtab->SymbolAtIndex(N_SO_index);
- symbol_ptr->SetByteSize(sym_idx + (minimize ? 0 : 1));
+ symbol_ptr->SetByteSize(sym_idx);
symbol_ptr->SetSizeIsSibling(true);
}
N_NSYM_indexes.clear();
@@ -2155,7 +2181,7 @@ ObjectFileMachO::ParseSymtab (bool minim
const bool N_SO_has_full_path = symbol_name[0] == '/';
if (N_SO_has_full_path)
{
- if (minimize && (N_SO_index == sym_idx - 1) && ((sym_idx - 1) < num_syms))
+ if ((N_SO_index == sym_idx - 1) && ((sym_idx - 1) < num_syms))
{
// We have two consecutive N_SO entries where the first contains a directory
// and the second contains a full path.
@@ -2170,7 +2196,7 @@ ObjectFileMachO::ParseSymtab (bool minim
N_SO_index = sym_idx;
}
}
- else if (minimize && (N_SO_index == sym_idx - 1) && ((sym_idx - 1) < num_syms))
+ else if ((N_SO_index == sym_idx - 1) && ((sym_idx - 1) < num_syms))
{
// This is usually the second N_SO entry that contains just the filename,
// so here we combine it with the first one if we are minimizing the symbol table
@@ -2253,8 +2279,7 @@ ObjectFileMachO::ParseSymtab (bool minim
type = eSymbolTypeHeaderFile;
// We currently don't use the header files on darwin
- if (minimize)
- add_nlist = false;
+ add_nlist = false;
break;
case StabCompilerParameters:
@@ -2503,8 +2528,6 @@ ObjectFileMachO::ParseSymtab (bool minim
if (add_nlist)
{
uint64_t symbol_value = nlist.n_value;
- bool symbol_name_is_mangled = false;
-
if (symbol_name_non_abi_mangled)
{
sym[sym_idx].GetMangled().SetMangledName (ConstString(symbol_name_non_abi_mangled));
@@ -2512,6 +2535,8 @@ ObjectFileMachO::ParseSymtab (bool minim
}
else
{
+ bool symbol_name_is_mangled = false;
+
if (symbol_name && symbol_name[0] == '_')
{
symbol_name_is_mangled = symbol_name[1] == '_';
@@ -2521,9 +2546,9 @@ ObjectFileMachO::ParseSymtab (bool minim
if (symbol_name)
{
ConstString const_symbol_name(symbol_name);
- if (is_gsym)
- N_GSYM_name_to_sym_idx[const_symbol_name.GetCString()] = sym_idx;
sym[sym_idx].GetMangled().SetValue(const_symbol_name, symbol_name_is_mangled);
+ if (is_gsym && is_debug)
+ N_GSYM_name_to_sym_idx[sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString()] = sym_idx;
}
}
if (symbol_section)
@@ -2590,8 +2615,7 @@ ObjectFileMachO::ParseSymtab (bool minim
ValueToSymbolIndexMap::const_iterator pos = N_FUN_addr_to_sym_idx.find (nlist.n_value);
if (pos != N_FUN_addr_to_sym_idx.end())
{
- if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) ||
- (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName()))
+ if (sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled) == sym[pos->second].GetMangled().GetName(Mangled::ePreferMangled))
{
m_nlist_idx_to_sym_idx[nlist_idx] = pos->second;
// We just need the flags from the linker symbol, so put these flags
@@ -2611,8 +2635,7 @@ ObjectFileMachO::ParseSymtab (bool minim
ValueToSymbolIndexMap::const_iterator pos = N_STSYM_addr_to_sym_idx.find (nlist.n_value);
if (pos != N_STSYM_addr_to_sym_idx.end())
{
- if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) ||
- (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName()))
+ if (sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled) == sym[pos->second].GetMangled().GetName(Mangled::ePreferMangled))
{
m_nlist_idx_to_sym_idx[nlist_idx] = pos->second;
// We just need the flags from the linker symbol, so put these flags
@@ -2625,7 +2648,7 @@ ObjectFileMachO::ParseSymtab (bool minim
else
{
// Combine N_GSYM stab entries with the non stab symbol
- ConstNameToSymbolIndexMap::const_iterator pos = N_GSYM_name_to_sym_idx.find(sym[sym_idx].GetMangled().GetMangledName().GetCString());
+ ConstNameToSymbolIndexMap::const_iterator pos = N_GSYM_name_to_sym_idx.find(sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString());
if (pos != N_GSYM_name_to_sym_idx.end())
{
const uint32_t GSYM_sym_idx = pos->second;
@@ -2811,8 +2834,7 @@ ObjectFileMachO::ParseSymtab (bool minim
// We don't really need the end function STAB as it contains the size which
// we already placed with the original symbol, so don't add it if we want a
// minimal symbol table
- if (minimize)
- add_nlist = false;
+ add_nlist = false;
}
}
break;
@@ -2834,17 +2856,8 @@ ObjectFileMachO::ParseSymtab (bool minim
// N_BNSYM
// We use the current number of symbols in the symbol table in lieu of
// using nlist_idx in case we ever start trimming entries out
- if (minimize)
- {
- // Skip these if we want minimal symbol tables
- add_nlist = false;
- }
- else
- {
- symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
- N_NSYM_indexes.push_back(sym_idx);
- type = eSymbolTypeScopeBegin;
- }
+ // Skip these if we want minimal symbol tables
+ add_nlist = false;
break;
case StabEndSymbol:
@@ -2852,22 +2865,8 @@ ObjectFileMachO::ParseSymtab (bool minim
// Set the size of the N_BNSYM to the terminating index of this N_ENSYM
// so that we can always skip the entire symbol if we need to navigate
// more quickly at the source level when parsing STABS
- if (minimize)
- {
- // Skip these if we want minimal symbol tables
- add_nlist = false;
- }
- else
- {
- if ( !N_NSYM_indexes.empty() )
- {
- symbol_ptr = symtab->SymbolAtIndex(N_NSYM_indexes.back());
- symbol_ptr->SetByteSize(sym_idx + 1);
- symbol_ptr->SetSizeIsSibling(true);
- N_NSYM_indexes.pop_back();
- }
- type = eSymbolTypeScopeEnd;
- }
+ // Skip these if we want minimal symbol tables
+ add_nlist = false;
break;
@@ -2897,15 +2896,14 @@ ObjectFileMachO::ParseSymtab (bool minim
type = eSymbolTypeSourceFile;
if (symbol_name == NULL)
{
- if (minimize)
- add_nlist = false;
+ add_nlist = false;
if (N_SO_index != UINT32_MAX)
{
// Set the size of the N_SO to the terminating index of this N_SO
// so that we can always skip the entire N_SO if we need to navigate
// more quickly at the source level when parsing STABS
symbol_ptr = symtab->SymbolAtIndex(N_SO_index);
- symbol_ptr->SetByteSize(sym_idx + (minimize ? 0 : 1));
+ symbol_ptr->SetByteSize(sym_idx);
symbol_ptr->SetSizeIsSibling(true);
}
N_NSYM_indexes.clear();
@@ -2922,7 +2920,7 @@ ObjectFileMachO::ParseSymtab (bool minim
const bool N_SO_has_full_path = symbol_name[0] == '/';
if (N_SO_has_full_path)
{
- if (minimize && (N_SO_index == sym_idx - 1) && ((sym_idx - 1) < num_syms))
+ if ((N_SO_index == sym_idx - 1) && ((sym_idx - 1) < num_syms))
{
// We have two consecutive N_SO entries where the first contains a directory
// and the second contains a full path.
@@ -2937,7 +2935,7 @@ ObjectFileMachO::ParseSymtab (bool minim
N_SO_index = sym_idx;
}
}
- else if (minimize && (N_SO_index == sym_idx - 1) && ((sym_idx - 1) < num_syms))
+ else if ((N_SO_index == sym_idx - 1) && ((sym_idx - 1) < num_syms))
{
// This is usually the second N_SO entry that contains just the filename,
// so here we combine it with the first one if we are minimizing the symbol table
@@ -3021,8 +3019,7 @@ ObjectFileMachO::ParseSymtab (bool minim
type = eSymbolTypeHeaderFile;
// We currently don't use the header files on darwin
- if (minimize)
- add_nlist = false;
+ add_nlist = false;
break;
case StabCompilerParameters:
@@ -3275,7 +3272,6 @@ ObjectFileMachO::ParseSymtab (bool minim
if (add_nlist)
{
uint64_t symbol_value = nlist.n_value;
- bool symbol_name_is_mangled = false;
if (symbol_name_non_abi_mangled)
{
@@ -3284,6 +3280,8 @@ ObjectFileMachO::ParseSymtab (bool minim
}
else
{
+ bool symbol_name_is_mangled = false;
+
if (symbol_name && symbol_name[0] == '_')
{
symbol_name_is_mangled = symbol_name[1] == '_';
@@ -3293,9 +3291,11 @@ ObjectFileMachO::ParseSymtab (bool minim
if (symbol_name)
{
ConstString const_symbol_name(symbol_name);
- if (is_gsym)
- N_GSYM_name_to_sym_idx[const_symbol_name.GetCString()] = sym_idx;
sym[sym_idx].GetMangled().SetValue(const_symbol_name, symbol_name_is_mangled);
+ if (is_gsym && is_debug)
+ {
+ N_GSYM_name_to_sym_idx[sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString()] = sym_idx;
+ }
}
}
if (symbol_section)
@@ -3357,8 +3357,7 @@ ObjectFileMachO::ParseSymtab (bool minim
ValueToSymbolIndexMap::const_iterator pos = N_FUN_addr_to_sym_idx.find (nlist.n_value);
if (pos != N_FUN_addr_to_sym_idx.end())
{
- if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) ||
- (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName()))
+ if (sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled) == sym[pos->second].GetMangled().GetName(Mangled::ePreferMangled))
{
m_nlist_idx_to_sym_idx[nlist_idx] = pos->second;
// We just need the flags from the linker symbol, so put these flags
@@ -3378,8 +3377,7 @@ ObjectFileMachO::ParseSymtab (bool minim
ValueToSymbolIndexMap::const_iterator pos = N_STSYM_addr_to_sym_idx.find (nlist.n_value);
if (pos != N_STSYM_addr_to_sym_idx.end())
{
- if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) ||
- (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName()))
+ if (sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled) == sym[pos->second].GetMangled().GetName(Mangled::ePreferMangled))
{
m_nlist_idx_to_sym_idx[nlist_idx] = pos->second;
// We just need the flags from the linker symbol, so put these flags
@@ -3392,7 +3390,7 @@ ObjectFileMachO::ParseSymtab (bool minim
else
{
// Combine N_GSYM stab entries with the non stab symbol
- ConstNameToSymbolIndexMap::const_iterator pos = N_GSYM_name_to_sym_idx.find(sym[sym_idx].GetMangled().GetMangledName().GetCString());
+ ConstNameToSymbolIndexMap::const_iterator pos = N_GSYM_name_to_sym_idx.find(sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString());
if (pos != N_GSYM_name_to_sym_idx.end())
{
const uint32_t GSYM_sym_idx = pos->second;
@@ -3639,6 +3637,16 @@ ObjectFileMachO::ParseSymtab (bool minim
}
}
}
+
+// StreamFile s(stdout, false);
+// s.Printf ("Symbol table before CalculateSymbolSizes():\n");
+// symtab->Dump(&s, NULL, eSortOrderNone);
+ // Set symbol byte sizes correctly since mach-o nlist entries don't have sizes
+ symtab->CalculateSymbolSizes();
+
+// s.Printf ("Symbol table after CalculateSymbolSizes():\n");
+// symtab->Dump(&s, NULL, eSortOrderNone);
+
return symtab->GetNumSymbols();
}
return 0;
@@ -3663,8 +3671,9 @@ ObjectFileMachO::Dump (Stream *s)
*s << ", file = '" << m_file << "', arch = " << header_arch.GetArchitectureName() << "\n";
- if (m_sections_ap.get())
- m_sections_ap->Dump(s, NULL, true, UINT32_MAX);
+ SectionList *sections = GetSectionList();
+ if (sections)
+ sections->Dump(s, NULL, true, UINT32_MAX);
if (m_symtab_ap.get())
m_symtab_ap->Dump(s, NULL, eSortOrderNone);
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=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h Tue Jul 9 20:23:25 2013
@@ -102,10 +102,13 @@ public:
GetAddressClass (lldb::addr_t file_addr);
virtual lldb_private::Symtab *
- GetSymtab(uint32_t flags = 0);
+ GetSymtab();
- virtual lldb_private::SectionList *
- GetSectionList();
+ virtual bool
+ IsStripped ();
+
+ virtual void
+ CreateSections (lldb_private::SectionList &unified_section_list);
virtual void
Dump (lldb_private::Stream *s);
@@ -195,10 +198,7 @@ protected:
bool m_thread_context_offsets_valid;
size_t
- ParseSections ();
-
- size_t
- ParseSymtab (bool minimize);
+ ParseSymtab ();
};
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=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp Tue Jul 9 20:23:25 2013
@@ -511,7 +511,7 @@ ObjectFilePECOFF::GetSectionName(std::st
// GetNListSymtab
//----------------------------------------------------------------------
Symtab *
-ObjectFilePECOFF::GetSymtab(uint32_t flags)
+ObjectFilePECOFF::GetSymtab()
{
ModuleSP module_sp(GetModule());
if (module_sp)
@@ -597,16 +597,26 @@ ObjectFilePECOFF::GetSymtab(uint32_t fla
}
-SectionList *
-ObjectFilePECOFF::GetSectionList()
+bool
+ObjectFilePECOFF::IsStripped ()
{
- ModuleSP module_sp(GetModule());
- if (module_sp)
+ // TODO: determine this for COFF
+ return false;
+}
+
+
+
+void
+ObjectFilePECOFF::CreateSections (SectionList &unified_section_list)
+{
+ if (!m_sections_ap.get())
{
- lldb_private::Mutex::Locker locker(module_sp->GetMutex());
- if (m_sections_ap.get() == NULL)
+ m_sections_ap.reset(new SectionList());
+
+ ModuleSP module_sp(GetModule());
+ if (module_sp)
{
- m_sections_ap.reset(new SectionList());
+ lldb_private::Mutex::Locker locker(module_sp->GetMutex());
const uint32_t nsects = m_sect_headers.size();
ModuleSP module_sp (GetModule());
for (uint32_t idx = 0; idx<nsects; ++idx)
@@ -710,13 +720,11 @@ ObjectFilePECOFF::GetSectionList()
//section_sp->SetIsEncrypted (segment_is_encrypted);
- m_sections_ap->AddSection(section_sp);
+ unified_section_list.AddSection(section_sp);
+ m_sections_ap->AddSection (section_sp);
}
-
- m_sections_ap->Finalize(); // Now that we're done adding sections, finalize to build fast-lookup caches
}
}
- return m_sections_ap.get();
}
bool
@@ -754,8 +762,9 @@ ObjectFilePECOFF::Dump(Stream *s)
*s << ", file = '" << m_file << "', arch = " << header_arch.GetArchitectureName() << "\n";
- if (m_sections_ap.get())
- m_sections_ap->Dump(s, NULL, true, UINT32_MAX);
+ SectionList *sections = GetSectionList();
+ if (sections)
+ sections->Dump(s, NULL, true, UINT32_MAX);
if (m_symtab_ap.get())
m_symtab_ap->Dump(s, NULL, eSortOrderNone);
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=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h Tue Jul 9 20:23:25 2013
@@ -86,10 +86,13 @@ public:
// GetAddressClass (lldb::addr_t file_addr);
//
virtual lldb_private::Symtab *
- GetSymtab(uint32_t flags = 0);
+ GetSymtab ();
- virtual lldb_private::SectionList *
- GetSectionList();
+ virtual bool
+ IsStripped ();
+
+ virtual void
+ CreateSections (lldb_private::SectionList &unified_section_list);
virtual void
Dump (lldb_private::Stream *s);
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Jul 9 20:23:25 2013
@@ -543,7 +543,7 @@ SymbolFileDWARF::InitializeObject()
ModuleSP module_sp (m_obj_file->GetModule());
if (module_sp)
{
- const SectionList *section_list = module_sp->GetUnifiedSectionList();
+ const SectionList *section_list = module_sp->GetSectionList();
const Section* section = section_list->FindSectionByName(GetDWARFMachOSegmentName ()).get();
@@ -706,7 +706,7 @@ SymbolFileDWARF::GetCachedSectionData (u
{
ModuleSP module_sp (m_obj_file->GetModule());
m_flags.Set (got_flag);
- const SectionList *section_list = module_sp->GetUnifiedSectionList();
+ const SectionList *section_list = module_sp->GetSectionList();
if (section_list)
{
SectionSP section_sp (section_list->FindSectionByType(sect_type, true));
@@ -1056,7 +1056,7 @@ SymbolFileDWARF::ParseCompileUnitFunctio
if (lowest_func_addr != LLDB_INVALID_ADDRESS && lowest_func_addr <= highest_func_addr)
{
ModuleSP module_sp (m_obj_file->GetModule());
- func_range.GetBaseAddress().ResolveAddressUsingFileSections (lowest_func_addr, module_sp->GetUnifiedSectionList());
+ func_range.GetBaseAddress().ResolveAddressUsingFileSections (lowest_func_addr, module_sp->GetSectionList());
if (func_range.GetBaseAddress().IsValid())
func_range.SetByteSize(highest_func_addr - lowest_func_addr);
}
@@ -4723,7 +4723,7 @@ SymbolFileDWARF::GetObjCClassSymbol (con
Symbol *objc_class_symbol = NULL;
if (m_obj_file)
{
- Symtab *symtab = m_obj_file->GetSymtab (ObjectFile::eSymtabFromUnifiedSectionList);
+ Symtab *symtab = m_obj_file->GetSymtab ();
if (symtab)
{
objc_class_symbol = symtab->FindFirstSymbolWithNameAndType (objc_class_name,
@@ -7437,7 +7437,7 @@ SymbolFileDWARF::ParseVariableDIE
ObjectFile *debug_map_objfile = debug_map_symfile->GetObjectFile();
if (debug_map_objfile)
{
- Symtab *debug_map_symtab = debug_map_objfile->GetSymtab(ObjectFile::eSymtabFromUnifiedSectionList);
+ Symtab *debug_map_symtab = debug_map_objfile->GetSymtab();
if (debug_map_symtab)
{
Symbol *exe_symbol = debug_map_symtab->FindFirstSymbolWithNameAndType (const_name,
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Tue Jul 9 20:23:25 2013
@@ -75,9 +75,9 @@ SymbolFileDWARFDebugMap::CompileUnitInfo
{
for (auto comp_unit_info : cu_infos)
{
- Symtab *exe_symtab = exe_symfile->GetObjectFile()->GetSymtab(ObjectFile::eSymtabFromUnifiedSectionList);
+ Symtab *exe_symtab = exe_symfile->GetObjectFile()->GetSymtab();
ModuleSP oso_module_sp (oso_objfile->GetModule());
- Symtab *oso_symtab = oso_objfile->GetSymtab(ObjectFile::eSymtabFromUnifiedSectionList);
+ Symtab *oso_symtab = oso_objfile->GetSymtab();
///const uint32_t fun_resolve_flags = SymbolContext::Module | eSymbolContextCompUnit | eSymbolContextFunction;
//SectionList *oso_sections = oso_objfile->Sections();
@@ -169,7 +169,7 @@ SymbolFileDWARFDebugMap::CompileUnitInfo
exe_symfile->FinalizeOSOFileRanges (this);
// We don't need the symbols anymore for the .o files
- oso_objfile->ClearSymtab(ObjectFile::eSymtabFromUnifiedSectionList);
+ oso_objfile->ClearSymtab();
}
}
return file_range_map;
@@ -325,12 +325,36 @@ SymbolFileDWARFDebugMap::InitOSO()
return;
m_flags.set(kHaveInitializedOSOs);
+
+ // If the object file has been stripped, there is no sense in looking further
+ // as all of the debug symbols for the debug map will not be available
+ if (m_obj_file->IsStripped())
+ return;
+
+ // Also make sure the file type is some sort of executable. Core files, debug
+ // info files (dSYM), object files (.o files), and stub libraries all can
+ switch (m_obj_file->GetType())
+ {
+ case ObjectFile::eTypeInvalid:
+ case ObjectFile::eTypeCoreFile:
+ case ObjectFile::eTypeDebugInfo:
+ case ObjectFile::eTypeObjectFile:
+ case ObjectFile::eTypeStubLibrary:
+ case ObjectFile::eTypeUnknown:
+ return;
+
+ case ObjectFile::eTypeExecutable:
+ case ObjectFile::eTypeDynamicLinker:
+ case ObjectFile::eTypeSharedLibrary:
+ break;
+ }
+
// In order to get the abilities of this plug-in, we look at the list of
// N_OSO entries (object files) from the symbol table and make sure that
// these files exist and also contain valid DWARF. If we get any of that
// then we return the abilities of the first N_OSO's DWARF.
- Symtab* symtab = m_obj_file->GetSymtab(ObjectFile::eSymtabFromUnifiedSectionList);
+ Symtab* symtab = m_obj_file->GetSymtab();
if (symtab)
{
Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_MAP));
@@ -367,13 +391,7 @@ SymbolFileDWARFDebugMap::InitOSO()
{
const Symbol *symbol = symtab->SymbolAtIndex(sym_idx);
lldb::addr_t file_addr = symbol->GetAddress().GetFileAddress();
- // The N_GSYM and N_STSYM symbols have a byte size and calling
- // symbol->GetByteSize() can cause an infinite loop where
- // InitOSO() gets called over and over if we are in the process
- // of getting the symbol vendor (module->SymbolVendor()). So
- // use a safer call for now until we can fix this. This is related
- // to the unified section/symtab changes that just went in.
- lldb::addr_t byte_size = symtab->CalculateSymbolSize(const_cast<Symbol *>(symbol));
+ lldb::addr_t byte_size = symbol->GetByteSize();
DebugMap::Entry debug_map_entry(file_addr, byte_size, OSOEntry(sym_idx, LLDB_INVALID_ADDRESS));
m_debug_map.Append(debug_map_entry);
}
@@ -599,27 +617,17 @@ SymbolFileDWARFDebugMap::CalculateAbilit
const uint32_t oso_index_count = GetNumCompileUnits();
if (oso_index_count > 0)
{
- const uint32_t dwarf_abilities = SymbolFile::CompileUnits |
- SymbolFile::Functions |
- SymbolFile::Blocks |
- SymbolFile::GlobalVariables |
- SymbolFile::LocalVariables |
- SymbolFile::VariableTypes |
- SymbolFile::LineTables;
-
InitOSO();
if (!m_compile_unit_infos.empty())
- return dwarf_abilities;
-// for (uint32_t oso_idx=0; oso_idx<oso_index_count; ++oso_idx)
-// {
-// SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx);
-// if (oso_dwarf)
-// {
-// uint32_t oso_abilities = oso_dwarf->GetAbilities();
-// if ((oso_abilities & dwarf_abilities) == dwarf_abilities)
-// return oso_abilities;
-// }
-// }
+ {
+ return SymbolFile::CompileUnits |
+ SymbolFile::Functions |
+ SymbolFile::Blocks |
+ SymbolFile::GlobalVariables |
+ SymbolFile::LocalVariables |
+ SymbolFile::VariableTypes |
+ SymbolFile::LineTables ;
+ }
}
return 0;
}
@@ -783,7 +791,7 @@ uint32_t
SymbolFileDWARFDebugMap::ResolveSymbolContext (const Address& exe_so_addr, uint32_t resolve_scope, SymbolContext& sc)
{
uint32_t resolved_flags = 0;
- Symtab* symtab = m_obj_file->GetSymtab(ObjectFile::eSymtabFromUnifiedSectionList);
+ Symtab* symtab = m_obj_file->GetSymtab();
if (symtab)
{
const addr_t exe_file_addr = exe_so_addr.GetFileAddress();
@@ -1460,12 +1468,10 @@ SymbolFileDWARFDebugMap::AddOSOFileRange
lldb::addr_t oso_file_addr,
lldb::addr_t oso_byte_size)
{
- assert (cu_info);// REMOVE THIS PRIOR TO CHECKIN
const uint32_t debug_map_idx = m_debug_map.FindEntryIndexThatContains(exe_file_addr);
if (debug_map_idx != UINT32_MAX)
{
DebugMap::Entry *debug_map_entry = m_debug_map.FindEntryThatContains(exe_file_addr);
- assert (debug_map_entry);// REMOVE THIS PRIOR TO CHECKIN
debug_map_entry->data.SetOSOFileAddress(oso_file_addr);
cu_info->file_range_map.Append(FileRangeMap::Entry(oso_file_addr, oso_byte_size, exe_file_addr));
return true;
Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Tue Jul 9 20:23:25 2013
@@ -93,7 +93,7 @@ SymbolFileSymtab::CalculateAbilities ()
uint32_t abilities = 0;
if (m_obj_file)
{
- const Symtab *symtab = m_obj_file->GetSymtab(ObjectFile::eSymtabFromUnifiedSectionList);
+ const Symtab *symtab = m_obj_file->GetSymtab();
if (symtab)
{
//----------------------------------------------------------------------
@@ -159,7 +159,7 @@ SymbolFileSymtab::ParseCompileUnitAtInde
// the entire object file
if (idx < m_source_indexes.size())
{
- const Symbol *cu_symbol = m_obj_file->GetSymtab(ObjectFile::eSymtabFromUnifiedSectionList)->SymbolAtIndex(m_source_indexes[idx]);
+ const Symbol *cu_symbol = m_obj_file->GetSymtab()->SymbolAtIndex(m_source_indexes[idx]);
if (cu_symbol)
cu_sp.reset(new CompileUnit (m_obj_file->GetModule(), NULL, cu_symbol->GetMangled().GetName().AsCString(), 0, eLanguageTypeUnknown));
}
@@ -179,7 +179,7 @@ SymbolFileSymtab::ParseCompileUnitFuncti
size_t num_added = 0;
// We must at least have a valid compile unit
assert (sc.comp_unit != NULL);
- const Symtab *symtab = m_obj_file->GetSymtab(ObjectFile::eSymtabFromUnifiedSectionList);
+ const Symtab *symtab = m_obj_file->GetSymtab();
const Symbol *curr_symbol = NULL;
const Symbol *next_symbol = NULL;
// const char *prefix = m_obj_file->SymbolPrefix();
@@ -307,13 +307,13 @@ SymbolFileSymtab::FindNamespace (const S
uint32_t
SymbolFileSymtab::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc)
{
- if (m_obj_file->GetSymtab(ObjectFile::eSymtabFromUnifiedSectionList) == NULL)
+ if (m_obj_file->GetSymtab() == NULL)
return 0;
uint32_t resolved_flags = 0;
if (resolve_scope & eSymbolContextSymbol)
{
- sc.symbol = m_obj_file->GetSymtab(ObjectFile::eSymtabFromUnifiedSectionList)->FindSymbolContainingFileAddress(so_addr.GetFileAddress());
+ sc.symbol = m_obj_file->GetSymtab()->FindSymbolContainingFileAddress(so_addr.GetFileAddress());
if (sc.symbol)
resolved_flags |= eSymbolContextSymbol;
}
Modified: lldb/trunk/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp Tue Jul 9 20:23:25 2013
@@ -141,7 +141,7 @@ SymbolVendorELF::CreateInstance (const l
if (symbol_vendor)
{
// Get the module unified section list and add our debug sections to that.
- SectionList *module_section_list = module_sp->GetUnifiedSectionList();
+ SectionList *module_section_list = module_sp->GetSectionList();
SectionList *objfile_section_list = dsym_objfile_sp->GetSectionList();
static const SectionType g_sections[] =
@@ -172,7 +172,6 @@ SymbolVendorELF::CreateInstance (const l
module_section_list->AddSection (section_sp);
}
}
- module_section_list->Finalize();
symbol_vendor->AddSymbolFileRepresentation (dsym_objfile_sp);
return symbol_vendor;
Modified: lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp Tue Jul 9 20:23:25 2013
@@ -83,51 +83,6 @@ UUIDsMatch(Module *module, ObjectFile *o
return false;
}
-static bool
-ReplaceDSYMSectionsWithExecutableSections (ObjectFile *exec_objfile, ObjectFile *dsym_objfile)
-{
- // We need both the executable and the dSYM to live off of the
- // same section lists. So we take all of the sections from the
- // executable, and replace them in the dSYM. This allows section
- // offset addresses that come from the dSYM to automatically
- // get updated as images (shared libraries) get loaded and
- // unloaded.
- SectionList *exec_section_list = exec_objfile->GetSectionList();
- SectionList *dsym_section_list = dsym_objfile->GetSectionList();
- if (exec_section_list && dsym_section_list)
- {
- const uint32_t num_exec_sections = dsym_section_list->GetSize();
- uint32_t exec_sect_idx;
- for (exec_sect_idx = 0; exec_sect_idx < num_exec_sections; ++exec_sect_idx)
- {
- SectionSP exec_sect_sp(exec_section_list->GetSectionAtIndex(exec_sect_idx));
- if (exec_sect_sp.get())
- {
- // Try and replace any sections that exist in both the executable
- // and in the dSYM with those from the executable. If we fail to
- // replace the one in the dSYM, then add the executable section to
- // the dSYM.
- SectionSP dsym_sect_sp(dsym_section_list->FindSectionByID(exec_sect_sp->GetID()));
- if (dsym_sect_sp.get() && dsym_sect_sp->GetName() != exec_sect_sp->GetName())
- {
- // The sections in a dSYM are normally a superset of the sections in an executable.
- // If we find a section # in the exectuable & dSYM that don't have the same name,
- // something has changed since the dSYM was written. The mach_kernel DSTROOT binary
- // has a CTF segment added, for instance, and it's easiest to simply not add that to
- // the dSYM - none of the nlist entries are going to have references to that section.
- continue;
- }
- if (dsym_section_list->ReplaceSection(exec_sect_sp->GetID(), exec_sect_sp, 0) == false)
- dsym_section_list->AddSection(exec_sect_sp);
- }
- }
-
- dsym_section_list->Finalize(); // Now that we're done adding sections, finalize to build fast-lookup caches
- return true;
- }
- return false;
-}
-
void
SymbolVendorMacOSX::Initialize()
{
@@ -321,16 +276,6 @@ SymbolVendorMacOSX::CreateInstance (cons
}
}
- if (ReplaceDSYMSectionsWithExecutableSections (obj_file, dsym_objfile_sp.get()))
- {
- SectionList *section_list = dsym_objfile_sp.get()->GetSectionList();
- if (section_list)
- {
- section_list->Copy (module_sp->GetUnifiedSectionList());
- section_list->Finalize ();
- }
- }
-
symbol_vendor->AddSymbolFileRepresentation(dsym_objfile_sp);
return symbol_vendor;
}
Modified: lldb/trunk/source/Symbol/ObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ObjectFile.cpp (original)
+++ lldb/trunk/source/Symbol/ObjectFile.cpp Tue Jul 9 20:23:25 2013
@@ -243,10 +243,8 @@ ObjectFile::ObjectFile (const lldb::Modu
m_unwind_table (*this),
m_process_wp(),
m_memory_addr (LLDB_INVALID_ADDRESS),
- m_sections_ap (),
- m_symtab_ap (),
- m_symtab_unified_ap (),
- m_symtab_unified_revisionid (0)
+ m_sections_ap(),
+ m_symtab_ap ()
{
if (file_spec_ptr)
m_file = *file_spec_ptr;
@@ -292,10 +290,8 @@ ObjectFile::ObjectFile (const lldb::Modu
m_unwind_table (*this),
m_process_wp (process_sp),
m_memory_addr (header_addr),
- m_sections_ap (),
- m_symtab_ap (),
- m_symtab_unified_ap (),
- m_symtab_unified_revisionid (0)
+ m_sections_ap(),
+ m_symtab_ap ()
{
if (header_data_sp)
m_data.SetData (header_data_sp, 0, header_data_sp->GetByteSize());
@@ -331,7 +327,7 @@ ObjectFile::SetModulesArchitecture (cons
AddressClass
ObjectFile::GetAddressClass (addr_t file_addr)
{
- Symtab *symtab = GetSymtab(ObjectFile::eSymtabFromUnifiedSectionList);
+ Symtab *symtab = GetSymtab();
if (symtab)
{
Symbol *symbol = symtab->FindSymbolContainingFileAddress(file_addr);
@@ -586,29 +582,31 @@ ObjectFile::SplitArchivePathWithObject (
}
void
-ObjectFile::ClearSymtab (uint32_t flags)
+ObjectFile::ClearSymtab ()
{
ModuleSP module_sp(GetModule());
if (module_sp)
{
lldb_private::Mutex::Locker locker(module_sp->GetMutex());
- bool unified_section_list = !!(flags & ObjectFile::eSymtabFromUnifiedSectionList);
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log)
{
- log->Printf ("%p ObjectFile::ClearSymtab (%s) symtab = %p",
+ log->Printf ("%p ObjectFile::ClearSymtab () symtab = %p",
this,
- unified_section_list ? "unified" : "",
- unified_section_list ? m_symtab_unified_ap.get() : m_symtab_ap.get());
- }
- if (unified_section_list)
- {
- m_symtab_unified_ap.reset();
- m_symtab_unified_revisionid = 0;
- }
- else
- {
- m_symtab_ap.reset();
+ m_symtab_ap.get());
}
+ m_symtab_ap.reset();
+ }
+}
+
+SectionList *
+ObjectFile::GetSectionList()
+{
+ if (m_sections_ap.get() == NULL)
+ {
+ ModuleSP module_sp(GetModule());
+ if (module_sp)
+ CreateSections(*module_sp->GetUnifiedSectionList());
}
+ return m_sections_ap.get();
}
Modified: lldb/trunk/source/Symbol/Symbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symbol.cpp (original)
+++ lldb/trunk/source/Symbol/Symbol.cpp Tue Jul 9 20:23:25 2013
@@ -33,7 +33,7 @@ Symbol::Symbol() :
m_is_external (false),
m_size_is_sibling (false),
m_size_is_synthesized (false),
- m_calculated_size (false),
+ m_size_is_valid (false),
m_demangled_is_synthesized (false),
m_type (eSymbolTypeInvalid),
m_mangled (),
@@ -67,7 +67,7 @@ Symbol::Symbol
m_is_external (external),
m_size_is_sibling (false),
m_size_is_synthesized (false),
- m_calculated_size (size_is_valid || size > 0),
+ m_size_is_valid (size_is_valid || size > 0),
m_demangled_is_synthesized (false),
m_type (type),
m_mangled (ConstString(name), name_is_mangled),
@@ -99,7 +99,7 @@ Symbol::Symbol
m_is_external (external),
m_size_is_sibling (false),
m_size_is_synthesized (false),
- m_calculated_size (size_is_valid || range.GetByteSize() > 0),
+ m_size_is_valid (size_is_valid || range.GetByteSize() > 0),
m_demangled_is_synthesized (false),
m_type (type),
m_mangled (ConstString(name), name_is_mangled),
@@ -118,7 +118,7 @@ Symbol::Symbol(const Symbol& rhs):
m_is_external (rhs.m_is_external),
m_size_is_sibling (rhs.m_size_is_sibling),
m_size_is_synthesized (false),
- m_calculated_size (rhs.m_calculated_size),
+ m_size_is_valid (rhs.m_size_is_valid),
m_demangled_is_synthesized (rhs.m_demangled_is_synthesized),
m_type (rhs.m_type),
m_mangled (rhs.m_mangled),
@@ -141,7 +141,7 @@ Symbol::operator= (const Symbol& rhs)
m_is_external = rhs.m_is_external;
m_size_is_sibling = rhs.m_size_is_sibling;
m_size_is_synthesized = rhs.m_size_is_sibling;
- m_calculated_size = rhs.m_calculated_size;
+ m_size_is_valid = rhs.m_size_is_valid;
m_demangled_is_synthesized = rhs.m_demangled_is_synthesized;
m_type = rhs.m_type;
m_mangled = rhs.m_mangled;
@@ -163,7 +163,7 @@ Symbol::Clear()
m_is_external = false;
m_size_is_sibling = false;
m_size_is_synthesized = false;
- m_calculated_size = false;
+ m_size_is_valid = false;
m_demangled_is_synthesized = false;
m_type = eSymbolTypeInvalid;
m_flags = 0;
@@ -410,7 +410,6 @@ Symbol::GetTypeAsString() const
return "<unknown SymbolType>";
}
-
void
Symbol::CalculateSymbolContext (SymbolContext *sc)
{
@@ -436,7 +435,6 @@ Symbol::CalculateSymbolContextSymbol ()
return this;
}
-
void
Symbol::DumpSymbolContext (Stream *s)
{
@@ -456,32 +454,9 @@ Symbol::DumpSymbolContext (Stream *s)
s->Printf("Symbol{0x%8.8x}", GetID());
}
-
lldb::addr_t
Symbol::GetByteSize () const
{
- addr_t byte_size = m_addr_range.GetByteSize();
- if (byte_size == 0 && !m_calculated_size)
- {
- const_cast<Symbol*>(this)->m_calculated_size = true;
- if (ValueIsAddress())
- {
- ModuleSP module_sp (GetAddress().GetModule());
- if (module_sp)
- {
- SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
- if (sym_vendor)
- {
- Symtab *symtab = sym_vendor->GetSymtab();
- if (symtab)
- {
- const_cast<Symbol*>(this)->SetByteSize (symtab->CalculateSymbolSize (const_cast<Symbol *>(this)));
- byte_size = m_addr_range.GetByteSize();
- }
- }
- }
- }
- }
- return byte_size;
+ return m_addr_range.GetByteSize();
}
Modified: lldb/trunk/source/Symbol/SymbolFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolFile.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolFile.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolFile.cpp Tue Jul 9 20:23:25 2013
@@ -24,6 +24,22 @@ SymbolFile::FindPlugin (ObjectFile* obj_
std::unique_ptr<SymbolFile> best_symfile_ap;
if (obj_file != NULL)
{
+
+ // We need to test the abilities of this section list. So create what it would
+ // be with this new obj_file.
+ lldb::ModuleSP module_sp(obj_file->GetModule());
+ if (module_sp)
+ {
+ // Default to the main module section list.
+ ObjectFile *module_obj_file = module_sp->GetObjectFile();
+ if (module_obj_file != obj_file)
+ {
+ // Make sure the main object file's sections are created
+ module_obj_file->GetSectionList();
+ obj_file->CreateSections (*module_sp->GetUnifiedSectionList());
+ }
+ }
+
// TODO: Load any plug-ins in the appropriate plug-in search paths and
// iterate over all of them to find the best one for the job.
Modified: lldb/trunk/source/Symbol/SymbolVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolVendor.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolVendor.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolVendor.cpp Tue Jul 9 20:23:25 2013
@@ -447,7 +447,7 @@ SymbolVendor::GetSymtab ()
if (objfile)
{
// Get symbol table from unified section list.
- return objfile->GetSymtab (ObjectFile::eSymtabFromUnifiedSectionList);
+ return objfile->GetSymtab ();
}
}
return NULL;
@@ -463,7 +463,7 @@ SymbolVendor::ClearSymtab()
if (objfile)
{
// Clear symbol table from unified section list.
- objfile->ClearSymtab (ObjectFile::eSymtabFromUnifiedSectionList);
+ objfile->ClearSymtab ();
}
}
}
Modified: lldb/trunk/source/Symbol/Symtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=185990&r1=185989&r2=185990&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symtab.cpp (original)
+++ lldb/trunk/source/Symbol/Symtab.cpp Tue Jul 9 20:23:25 2013
@@ -27,10 +27,10 @@ using namespace lldb_private;
Symtab::Symtab(ObjectFile *objfile) :
m_objfile (objfile),
m_symbols (),
- m_addr_indexes (),
+ m_file_addr_to_index (),
m_name_to_index (),
m_mutex (Mutex::eMutexTypeRecursive),
- m_addr_indexes_computed (false),
+ m_file_addr_to_index_computed (false),
m_name_indexes_computed (false)
{
}
@@ -63,9 +63,9 @@ Symtab::AddSymbol(const Symbol& symbol)
// when calling this function to avoid performance issues.
uint32_t symbol_idx = m_symbols.size();
m_name_to_index.Clear();
- m_addr_indexes.clear();
+ m_file_addr_to_index.Clear();
m_symbols.push_back(symbol);
- m_addr_indexes_computed = false;
+ m_file_addr_to_index_computed = false;
m_name_indexes_computed = false;
return symbol_idx;
}
@@ -144,19 +144,14 @@ Symtab::Dump (Stream *s, Target *target,
case eSortOrderByAddress:
s->PutCString (" (sorted by address):\n");
DumpSymbolHeader (s);
- if (!m_addr_indexes_computed)
+ if (!m_file_addr_to_index_computed)
InitAddressIndexes();
- const size_t num_symbols = GetNumSymbols();
- std::vector<uint32_t>::const_iterator pos;
- std::vector<uint32_t>::const_iterator end = m_addr_indexes.end();
- for (pos = m_addr_indexes.begin(); pos != end; ++pos)
+ const size_t num_entries = m_file_addr_to_index.GetSize();
+ for (size_t i=0; i<num_entries; ++i)
{
- size_t idx = *pos;
- if (idx < num_symbols)
- {
- s->Indent();
- m_symbols[idx].Dump(s, target, idx);
- }
+ s->Indent();
+ const uint32_t symbol_idx = m_file_addr_to_index.GetEntryRef(i).data;
+ m_symbols[symbol_idx].Dump(s, target, symbol_idx);
}
break;
}
@@ -943,92 +938,94 @@ void
Symtab::InitAddressIndexes()
{
// Protected function, no need to lock mutex...
- if (!m_addr_indexes_computed && !m_symbols.empty())
+ if (!m_file_addr_to_index_computed && !m_symbols.empty())
{
- m_addr_indexes_computed = true;
+ m_file_addr_to_index_computed = true;
+ FileRangeToIndexMap::Entry entry;
const_iterator begin = m_symbols.begin();
const_iterator end = m_symbols.end();
for (const_iterator pos = m_symbols.begin(); pos != end; ++pos)
{
if (pos->ValueIsAddress())
- m_addr_indexes.push_back (std::distance(begin, pos));
+ {
+ entry.SetRangeBase(pos->GetAddress().GetFileAddress());
+ entry.SetByteSize(pos->GetByteSize());
+ entry.data = std::distance(begin, pos);
+ m_file_addr_to_index.Append(entry);
+ }
}
+ const size_t num_entries = m_file_addr_to_index.GetSize();
+ if (num_entries > 0)
+ {
+ m_file_addr_to_index.Sort();
+ m_file_addr_to_index.CalculateSizesOfZeroByteSizeRanges();
+
+ // Now our last symbols might not have had sizes because there
+ // was no subsequent symbol to calculate the size from. If this is
+ // the case, then calculate the size by capping it at the end of the
+ // section in which the symbol resides
+ for (int i = num_entries - 1; i >= 0; --i)
+ {
+ const FileRangeToIndexMap::Entry &entry = m_file_addr_to_index.GetEntryRef(i);
+ // As we iterate backwards, as soon as we find a symbol with a valid
+ // byte size, we are done
+ if (entry.GetByteSize() > 0)
+ break;
+
+ // Cap the size to the end of the section in which the symbol resides
+ SectionSP section_sp (m_objfile->GetSectionList()->FindSectionContainingFileAddress (entry.GetRangeBase()));
+ if (section_sp)
+ {
+ const lldb::addr_t end_section_file_addr = section_sp->GetFileAddress() + section_sp->GetByteSize();
+ const lldb::addr_t symbol_file_addr = entry.GetRangeBase();
+ if (end_section_file_addr > symbol_file_addr)
+ {
+ Symbol &symbol = m_symbols[entry.data];
- SortSymbolIndexesByValue (m_addr_indexes, false);
- m_addr_indexes.push_back (UINT32_MAX); // Terminator for bsearch since we might need to look at the next symbol
+ symbol.SetByteSize(end_section_file_addr - symbol_file_addr);
+ symbol.SetSizeIsSynthesized(true);
+ }
+ }
+ }
+ // Sort again in case the range size changes the ordering
+ m_file_addr_to_index.Sort();
+ }
}
}
-size_t
-Symtab::CalculateSymbolSize (Symbol *symbol)
+void
+Symtab::CalculateSymbolSizes ()
{
Mutex::Locker locker (m_mutex);
- if (m_symbols.empty())
- return 0;
-
- // Make sure this symbol is from this symbol table...
- if (symbol < &m_symbols.front() || symbol > &m_symbols.back())
- return 0;
-
- size_t byte_size = 0;
-
- // Else if this is an address based symbol, figure out the delta between
- // it and the next address based symbol
- if (symbol->ValueIsAddress())
+ if (!m_symbols.empty())
{
- if (!m_addr_indexes_computed)
+ if (!m_file_addr_to_index_computed)
InitAddressIndexes();
- const size_t num_addr_indexes = m_addr_indexes.size();
- const lldb::addr_t symbol_file_addr = symbol->GetAddress().GetFileAddress();
- SymbolSearchInfo info = FindIndexPtrForSymbolContainingAddress (this,
- symbol_file_addr,
- &m_addr_indexes.front(),
- num_addr_indexes);
- if (info.match_index_ptr != NULL)
+
+ const size_t num_entries = m_file_addr_to_index.GetSize();
+
+ for (size_t i = 0; i < num_entries; ++i)
{
- // We can figure out the address range of all symbols except the
- // last one by taking the delta between the current symbol and
- // the next symbol
-
- for (uint32_t addr_index = info.match_index_ptr - &m_addr_indexes.front() + 1;
- addr_index < num_addr_indexes;
- ++addr_index)
+ // The entries in the m_file_addr_to_index have calculated the sizes already
+ // so we will use this size if we need to.
+ const FileRangeToIndexMap::Entry &entry = m_file_addr_to_index.GetEntryRef(i);
+
+ Symbol &symbol = m_symbols[entry.data];
+
+ // If the symbol size is already valid, no need to do anything
+ if (symbol.GetByteSizeIsValid())
+ continue;
+
+ const addr_t range_size = entry.GetByteSize();
+ if (range_size > 0)
{
- Symbol *next_symbol = SymbolAtIndex(m_addr_indexes[addr_index]);
- if (next_symbol == NULL)
- {
- // No next symbol take the size to be the remaining bytes in the section
- // in which the symbol resides
- SectionSP section_sp (m_objfile->GetSectionList()->FindSectionContainingFileAddress (symbol_file_addr));
- if (section_sp)
- {
- const lldb::addr_t end_section_file_addr = section_sp->GetFileAddress() + section_sp->GetByteSize();
- if (end_section_file_addr > symbol_file_addr)
- {
- byte_size = end_section_file_addr - symbol_file_addr;
- symbol->SetByteSize(byte_size);
- symbol->SetSizeIsSynthesized(true);
- break;
- }
- }
- }
- else
- {
- const lldb::addr_t next_file_addr = next_symbol->GetAddress().GetFileAddress();
- if (next_file_addr > symbol_file_addr)
- {
- byte_size = next_file_addr - symbol_file_addr;
- symbol->SetByteSize(byte_size);
- symbol->SetSizeIsSynthesized(true);
- break;
- }
- }
+ symbol.SetByteSize(range_size);
+ symbol.SetSizeIsSynthesized(true);
}
}
}
- return byte_size;
}
Symbol *
@@ -1036,6 +1033,7 @@ Symtab::FindSymbolContainingFileAddress
{
Mutex::Locker locker (m_mutex);
+
SymbolSearchInfo info = { this, file_addr, NULL, NULL, 0 };
::bsearch (&info,
@@ -1074,10 +1072,13 @@ Symtab::FindSymbolContainingFileAddress
{
Mutex::Locker locker (m_mutex);
- if (!m_addr_indexes_computed)
+ if (!m_file_addr_to_index_computed)
InitAddressIndexes();
- return FindSymbolContainingFileAddress (file_addr, &m_addr_indexes[0], m_addr_indexes.size());
+ const FileRangeToIndexMap::Entry *entry = m_file_addr_to_index.FindEntryThatContains(file_addr);
+ if (entry)
+ return SymbolAtIndex(entry->data);
+ return NULL;
}
void
More information about the lldb-commits
mailing list