[Lldb-commits] [PATCH] D65266: SymbolVendor: Make SectionAddressesChanged a passthrough

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 25 01:47:37 PDT 2019


labath created this revision.
labath added reviewers: clayborg, jingham, JDevlieghere.

This moves the implementation of the function into the SymbolFile class,
making it possible to excise the SymbolVendor passthrough functions in
follow-up patches.


https://reviews.llvm.org/D65266

Files:
  include/lldb/Symbol/SymbolFile.h
  source/Symbol/SymbolFile.cpp
  source/Symbol/SymbolVendor.cpp


Index: source/Symbol/SymbolVendor.cpp
===================================================================
--- source/Symbol/SymbolVendor.cpp
+++ source/Symbol/SymbolVendor.cpp
@@ -390,19 +390,8 @@
 }
 
 void SymbolVendor::SectionFileAddressesChanged() {
-  ModuleSP module_sp(GetModule());
-  if (module_sp) {
-    ObjectFile *module_objfile = module_sp->GetObjectFile();
-    if (m_sym_file_up) {
-      ObjectFile *symfile_objfile = m_sym_file_up->GetObjectFile();
-      if (symfile_objfile != module_objfile)
-        symfile_objfile->SectionFileAddressesChanged();
-    }
-    Symtab *symtab = GetSymtab();
-    if (symtab) {
-      symtab->SectionFileAddressesChanged();
-    }
-  }
+  if (m_sym_file_up)
+    m_sym_file_up->SectionFileAddressesChanged();
 }
 
 // PluginInterface protocol
Index: source/Symbol/SymbolFile.cpp
===================================================================
--- source/Symbol/SymbolFile.cpp
+++ source/Symbol/SymbolFile.cpp
@@ -31,6 +31,9 @@
 std::recursive_mutex &SymbolFile::GetModuleMutex() const {
   return GetObjectFile()->GetModule()->GetMutex();
 }
+ObjectFile *SymbolFile::GetMainObjectFile() {
+  return m_obj_file->GetModule()->GetObjectFile();
+}
 
 SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) {
   std::unique_ptr<SymbolFile> best_symfile_up;
@@ -205,7 +208,7 @@
     return m_symtab;
 
   // Fetch the symtab from the main object file.
-  m_symtab = m_obj_file->GetModule()->GetObjectFile()->GetSymtab();
+  m_symtab = GetMainObjectFile()->GetSymtab();
 
   // Then add our symbols to it.
   if (m_symtab)
@@ -214,6 +217,15 @@
   return m_symtab;
 }
 
+void SymbolFile::SectionFileAddressesChanged() {
+  ObjectFile *module_objfile = GetMainObjectFile();
+  ObjectFile *symfile_objfile = GetObjectFile();
+  if (symfile_objfile != module_objfile)
+    symfile_objfile->SectionFileAddressesChanged();
+  if (m_symtab)
+    m_symtab->SectionFileAddressesChanged();
+}
+
 void SymbolFile::Dump(Stream &s) {
   s.PutCString("Types:\n");
   m_type_list.Dump(&s, /*show_context*/ false);
Index: include/lldb/Symbol/SymbolFile.h
===================================================================
--- include/lldb/Symbol/SymbolFile.h
+++ include/lldb/Symbol/SymbolFile.h
@@ -212,6 +212,7 @@
 
   ObjectFile *GetObjectFile() { return m_obj_file; }
   const ObjectFile *GetObjectFile() const { return m_obj_file; }
+  ObjectFile *GetMainObjectFile();
 
   virtual std::vector<CallEdge> ParseCallEdgesInFunction(UserID func_id) {
     return {};
@@ -221,7 +222,7 @@
 
   /// Notify the SymbolFile that the file addresses in the Sections
   /// for this module have been changed.
-  virtual void SectionFileAddressesChanged() {}
+  virtual void SectionFileAddressesChanged();
 
   struct RegisterInfoResolver {
     virtual ~RegisterInfoResolver(); // anchor


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65266.211693.patch
Type: text/x-patch
Size: 2817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190725/6876066e/attachment-0001.bin>


More information about the lldb-commits mailing list