[Lldb-commits] [PATCH] D90464: [nfc] [lldb] Refactor out DWARFUnit::ContainsDIERef

Jan Kratochvil via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 30 08:07:30 PDT 2020


jankratochvil created this revision.
jankratochvil added reviewers: labath, JDevlieghere.
jankratochvil added a project: LLDB.
jankratochvil requested review of this revision.

There is just a difference of comparing `DIERef::die_offset()` with originally `GetOffset()` while now with `GetFirstDIEOffset()`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90464

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
@@ -50,10 +50,7 @@
   const uint32_t size = m_map.GetSize();
   for (uint32_t i = 0; i < size; ++i) {
     const DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i);
-    if (unit.GetSymbolFileDWARF().GetDwoNum() == die_ref.dwo_num() &&
-        unit.GetDebugSection() == die_ref.section() &&
-        unit.GetOffset() <= die_ref.die_offset() &&
-        die_ref.die_offset() < unit.GetNextUnitOffset()) {
+    if (unit.ContainsDIERef(die_ref)) {
       if (!callback(die_ref))
         return;
     }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -137,6 +137,7 @@
     return die_offset >= GetFirstDIEOffset() &&
            die_offset < GetNextUnitOffset();
   }
+  bool ContainsDIERef(DIERef die_ref) const;
   dw_offset_t GetFirstDIEOffset() const {
     return GetOffset() + GetHeaderByteSize();
   }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -967,3 +967,11 @@
   return llvm::createStringError(errc::invalid_argument,
                                  "missing or invalid range list table");
 }
+
+bool DWARFUnit::ContainsDIERef(DIERef die_ref) const {
+  if (m_dwarf.GetDwoNum() != die_ref.dwo_num())
+    return false;
+  if (m_section != die_ref.section())
+    return false;
+  return ContainsDIEOffset(die_ref.die_offset());
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90464.301902.patch
Type: text/x-patch
Size: 1859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201030/6b130145/attachment-0001.bin>


More information about the lldb-commits mailing list