summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Symbol/SymbolFile.h3
-rw-r--r--lldb/include/lldb/Symbol/SymbolVendor.h5
-rw-r--r--lldb/source/Symbol/SymbolFile.cpp15
-rw-r--r--lldb/source/Symbol/SymbolVendor.cpp34
-rw-r--r--lldb/unittests/Core/CMakeLists.txt2
-rw-r--r--lldb/unittests/Core/MangledTest.cpp6
-rw-r--r--lldb/unittests/ObjectFile/ELF/CMakeLists.txt2
-rw-r--r--lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp6
-rw-r--r--lldb/unittests/Symbol/CMakeLists.txt1
-rw-r--r--lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp3
-rw-r--r--lldb/unittests/Target/CMakeLists.txt1
-rw-r--r--lldb/unittests/Target/ModuleCacheTest.cpp3
12 files changed, 38 insertions, 43 deletions
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h
index e41f50e1944..183753a6c25 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -114,6 +114,8 @@ public:
uint32_t GetNumCompileUnits();
lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx);
+ Symtab *GetSymtab();
+
virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0;
virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0;
virtual bool ParseLineTable(CompileUnit &comp_unit) = 0;
@@ -246,6 +248,7 @@ protected:
ObjectFile *m_obj_file; // The object file that symbols can be extracted from.
llvm::Optional<std::vector<lldb::CompUnitSP>> m_compile_units;
TypeList m_type_list;
+ Symtab *m_symtab = nullptr;
uint32_t m_abilities;
bool m_calculated_abilities;
diff --git a/lldb/include/lldb/Symbol/SymbolVendor.h b/lldb/include/lldb/Symbol/SymbolVendor.h
index 413b1f4b958..504b7afb0ad 100644
--- a/lldb/include/lldb/Symbol/SymbolVendor.h
+++ b/lldb/include/lldb/Symbol/SymbolVendor.h
@@ -121,9 +121,6 @@ public:
// Get module unified section list symbol table.
virtual Symtab *GetSymtab();
- // Clear module unified section list symbol table.
- virtual void ClearSymtab();
-
/// Notify the SymbolVendor that the file addresses in the Sections
/// for this module have been changed.
virtual void SectionFileAddressesChanged();
@@ -140,8 +137,6 @@ protected:
// file)
std::unique_ptr<SymbolFile> m_sym_file_up; // A single symbol file. Subclasses
// can add more of these if needed.
- Symtab *m_symtab; // Save a symtab once to not pass it through `AddSymbols` of
- // the symbol file each time when it is needed
private:
// For SymbolVendor only
diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp
index 7688d18f172..223e678e98e 100644
--- a/lldb/source/Symbol/SymbolFile.cpp
+++ b/lldb/source/Symbol/SymbolFile.cpp
@@ -200,6 +200,21 @@ void SymbolFile::SetCompileUnitAtIndex(uint32_t idx, const CompUnitSP &cu_sp) {
(*m_compile_units)[idx] = cu_sp;
}
+Symtab *SymbolFile::GetSymtab() {
+ std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
+ if (m_symtab)
+ return m_symtab;
+
+ // Fetch the symtab from the main object file.
+ m_symtab = m_obj_file->GetModule()->GetObjectFile()->GetSymtab();
+
+ // Then add our symbols to it.
+ if (m_symtab)
+ AddSymbols(*m_symtab);
+
+ return m_symtab;
+}
+
void SymbolFile::Dump(Stream &s) {
s.PutCString("Types:\n");
m_type_list.Dump(&s, /*show_context*/ false);
diff --git a/lldb/source/Symbol/SymbolVendor.cpp b/lldb/source/Symbol/SymbolVendor.cpp
index 30e78ef91eb..5bb4ea3822a 100644
--- a/lldb/source/Symbol/SymbolVendor.cpp
+++ b/lldb/source/Symbol/SymbolVendor.cpp
@@ -58,7 +58,7 @@ SymbolVendor *SymbolVendor::FindPlugin(const lldb::ModuleSP &module_sp,
// SymbolVendor constructor
SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp)
- : ModuleChild(module_sp), m_sym_file_up(), m_symtab() {}
+ : ModuleChild(module_sp), m_sym_file_up() {}
// Destructor
SymbolVendor::~SymbolVendor() {}
@@ -384,35 +384,9 @@ FileSpec SymbolVendor::GetMainFileSpec() const {
}
Symtab *SymbolVendor::GetSymtab() {
- ModuleSP module_sp(GetModule());
- if (!module_sp)
- return nullptr;
-
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
-
- if (m_symtab)
- return m_symtab;
-
- ObjectFile *objfile = module_sp->GetObjectFile();
- if (!objfile)
- return nullptr;
-
- m_symtab = objfile->GetSymtab();
- if (m_symtab && m_sym_file_up)
- m_sym_file_up->AddSymbols(*m_symtab);
-
- return m_symtab;
-}
-
-void SymbolVendor::ClearSymtab() {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- ObjectFile *objfile = module_sp->GetObjectFile();
- if (objfile) {
- // Clear symbol table from unified section list.
- objfile->ClearSymtab();
- }
- }
+ if (m_sym_file_up)
+ return m_sym_file_up->GetSymtab();
+ return nullptr;
}
void SymbolVendor::SectionFileAddressesChanged() {
diff --git a/lldb/unittests/Core/CMakeLists.txt b/lldb/unittests/Core/CMakeLists.txt
index f6c6e25b8d8..369237d114c 100644
--- a/lldb/unittests/Core/CMakeLists.txt
+++ b/lldb/unittests/Core/CMakeLists.txt
@@ -9,7 +9,7 @@ add_lldb_unittest(LLDBCoreTests
lldbHost
lldbSymbol
lldbPluginObjectFileELF
- lldbPluginSymbolVendorELF
+ lldbPluginSymbolFileSymtab
lldbUtilityHelpers
LLVMTestingSupport
LINK_COMPONENTS
diff --git a/lldb/unittests/Core/MangledTest.cpp b/lldb/unittests/Core/MangledTest.cpp
index 85d2723010d..94fee105e9b 100644
--- a/lldb/unittests/Core/MangledTest.cpp
+++ b/lldb/unittests/Core/MangledTest.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
#include "TestingSupport/TestUtilities.h"
#include "lldb/Core/Mangled.h"
@@ -54,7 +54,7 @@ TEST(MangledTest, NameIndexes_FindFunctionSymbols) {
FileSystem::Initialize();
HostInfo::Initialize();
ObjectFileELF::Initialize();
- SymbolVendorELF::Initialize();
+ SymbolFileSymtab::Initialize();
llvm::SmallString<128> Obj;
ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile(
@@ -146,7 +146,7 @@ TEST(MangledTest, NameIndexes_FindFunctionSymbols) {
EXPECT_EQ(0, Count("undemangable", eFunctionNameTypeBase));
EXPECT_EQ(0, Count("undemangable", eFunctionNameTypeMethod));
- SymbolVendorELF::Terminate();
+ SymbolFileSymtab::Terminate();
ObjectFileELF::Terminate();
HostInfo::Terminate();
FileSystem::Terminate();
diff --git a/lldb/unittests/ObjectFile/ELF/CMakeLists.txt b/lldb/unittests/ObjectFile/ELF/CMakeLists.txt
index ccce062d29e..9d2b64becb1 100644
--- a/lldb/unittests/ObjectFile/ELF/CMakeLists.txt
+++ b/lldb/unittests/ObjectFile/ELF/CMakeLists.txt
@@ -3,7 +3,7 @@ add_lldb_unittest(ObjectFileELFTests
LINK_LIBS
lldbPluginObjectFileELF
- lldbPluginSymbolVendorELF
+ lldbPluginSymbolFileSymtab
lldbCore
lldbUtilityHelpers
LLVMTestingSupport
diff --git a/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp b/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
index a74986b5d8e..0f72a86573e 100644
--- a/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
+++ b/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
#include "TestingSupport/TestUtilities.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -34,11 +34,11 @@ public:
FileSystem::Initialize();
HostInfo::Initialize();
ObjectFileELF::Initialize();
- SymbolVendorELF::Initialize();
+ SymbolFileSymtab::Initialize();
}
void TearDown() override {
- SymbolVendorELF::Terminate();
+ SymbolFileSymtab::Terminate();
ObjectFileELF::Terminate();
HostInfo::Terminate();
FileSystem::Terminate();
diff --git a/lldb/unittests/Symbol/CMakeLists.txt b/lldb/unittests/Symbol/CMakeLists.txt
index 1fbb1d87167..7d3640d138c 100644
--- a/lldb/unittests/Symbol/CMakeLists.txt
+++ b/lldb/unittests/Symbol/CMakeLists.txt
@@ -13,6 +13,7 @@ add_lldb_unittest(SymbolTests
lldbPluginObjectFileELF
lldbPluginObjectFileMachO
lldbPluginSymbolFileDWARF
+ lldbPluginSymbolFileSymtab
LLVMTestingSupport
)
diff --git a/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp b/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
index c0bfa55f577..86eea3f5190 100644
--- a/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
+++ b/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
@@ -11,6 +11,7 @@
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
#include "Plugins/Process/Utility/RegisterContext_x86.h"
+#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
#include "TestingSupport/TestUtilities.h"
#include "lldb/Core/Module.h"
@@ -36,9 +37,11 @@ public:
FileSystem::Initialize();
HostInfo::Initialize();
ObjectFileELF::Initialize();
+ SymbolFileSymtab::Initialize();
}
void TearDown() override {
+ SymbolFileSymtab::Terminate();
ObjectFileELF::Terminate();
HostInfo::Terminate();
FileSystem::Terminate();
diff --git a/lldb/unittests/Target/CMakeLists.txt b/lldb/unittests/Target/CMakeLists.txt
index ba3039e1d42..3ece2e93108 100644
--- a/lldb/unittests/Target/CMakeLists.txt
+++ b/lldb/unittests/Target/CMakeLists.txt
@@ -10,6 +10,7 @@ add_lldb_unittest(TargetTests
lldbSymbol
lldbUtility
lldbPluginObjectFileELF
+ lldbPluginSymbolFileSymtab
lldbUtilityHelpers
LINK_COMPONENTS
Support
diff --git a/lldb/unittests/Target/ModuleCacheTest.cpp b/lldb/unittests/Target/ModuleCacheTest.cpp
index 9678bb078ce..b754d14b6f8 100644
--- a/lldb/unittests/Target/ModuleCacheTest.cpp
+++ b/lldb/unittests/Target/ModuleCacheTest.cpp
@@ -5,6 +5,7 @@
#include "llvm/Support/Path.h"
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
#include "TestingSupport/TestUtilities.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -69,12 +70,14 @@ void ModuleCacheTest::SetUpTestCase() {
FileSystem::Initialize();
HostInfo::Initialize();
ObjectFileELF::Initialize();
+ SymbolFileSymtab::Initialize();
s_cache_dir = HostInfo::GetProcessTempDir();
s_test_executable = GetInputFilePath(module_name);
}
void ModuleCacheTest::TearDownTestCase() {
+ SymbolFileSymtab::Terminate();
ObjectFileELF::Terminate();
HostInfo::Terminate();
FileSystem::Terminate();
OpenPOWER on IntegriCloud