[Lldb-commits] [lldb] 2178088 - Separate DIERef vs. user_id_t: m_function_scope_qualified_name_map

Jan Kratochvil via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 17 07:35:51 PST 2020


Author: Jan Kratochvil
Date: 2020-02-17T16:35:42+01:00
New Revision: 21780888791837b575d227a9a69c1afee9e4c29d

URL: https://github.com/llvm/llvm-project/commit/21780888791837b575d227a9a69c1afee9e4c29d
DIFF: https://github.com/llvm/llvm-project/commit/21780888791837b575d227a9a69c1afee9e4c29d.diff

LOG: Separate DIERef vs. user_id_t: m_function_scope_qualified_name_map

As discussed in https://reviews.llvm.org/D73206#1871895 there is both
`DIERef` and `user_id_t` and sometimes (for DWZ) we need to encode Main
CU into them and sometimes we cannot as it is unavailable at that point
and at the same time not even needed.

I have also noticed `DIERef` and `user_id_t` in fact contain the same
information which can be seen in SymbolFileDWARF::GetUID.

SB* API/ABI is already using `user_id_t` and it needs to encode Main CU
for DWZ. Therefore what about making `DIERef` the identifier not
containing Main CU and `user_id_t` the identifier containing Main CU?

It is sort of a revert of D63322.

I find this patch as a NFC cleanup to the codebase - to satisfy a new
premise `user_id_t` is used as little as possible and thus only for
external interfaces which must not deal with MainCU in any way.

Its larger goal is to satisfy a plan to implement DWZ support.

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

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
index 5546bb7e8b86..7d78ea18587f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -44,6 +44,16 @@ class DIERef {
 
   dw_offset_t die_offset() const { return m_die_offset; }
 
+  bool operator<(DIERef other) const {
+    if (m_dwo_num_valid != other.m_dwo_num_valid)
+      return m_dwo_num_valid < other.m_dwo_num_valid;
+    if (m_dwo_num_valid && (m_dwo_num != other.m_dwo_num))
+      return m_dwo_num < other.m_dwo_num;
+    if (m_section != other.m_section)
+      return m_section < other.m_section;
+    return m_die_offset < other.m_die_offset;
+  }
+
 private:
   uint32_t m_dwo_num : 30;
   uint32_t m_dwo_num_valid : 1;

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index b7e91c0eedb0..954f1110ba1e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2381,9 +2381,9 @@ void SymbolFileDWARF::GetMangledNamesForFunction(
       dwo->GetMangledNamesForFunction(scope_qualified_name, mangled_names);
   }
 
-  for (lldb::user_id_t uid :
+  for (DIERef die_ref :
        m_function_scope_qualified_name_map.lookup(scope_qualified_name)) {
-    DWARFDIE die = GetDIE(uid);
+    DWARFDIE die = GetDIE(die_ref);
     mangled_names.push_back(ConstString(die.GetMangledName()));
   }
 }
@@ -3031,7 +3031,7 @@ TypeSP SymbolFileDWARF::ParseType(const SymbolContext &sc, const DWARFDIE &die,
                                            .AsCString(""));
       if (scope_qualified_name.size()) {
         m_function_scope_qualified_name_map[scope_qualified_name].insert(
-            die.GetID());
+            *die.GetDIERef());
       }
     }
   }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index c592561b4880..4d6132099801 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -500,7 +500,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
   bool m_fetched_external_modules : 1;
   lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type;
 
-  typedef std::set<lldb::user_id_t> DIERefSet;
+  typedef std::set<DIERef> DIERefSet;
   typedef llvm::StringMap<DIERefSet> NameToOffsetMap;
   NameToOffsetMap m_function_scope_qualified_name_map;
   std::unique_ptr<DWARFDebugRanges> m_ranges;


        


More information about the lldb-commits mailing list