diff options
author | Greg Clayton <gclayton@fb.com> | 2021-11-15 21:02:53 -0800 |
---|---|---|
committer | Greg Clayton <gclayton@fb.com> | 2021-11-17 15:14:01 -0800 |
commit | 951b107eedab1829f18049443f03339dbb0db165 (patch) | |
tree | b685d16ca70d97c4f0780d023dd03901ccd6c68a /lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp | |
parent | a82ee2be9c6378cd34deb3ab002d78acd2b04ff3 (diff) | |
download | llvm-951b107eedab1829f18049443f03339dbb0db165.zip llvm-951b107eedab1829f18049443f03339dbb0db165.tar.gz llvm-951b107eedab1829f18049443f03339dbb0db165.tar.bz2 |
[NFC] Refactor symbol table parsing.
Symbol table parsing has evolved over the years and many plug-ins contained duplicate code in the ObjectFile::GetSymtab() that used to be pure virtual. With this change, the "Symbtab *ObjectFile::GetSymtab()" is no longer virtual and will end up calling a new "void ObjectFile::ParseSymtab(Symtab &symtab)" pure virtual function to actually do the parsing. This helps centralize the code for parsing the symbol table and allows the ObjectFile base class to do all of the common work, like taking the necessary locks and creating the symbol table object itself. Plug-ins now just need to parse when they are asked to parse as the ParseSymtab function will only get called once.
Differential Revision: https://reviews.llvm.org/D113965
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp index bec0099..ca93374 100644 --- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp +++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp @@ -106,23 +106,10 @@ uint32_t ObjectFileJIT::GetAddressByteSize() const { return m_data.GetAddressByteSize(); } -Symtab *ObjectFileJIT::GetSymtab() { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); - if (m_symtab_up == nullptr) { - ElapsedTime elapsed(module_sp->GetSymtabParseTime()); - m_symtab_up = std::make_unique<Symtab>(this); - std::lock_guard<std::recursive_mutex> symtab_guard( - m_symtab_up->GetMutex()); - ObjectFileJITDelegateSP delegate_sp(m_delegate_wp.lock()); - if (delegate_sp) - delegate_sp->PopulateSymtab(this, *m_symtab_up); - // TODO: get symbols from delegate - m_symtab_up->Finalize(); - } - } - return m_symtab_up.get(); +void ObjectFileJIT::ParseSymtab(Symtab &symtab) { + ObjectFileJITDelegateSP delegate_sp(m_delegate_wp.lock()); + if (delegate_sp) + delegate_sp->PopulateSymtab(this, symtab); } bool ObjectFileJIT::IsStripped() { |