summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Module.cpp
diff options
context:
space:
mode:
authorMichael Sartain <mikesart@valvesoftware.com>2013-07-01 19:45:50 +0000
committerMichael Sartain <mikesart@valvesoftware.com>2013-07-01 19:45:50 +0000
commita7499c98301e847d2e525921801e1edcc44e34da (patch)
tree4b78835f6badd7ce118ed5175279f4efc26f0c80 /lldb/source/Core/Module.cpp
parent82bedb1f3ba396b32b0f2275e5e1003e4b143398 (diff)
downloadbcm5719-llvm-a7499c98301e847d2e525921801e1edcc44e34da.tar.gz
bcm5719-llvm-a7499c98301e847d2e525921801e1edcc44e34da.zip
Split symbol support for ELF and Linux.
llvm-svn: 185366
Diffstat (limited to 'lldb/source/Core/Module.cpp')
-rw-r--r--lldb/source/Core/Module.cpp112
1 files changed, 72 insertions, 40 deletions
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index df0ffb6ed02..e5df43287d1 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -33,6 +33,7 @@
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Symbol/SymbolFile.h"
using namespace lldb;
using namespace lldb_private;
@@ -244,6 +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_symfile_ap.reset();
m_objfile_sp.reset();
}
@@ -480,10 +482,10 @@ Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve
// Resolve the symbol if requested, but don't re-look it up if we've already found it.
if (resolve_scope & eSymbolContextSymbol && !(resolved_flags & eSymbolContextSymbol))
{
- ObjectFile* ofile = GetObjectFile();
- if (ofile)
+ SymbolVendor* sym_vendor = GetSymbolVendor();
+ if (sym_vendor)
{
- Symtab *symtab = ofile->GetSymtab();
+ Symtab *symtab = sym_vendor->GetSymtab();
if (symtab)
{
if (so_addr.IsSectionOffset())
@@ -613,6 +615,7 @@ Module::FindFunctions (const ConstString &name,
match_name_after_lookup);
if (symbols)
+ {
symbols->FindFunctions(lookup_name,
namespace_decl,
lookup_name_type_mask,
@@ -620,13 +623,10 @@ Module::FindFunctions (const ConstString &name,
append,
sc_list);
- // Now check our symbol table for symbols that are code symbols if requested
- if (include_symbols)
- {
- ObjectFile *objfile = GetObjectFile();
- if (objfile)
+ // Now check our symbol table for symbols that are code symbols if requested
+ if (include_symbols)
{
- Symtab *symtab = objfile->GetSymtab();
+ Symtab *symtab = symbols->GetSymtab();
if (symtab)
symtab->FindFunctionSymbols(lookup_name, lookup_name_type_mask, sc_list);
}
@@ -652,20 +652,17 @@ Module::FindFunctions (const ConstString &name,
++i;
}
}
-
}
else
{
if (symbols)
+ {
symbols->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list);
- // Now check our symbol table for symbols that are code symbols if requested
- if (include_symbols)
- {
- ObjectFile *objfile = GetObjectFile();
- if (objfile)
+ // Now check our symbol table for symbols that are code symbols if requested
+ if (include_symbols)
{
- Symtab *symtab = objfile->GetSymtab();
+ Symtab *symtab = symbols->GetSymtab();
if (symtab)
symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
}
@@ -689,14 +686,13 @@ Module::FindFunctions (const RegularExpression& regex,
SymbolVendor *symbols = GetSymbolVendor ();
if (symbols)
- symbols->FindFunctions(regex, include_inlines, append, sc_list);
- // Now check our symbol table for symbols that are code symbols if requested
- if (include_symbols)
{
- ObjectFile *objfile = GetObjectFile();
- if (objfile)
+ symbols->FindFunctions(regex, include_inlines, append, sc_list);
+
+ // Now check our symbol table for symbols that are code symbols if requested
+ if (include_symbols)
{
- Symtab *symtab = objfile->GetSymtab();
+ Symtab *symtab = symbols->GetSymtab();
if (symtab)
{
std::vector<uint32_t> symbol_indexes;
@@ -1067,13 +1063,12 @@ Module::Dump(Stream *s)
m_object_name ? ")" : "");
s->IndentMore();
+
ObjectFile *objfile = GetObjectFile ();
-
if (objfile)
objfile->Dump(s);
SymbolVendor *symbols = GetSymbolVendor ();
-
if (symbols)
symbols->Dump(s);
@@ -1115,15 +1110,29 @@ Module::GetObjectFile()
data_offset);
if (m_objfile_sp)
{
- // Once we get the object file, update our module with the object file's
- // architecture since it might differ in vendor/os if some parts were
- // unknown.
+ // Once we get the object file, update our module with the object file's
+ // 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::GetUnifiedSectionList()
+{
+ return m_unified_sections_ap.get();
+}
const Symbol *
Module::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symbol_type)
@@ -1132,10 +1141,10 @@ Module::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symb
"Module::FindFirstSymbolWithNameAndType (name = %s, type = %i)",
name.AsCString(),
symbol_type);
- ObjectFile *objfile = GetObjectFile();
- if (objfile)
+ SymbolVendor* sym_vendor = GetSymbolVendor();
+ if (sym_vendor)
{
- Symtab *symtab = objfile->GetSymtab();
+ Symtab *symtab = sym_vendor->GetSymtab();
if (symtab)
return symtab->FindFirstSymbolWithNameAndType (name, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny);
}
@@ -1170,10 +1179,10 @@ Module::FindFunctionSymbols (const ConstString &name,
"Module::FindSymbolsFunctions (name = %s, mask = 0x%8.8x)",
name.AsCString(),
name_type_mask);
- ObjectFile *objfile = GetObjectFile ();
- if (objfile)
+ SymbolVendor* sym_vendor = GetSymbolVendor();
+ if (sym_vendor)
{
- Symtab *symtab = objfile->GetSymtab();
+ Symtab *symtab = sym_vendor->GetSymtab();
if (symtab)
return symtab->FindFunctionSymbols (name, name_type_mask, sc_list);
}
@@ -1192,10 +1201,10 @@ Module::FindSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_t
name.AsCString(),
symbol_type);
const size_t initial_size = sc_list.GetSize();
- ObjectFile *objfile = GetObjectFile ();
- if (objfile)
+ SymbolVendor* sym_vendor = GetSymbolVendor();
+ if (sym_vendor)
{
- Symtab *symtab = objfile->GetSymtab();
+ Symtab *symtab = sym_vendor->GetSymtab();
if (symtab)
{
std::vector<uint32_t> symbol_indexes;
@@ -1217,10 +1226,10 @@ Module::FindSymbolsMatchingRegExAndType (const RegularExpression &regex, SymbolT
regex.GetText(),
symbol_type);
const size_t initial_size = sc_list.GetSize();
- ObjectFile *objfile = GetObjectFile ();
- if (objfile)
+ SymbolVendor* sym_vendor = GetSymbolVendor();
+ if (sym_vendor)
{
- Symtab *symtab = objfile->GetSymtab();
+ Symtab *symtab = sym_vendor->GetSymtab();
if (symtab)
{
std::vector<uint32_t> symbol_indexes;
@@ -1234,12 +1243,35 @@ Module::FindSymbolsMatchingRegExAndType (const RegularExpression &regex, SymbolT
void
Module::SetSymbolFileFileSpec (const FileSpec &file)
{
+ // Remove any sections in the unified section list that come from the current symbol vendor.
+ if (m_symfile_ap)
+ {
+ SectionList *section_list = GetUnifiedSectionList();
+ SymbolFile *symbol_file = m_symfile_ap->GetSymbolFile();
+ if (section_list && symbol_file)
+ {
+ ObjectFile *obj_file = symbol_file->GetObjectFile();
+ if (obj_file)
+ {
+ size_t num_sections = section_list->GetNumSections (0);
+ for (size_t idx = num_sections; idx > 0; --idx)
+ {
+ lldb::SectionSP section_sp (section_list->GetSectionAtIndex (idx - 1));
+ if (section_sp->GetObjectFile() == obj_file)
+ {
+ m_unified_sections_ap->DeleteSection (idx - 1);
+ }
+ }
+ m_unified_sections_ap->Finalize();
+ }
+ }
+ }
+
m_symfile_spec = file;
m_symfile_ap.reset();
m_did_load_symbol_vendor = false;
}
-
bool
Module::IsExecutable ()
{
OpenPOWER on IntegriCloud