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

Jan Kratochvil via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Nov 2 07:47:03 PST 2020


jankratochvil updated this revision to Diff 302281.
jankratochvil added a comment.

It is no longer too much pretty, feel free to drop it if you think so.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90464/new/

https://reviews.llvm.org/D90464

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


Index: lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
@@ -49,6 +49,9 @@
 
 protected:
   lldb_private::UniqueCStringMap<DIERef> m_map;
+
+private:
+  static bool DWARFUnitContainsDIERef(const DWARFUnit &unit, DIERef die_ref);
 };
 
 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_NAMETODIE_H
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 (DWARFUnitContainsDIERef(unit, die_ref)) {
       if (!callback(die_ref))
         return;
     }
@@ -86,3 +83,11 @@
                  other.m_map.GetValueAtIndexUnchecked(i));
   }
 }
+
+bool NameToDIE::DWARFUnitContainsDIERef(const DWARFUnit &unit, DIERef die_ref) {
+  if (unit.GetSymbolFileDWARF().GetDwoNum() != die_ref.dwo_num())
+    return false;
+  if (unit.GetDebugSection() != die_ref.section())
+    return false;
+  return unit.ContainsDIEOffset(die_ref.die_offset());
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90464.302281.patch
Type: text/x-patch
Size: 1603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201102/ff1e8300/attachment.bin>


More information about the lldb-commits mailing list