[Lldb-commits] [lldb] r368263 - Remove Module::GetSymbolVendor

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 8 00:34:08 PDT 2019


Author: labath
Date: Thu Aug  8 00:34:07 2019
New Revision: 368263

URL: http://llvm.org/viewvc/llvm-project?rev=368263&view=rev
Log:
Remove Module::GetSymbolVendor

Summary:
This patch removes the GetSymbolVendor function, and the various
mentions of the SymbolVendor in the Module class. The implementation of
GetSymbolVendor is "inlined" into the GetSymbolFile class which I
created earlier.

After this patch, the SymbolVendor class still exists inside the Module
object, but only as an implementation detail -- a fancy holder for the
SymbolFile. That will be removed in the next patch.

Reviewers: clayborg, JDevlieghere, jingham, jdoerfert

Subscribers: jfb, lldb-commits

Differential Revision: https://reviews.llvm.org/D65864

Modified:
    lldb/trunk/include/lldb/Core/Module.h
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=368263&r1=368262&r2=368263&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Thu Aug  8 00:34:07 2019
@@ -49,7 +49,6 @@ class Symbol;
 class SymbolContext;
 class SymbolContextList;
 class SymbolFile;
-class SymbolVendor;
 class Symtab;
 class Target;
 class TypeList;
@@ -67,8 +66,8 @@ class VariableList;
 /// accessors are called. For example the object file (ObjectFile)
 /// representation will only be parsed if the object file is requested using
 /// the Module::GetObjectFile() is called. The debug symbols will only be
-/// parsed if the symbol vendor (SymbolVendor) is requested using the
-/// Module::GetSymbolVendor() is called.
+/// parsed if the symbol file (SymbolFile) is requested using the
+/// Module::GetSymbolFile() method.
 ///
 /// The module will parse more detailed information as more queries are made.
 class Module : public std::enable_shared_from_this<Module>,
@@ -420,10 +419,9 @@ public:
 
   /// Find types by name.
   ///
-  /// Type lookups in modules go through the SymbolVendor (which will use one
-  /// or more SymbolFile subclasses). The SymbolFile needs to be able to
-  /// lookup types by basename and not the fully qualified typename. This
-  /// allows the type accelerator tables to stay small, even with heavily
+  /// Type lookups in modules go through the SymbolFile. The SymbolFile needs to
+  /// be able to lookup types by basename and not the fully qualified typename.
+  /// This allows the type accelerator tables to stay small, even with heavily
   /// templatized C++. The type search will then narrow down the search
   /// results. If "exact_match" is true, then the type search will only match
   /// exact type name matches. If "exact_match" is false, the type will match
@@ -638,23 +636,17 @@ public:
   ObjectFile *GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
                                   lldb::addr_t header_addr, Status &error,
                                   size_t size_to_read = 512);
-  /// Get the symbol vendor interface for the current architecture.
-  ///
-  /// If the symbol vendor file has not been located yet, this function will
-  /// find the best SymbolVendor plug-in that can use the current object file.
-  ///
-  /// \return
-  ///     If this module does not have a valid object file, or no
-  ///     plug-in can be found that can use the object file, nullptr will
-  ///     be returned, else a valid symbol vendor plug-in interface
-  ///     will be returned. The returned pointer is owned by this
-  ///     object and remains valid as long as the object is around.
-  virtual SymbolVendor *
-  GetSymbolVendor(bool can_create = true,
-                  lldb_private::Stream *feedback_strm = nullptr);
 
-  SymbolFile *GetSymbolFile(bool can_create = true,
-                            Stream *feedback_strm = nullptr);
+  /// Get the module's symbol file
+  ///
+  /// If the symbol file has already been loaded, this function returns it. All
+  /// arguments are ignored. If the symbol file has not been located yet, and
+  /// the can_create argument is false, the function returns nullptr. If
+  /// can_create is true, this function will find the best SymbolFile plug-in
+  /// that can use the current object file. feedback_strm, if not null, is used
+  /// to report the details of the search process.
+  virtual SymbolFile *GetSymbolFile(bool can_create = true,
+                                    Stream *feedback_strm = nullptr);
 
   Symtab *GetSymtab();
 
@@ -847,7 +839,7 @@ public:
   // when the module first gets created.
   bool FileHasChanged() const;
 
-  // SymbolVendor, SymbolFile and ObjectFile member objects should lock the
+  // SymbolFile and ObjectFile member objects should lock the
   // module mutex to avoid deadlocks.
   std::recursive_mutex &GetMutex() const { return m_mutex; }
 
@@ -899,12 +891,12 @@ public:
   /// A class that encapsulates name lookup information.
   ///
   /// Users can type a wide variety of partial names when setting breakpoints
-  /// by name or when looking for functions by name. SymbolVendor and
-  /// SymbolFile objects are only required to implement name lookup for
-  /// function basenames and for fully mangled names. This means if the user
-  /// types in a partial name, we must reduce this to a name lookup that will
-  /// work with all SymbolFile objects. So we might reduce a name lookup to
-  /// look for a basename, and then prune out any results that don't match.
+  /// by name or when looking for functions by name. The SymbolFile object is
+  /// only required to implement name lookup for function basenames and for
+  /// fully mangled names. This means if the user types in a partial name, we
+  /// must reduce this to a name lookup that will work with all SymbolFile
+  /// objects. So we might reduce a name lookup to look for a basename, and then
+  /// prune out any results that don't match.
   ///
   /// The "m_name" member variable represents the name as it was typed by the
   /// user. "m_lookup_name" will be the name we actually search for through
@@ -1011,7 +1003,7 @@ protected:
                                      /// ObjectFile instances for the debug info
 
   std::atomic<bool> m_did_load_objfile{false};
-  std::atomic<bool> m_did_load_symbol_vendor{false};
+  std::atomic<bool> m_did_load_symfile{false};
   std::atomic<bool> m_did_set_uuid{false};
   mutable bool m_file_has_changed : 1,
       m_first_file_changed_log : 1; /// See if the module was modified after it

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=368263&r1=368262&r2=368263&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Thu Aug  8 00:34:07 2019
@@ -1037,28 +1037,21 @@ size_t Module::FindTypes(
   return num_matches;
 }
 
-SymbolVendor *Module::GetSymbolVendor(bool can_create,
-                                      lldb_private::Stream *feedback_strm) {
-  if (!m_did_load_symbol_vendor.load()) {
+SymbolFile *Module::GetSymbolFile(bool can_create, Stream *feedback_strm) {
+  if (!m_did_load_symfile.load()) {
     std::lock_guard<std::recursive_mutex> guard(m_mutex);
-    if (!m_did_load_symbol_vendor.load() && can_create) {
+    if (!m_did_load_symfile.load() && can_create) {
       ObjectFile *obj_file = GetObjectFile();
       if (obj_file != nullptr) {
         static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
         Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
         m_symfile_up.reset(
             SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
-        m_did_load_symbol_vendor = true;
+        m_did_load_symfile = true;
       }
     }
   }
-  return m_symfile_up.get();
-}
-
-SymbolFile *Module::GetSymbolFile(bool can_create, Stream *feedback_strm) {
-  if (SymbolVendor *vendor = GetSymbolVendor(can_create, feedback_strm))
-    return vendor->GetSymbolFile();
-  return nullptr;
+  return m_symfile_up ? m_symfile_up->GetSymbolFile() : nullptr;
 }
 
 Symtab *Module::GetSymtab() {
@@ -1467,7 +1460,7 @@ void Module::SetSymbolFileFileSpec(const
   }
   m_symfile_spec = file;
   m_symfile_up.reset();
-  m_did_load_symbol_vendor = false;
+  m_did_load_symfile = false;
 }
 
 bool Module::IsExecutable() {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=368263&r1=368262&r2=368263&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Thu Aug  8 00:34:07 2019
@@ -41,7 +41,7 @@ using namespace lldb_private;
 
 // Subclass lldb_private::Module so we can intercept the
 // "Module::GetObjectFile()" (so we can fixup the object file sections) and
-// also for "Module::GetSymbolVendor()" (so we can fixup the symbol file id.
+// also for "Module::GetSymbolFile()" (so we can fixup the symbol file id.
 
 const SymbolFileDWARFDebugMap::FileRangeMap &
 SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(
@@ -173,12 +173,12 @@ public:
 
   ~DebugMapModule() override = default;
 
-  SymbolVendor *
-  GetSymbolVendor(bool can_create = true,
-                  lldb_private::Stream *feedback_strm = nullptr) override {
+  SymbolFile *
+  GetSymbolFile(bool can_create = true,
+                lldb_private::Stream *feedback_strm = nullptr) override {
     // Scope for locker
     if (m_symfile_up.get() || !can_create)
-      return m_symfile_up.get();
+      return m_symfile_up ? m_symfile_up->GetSymbolFile() : nullptr;
 
     ModuleSP exe_module_sp(m_exe_module_wp.lock());
     if (exe_module_sp) {
@@ -186,30 +186,28 @@ public:
       ObjectFile *oso_objfile = GetObjectFile();
       if (oso_objfile) {
         std::lock_guard<std::recursive_mutex> guard(m_mutex);
-        SymbolVendor *symbol_vendor =
-            Module::GetSymbolVendor(can_create, feedback_strm);
-        if (symbol_vendor) {
+        if (SymbolFile *symfile =
+                Module::GetSymbolFile(can_create, feedback_strm)) {
           // Set a pointer to this class to set our OSO DWARF file know that
           // the DWARF is being used along with a debug map and that it will
           // have the remapped sections that we do below.
           SymbolFileDWARF *oso_symfile =
-              SymbolFileDWARFDebugMap::GetSymbolFileAsSymbolFileDWARF(
-                  symbol_vendor->GetSymbolFile());
+              SymbolFileDWARFDebugMap::GetSymbolFileAsSymbolFileDWARF(symfile);
 
           if (!oso_symfile)
             return nullptr;
 
           ObjectFile *exe_objfile = exe_module_sp->GetObjectFile();
-          SymbolVendor *exe_sym_vendor = exe_module_sp->GetSymbolVendor();
+          SymbolFile *exe_symfile = exe_module_sp->GetSymbolFile();
 
-          if (exe_objfile && exe_sym_vendor) {
+          if (exe_objfile && exe_symfile) {
             oso_symfile->SetDebugMapModule(exe_module_sp);
             // Set the ID of the symbol file DWARF to the index of the OSO
             // shifted left by 32 bits to provide a unique prefix for any
             // UserID's that get created in the symbol file.
             oso_symfile->SetID(((uint64_t)m_cu_idx + 1ull) << 32ull);
           }
-          return symbol_vendor;
+          return symfile;
         }
       }
     }
@@ -537,12 +535,8 @@ SymbolFileDWARFDebugMap::GetSymbolFileAs
 
 SymbolFileDWARF *SymbolFileDWARFDebugMap::GetSymbolFileByCompUnitInfo(
     CompileUnitInfo *comp_unit_info) {
-  Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info);
-  if (oso_module) {
-    SymbolVendor *sym_vendor = oso_module->GetSymbolVendor();
-    if (sym_vendor)
-      return GetSymbolFileAsSymbolFileDWARF(sym_vendor->GetSymbolFile());
-  }
+  if (Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info))
+    return GetSymbolFileAsSymbolFileDWARF(oso_module->GetSymbolFile());
   return nullptr;
 }
 




More information about the lldb-commits mailing list