[Lldb-commits] [lldb] r361232 - DWARF: Port debug_addr over to DWARFContext

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue May 21 02:11:12 PDT 2019


Author: labath
Date: Tue May 21 02:11:11 2019
New Revision: 361232

URL: http://llvm.org/viewvc/llvm-project?rev=361232&view=rev
Log:
DWARF: Port debug_addr over to DWARFContext

Modified:
    lldb/trunk/source/Expression/DWARFExpression.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=361232&r1=361231&r2=361232&view=diff
==============================================================================
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Tue May 21 02:11:11 2019
@@ -46,8 +46,10 @@ ReadAddressFromDebugAddrSection(const DW
   uint32_t index_size = dwarf_cu->GetAddressByteSize();
   dw_offset_t addr_base = dwarf_cu->GetAddrBase();
   lldb::offset_t offset = addr_base + index * index_size;
-  return dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(
-      &offset, index_size);
+  return dwarf_cu->GetSymbolFileDWARF()
+      ->GetDWARFContext()
+      .getOrLoadAddrData()
+      .GetMaxU64(&offset, index_size);
 }
 
 // DWARFExpression constructor
@@ -2813,12 +2815,7 @@ bool DWARFExpression::Evaluate(
         return false;
       }
       uint64_t index = opcodes.GetULEB128(&offset);
-      uint32_t index_size = dwarf_cu->GetAddressByteSize();
-      dw_offset_t addr_base = dwarf_cu->GetAddrBase();
-      lldb::offset_t offset = addr_base + index * index_size;
-      uint64_t value =
-          dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(
-              &offset, index_size);
+      lldb::addr_t value = ReadAddressFromDebugAddrSection(dwarf_cu, index);
       stack.push_back(Scalar(value));
       stack.back().SetValueType(Value::eValueTypeFileAddress);
     } break;
@@ -2838,22 +2835,8 @@ bool DWARFExpression::Evaluate(
         return false;
       }
       uint64_t index = opcodes.GetULEB128(&offset);
-      uint32_t index_size = dwarf_cu->GetAddressByteSize();
-      dw_offset_t addr_base = dwarf_cu->GetAddrBase();
-      lldb::offset_t offset = addr_base + index * index_size;
-      const DWARFDataExtractor &debug_addr =
-          dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data();
-      switch (index_size) {
-      case 4:
-        stack.push_back(Scalar(debug_addr.GetU32(&offset)));
-        break;
-      case 8:
-        stack.push_back(Scalar(debug_addr.GetU64(&offset)));
-        break;
-      default:
-        assert(false && "Unhandled index size");
-        return false;
-      }
+      lldb::addr_t value = ReadAddressFromDebugAddrSection(dwarf_cu, index);
+      stack.push_back(Scalar(value));
     } break;
 
     default:

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp?rev=361232&r1=361231&r2=361232&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp Tue May 21 02:11:11 2019
@@ -48,6 +48,11 @@ const DWARFDataExtractor &DWARFContext::
                           m_data_debug_aranges);
 }
 
+const DWARFDataExtractor &DWARFContext::getOrLoadAddrData() {
+  return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugAddr,
+                          m_data_debug_addr);
+}
+
 const DWARFDataExtractor &DWARFContext::getOrLoadDebugInfoData() {
   if (isDwo())
     return LoadOrGetSection(m_dwo_section_list, eSectionTypeDWARFDebugInfoDwo,

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h?rev=361232&r1=361231&r2=361232&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h Tue May 21 02:11:11 2019
@@ -21,6 +21,7 @@ private:
   SectionList *m_dwo_section_list;
 
   llvm::Optional<DWARFDataExtractor> m_data_debug_abbrev;
+  llvm::Optional<DWARFDataExtractor> m_data_debug_addr;
   llvm::Optional<DWARFDataExtractor> m_data_debug_aranges;
   llvm::Optional<DWARFDataExtractor> m_data_debug_info;
   llvm::Optional<DWARFDataExtractor> m_data_debug_line;
@@ -38,6 +39,7 @@ public:
         m_dwo_section_list(dwo_section_list) {}
 
   const DWARFDataExtractor &getOrLoadAbbrevData();
+  const DWARFDataExtractor &getOrLoadAddrData();
   const DWARFDataExtractor &getOrLoadArangesData();
   const DWARFDataExtractor &getOrLoadDebugInfoData();
   const DWARFDataExtractor &getOrLoadLineData();

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp?rev=361232&r1=361231&r2=361232&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp Tue May 21 02:11:11 2019
@@ -204,8 +204,10 @@ static uint64_t ReadAddressFromDebugAddr
   uint32_t index_size = cu->GetAddressByteSize();
   dw_offset_t addr_base = cu->GetAddrBase();
   lldb::offset_t offset = addr_base + index * index_size;
-  return cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(&offset,
-                                                                   index_size);
+  return cu->GetSymbolFileDWARF()
+      ->GetDWARFContext()
+      .getOrLoadAddrData()
+      .GetMaxU64(&offset, index_size);
 }
 
 bool DWARFDebugRngLists::FindRanges(const DWARFUnit *cu,

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp?rev=361232&r1=361231&r2=361232&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp Tue May 21 02:11:11 2019
@@ -549,7 +549,8 @@ dw_addr_t DWARFFormValue::Address() cons
   uint32_t index_size = m_unit->GetAddressByteSize();
   dw_offset_t addr_base = m_unit->GetAddrBase();
   lldb::offset_t offset = addr_base + m_value.value.uval * index_size;
-  return symbol_file->get_debug_addr_data().GetMaxU64(&offset, index_size);
+  return symbol_file->GetDWARFContext().getOrLoadAddrData().GetMaxU64(
+      &offset, index_size);
 }
 
 DWARFDIE DWARFFormValue::Reference() const {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=361232&r1=361231&r2=361232&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue May 21 02:11:11 2019
@@ -549,10 +549,6 @@ void SymbolFileDWARF::LoadSectionData(ll
   m_obj_file->ReadSectionData(section_sp.get(), data);
 }
 
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_addr_data() {
-  return GetCachedSectionData(eSectionTypeDWARFDebugAddr, m_data_debug_addr);
-}
-
 const DWARFDataExtractor &SymbolFileDWARF::DebugLocData() {
   const DWARFDataExtractor &debugLocData = get_debug_loc_data();
   if (debugLocData.GetByteSize() > 0)

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=361232&r1=361231&r2=361232&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Tue May 21 02:11:11 2019
@@ -212,7 +212,6 @@ public:
 
   uint32_t GetPluginVersion() override;
 
-  virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data();
   const lldb_private::DWARFDataExtractor &get_debug_loc_data();
   const lldb_private::DWARFDataExtractor &get_debug_loclists_data();
   const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
@@ -451,7 +450,6 @@ protected:
 
   lldb_private::DWARFContext m_context;
 
-  DWARFDataSegment m_data_debug_addr;
   DWARFDataSegment m_data_debug_loc;
   DWARFDataSegment m_data_debug_loclists;
   DWARFDataSegment m_data_debug_ranges;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp?rev=361232&r1=361231&r2=361232&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp Tue May 21 02:11:11 2019
@@ -112,19 +112,6 @@ DWARFUnit *SymbolFileDWARFDwo::GetBaseCo
   return m_base_dwarf_cu;
 }
 
-const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_addr_data() {
-  // For single file split dwarf case (when we have .dwo sections in a .o),
-  // we do not want to use the .debug_addr section from .o file,
-  // but want to get one from the final executable.
-  // For regular split debug case, .dwo file does not contain the
-  // .debug_addr, so we would always fall back to such lookup anyways.
-  llvm::call_once(m_data_debug_addr.m_flag, [this] {
-    SymbolFileDWARF::LoadSectionData(eSectionTypeDWARFDebugAddr,
-                                     std::ref(m_data_debug_addr.m_data));
-  });
-  return m_data_debug_addr.m_data;
-}
-
 SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
   return m_base_dwarf_cu->GetSymbolFileDWARF();
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h?rev=361232&r1=361231&r2=361232&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h Tue May 21 02:11:11 2019
@@ -45,8 +45,6 @@ public:
 
   DWARFUnit *GetBaseCompileUnit() override;
 
-  const lldb_private::DWARFDataExtractor &get_debug_addr_data() override;
-
 protected:
   void LoadSectionData(lldb::SectionType sect_type,
                        lldb_private::DWARFDataExtractor &data) override;




More information about the lldb-commits mailing list