diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-10-23 17:53:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-10-23 17:53:01 +0000 |
commit | ead246455adf1a215ec2715dad6533073a6beb4e (patch) | |
tree | f3f97a47d77053bf96fe74cdbd6fae74380e8a92 /source/Plugins/SymbolFile/Symtab | |
parent | fdb00c4408990a0a63ef7f496d809ce59f263bc5 (diff) |
Notes
Diffstat (limited to 'source/Plugins/SymbolFile/Symtab')
-rw-r--r-- | source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp | 38 | ||||
-rw-r--r-- | source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h | 18 |
2 files changed, 28 insertions, 28 deletions
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index a1b21e51b0fe..62da76581c3e 100644 --- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -43,26 +43,24 @@ const char *SymbolFileSymtab::GetPluginDescriptionStatic() { return "Reads debug symbols from an object file's symbol table."; } -SymbolFile *SymbolFileSymtab::CreateInstance(ObjectFile *obj_file) { - return new SymbolFileSymtab(obj_file); +SymbolFile *SymbolFileSymtab::CreateInstance(ObjectFileSP objfile_sp) { + return new SymbolFileSymtab(std::move(objfile_sp)); } -size_t SymbolFileSymtab::GetTypes(SymbolContextScope *sc_scope, - TypeClass type_mask, - lldb_private::TypeList &type_list) { - return 0; -} +void SymbolFileSymtab::GetTypes(SymbolContextScope *sc_scope, + TypeClass type_mask, + lldb_private::TypeList &type_list) {} -SymbolFileSymtab::SymbolFileSymtab(ObjectFile *obj_file) - : SymbolFile(obj_file), m_source_indexes(), m_func_indexes(), +SymbolFileSymtab::SymbolFileSymtab(ObjectFileSP objfile_sp) + : SymbolFile(std::move(objfile_sp)), m_source_indexes(), m_func_indexes(), m_code_indexes(), m_objc_class_name_to_index() {} SymbolFileSymtab::~SymbolFileSymtab() {} uint32_t SymbolFileSymtab::CalculateAbilities() { uint32_t abilities = 0; - if (m_obj_file) { - const Symtab *symtab = m_obj_file->GetSymtab(); + if (m_objfile_sp) { + const Symtab *symtab = m_objfile_sp->GetSymtab(); if (symtab) { // The snippet of code below will get the indexes the module symbol table // entries that are code, data, or function related (debug info), sort @@ -104,7 +102,7 @@ uint32_t SymbolFileSymtab::CalculateAbilities() { return abilities; } -uint32_t SymbolFileSymtab::GetNumCompileUnits() { +uint32_t SymbolFileSymtab::CalculateNumCompileUnits() { // If we don't have any source file symbols we will just have one compile // unit for the entire object file if (m_source_indexes.empty()) @@ -122,10 +120,10 @@ CompUnitSP SymbolFileSymtab::ParseCompileUnitAtIndex(uint32_t idx) { // unit for the entire object file if (idx < m_source_indexes.size()) { const Symbol *cu_symbol = - m_obj_file->GetSymtab()->SymbolAtIndex(m_source_indexes[idx]); + m_objfile_sp->GetSymtab()->SymbolAtIndex(m_source_indexes[idx]); if (cu_symbol) - cu_sp = std::make_shared<CompileUnit>(m_obj_file->GetModule(), nullptr, - cu_symbol->GetName().AsCString(), 0, + cu_sp = std::make_shared<CompileUnit>(m_objfile_sp->GetModule(), nullptr, + cu_symbol->GetName().AsCString(), 0, eLanguageTypeUnknown, eLazyBoolNo); } return cu_sp; @@ -136,12 +134,13 @@ lldb::LanguageType SymbolFileSymtab::ParseLanguage(CompileUnit &comp_unit) { } size_t SymbolFileSymtab::ParseFunctions(CompileUnit &comp_unit) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); size_t num_added = 0; // We must at least have a valid compile unit - const Symtab *symtab = m_obj_file->GetSymtab(); + const Symtab *symtab = m_objfile_sp->GetSymtab(); const Symbol *curr_symbol = nullptr; const Symbol *next_symbol = nullptr; - // const char *prefix = m_obj_file->SymbolPrefix(); + // const char *prefix = m_objfile_sp->SymbolPrefix(); // if (prefix == NULL) // prefix == ""; // @@ -246,12 +245,13 @@ bool SymbolFileSymtab::CompleteType(lldb_private::CompilerType &compiler_type) { uint32_t SymbolFileSymtab::ResolveSymbolContext(const Address &so_addr, SymbolContextItem resolve_scope, SymbolContext &sc) { - if (m_obj_file->GetSymtab() == nullptr) + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); + if (m_objfile_sp->GetSymtab() == nullptr) return 0; uint32_t resolved_flags = 0; if (resolve_scope & eSymbolContextSymbol) { - sc.symbol = m_obj_file->GetSymtab()->FindSymbolContainingFileAddress( + sc.symbol = m_objfile_sp->GetSymtab()->FindSymbolContainingFileAddress( so_addr.GetFileAddress()); if (sc.symbol) resolved_flags |= eSymbolContextSymbol; diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h index bc9a531419ae..2ac4660f0125 100644 --- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h +++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h @@ -18,7 +18,7 @@ class SymbolFileSymtab : public lldb_private::SymbolFile { public: // Constructors and Destructors - SymbolFileSymtab(lldb_private::ObjectFile *obj_file); + SymbolFileSymtab(lldb::ObjectFileSP objfile_sp); ~SymbolFileSymtab() override; @@ -32,15 +32,11 @@ public: static const char *GetPluginDescriptionStatic(); static lldb_private::SymbolFile * - CreateInstance(lldb_private::ObjectFile *obj_file); + CreateInstance(lldb::ObjectFileSP objfile_sp); uint32_t CalculateAbilities() override; // Compile Unit function calls - uint32_t GetNumCompileUnits() override; - - lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; - lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override; @@ -75,9 +71,9 @@ public: lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override; - size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, - lldb::TypeClass type_mask, - lldb_private::TypeList &type_list) override; + void GetTypes(lldb_private::SymbolContextScope *sc_scope, + lldb::TypeClass type_mask, + lldb_private::TypeList &type_list) override; // PluginInterface protocol lldb_private::ConstString GetPluginName() override; @@ -85,6 +81,10 @@ public: uint32_t GetPluginVersion() override; protected: + uint32_t CalculateNumCompileUnits() override; + + lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; + typedef std::map<lldb_private::ConstString, lldb::TypeSP> TypeMap; lldb_private::Symtab::IndexCollection m_source_indexes; |