[Lldb-commits] [lldb] r363400 - DWARF: port debug_ranges/rnglists over to DWARFContext

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 14 07:12:25 PDT 2019


Author: labath
Date: Fri Jun 14 07:12:25 2019
New Revision: 363400

URL: http://llvm.org/viewvc/llvm-project?rev=363400&view=rev
Log:
DWARF: port debug_ranges/rnglists over to DWARFContext

Modified:
    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/DWARFDebugRanges.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

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=363400&r1=363399&r2=363400&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp Fri Jun 14 07:12:25 2019
@@ -75,6 +75,16 @@ const DWARFDataExtractor &DWARFContext::
                           m_data_debug_macro);
 }
 
+const DWARFDataExtractor &DWARFContext::getOrLoadRangesData() {
+  return LoadOrGetSection(eSectionTypeDWARFDebugRanges, llvm::None,
+                          m_data_debug_ranges);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadRngListsData() {
+  return LoadOrGetSection(eSectionTypeDWARFDebugRngLists, llvm::None,
+                          m_data_debug_rnglists);
+}
+
 const DWARFDataExtractor &DWARFContext::getOrLoadStrData() {
   return LoadOrGetSection(eSectionTypeDWARFDebugStr,
                           eSectionTypeDWARFDebugStrDwo, m_data_debug_str);

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=363400&r1=363399&r2=363400&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h Fri Jun 14 07:12:25 2019
@@ -33,6 +33,8 @@ private:
   SectionData m_data_debug_line;
   SectionData m_data_debug_line_str;
   SectionData m_data_debug_macro;
+  SectionData m_data_debug_ranges;
+  SectionData m_data_debug_rnglists;
   SectionData m_data_debug_str;
   SectionData m_data_debug_str_offsets;
   SectionData m_data_debug_types;
@@ -57,6 +59,8 @@ public:
   const DWARFDataExtractor &getOrLoadLineData();
   const DWARFDataExtractor &getOrLoadLineStrData();
   const DWARFDataExtractor &getOrLoadMacroData();
+  const DWARFDataExtractor &getOrLoadRangesData();
+  const DWARFDataExtractor &getOrLoadRngListsData();
   const DWARFDataExtractor &getOrLoadStrData();
   const DWARFDataExtractor &getOrLoadStrOffsetsData();
   const DWARFDataExtractor &getOrLoadDebugTypesData();

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=363400&r1=363399&r2=363400&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp Fri Jun 14 07:12:25 2019
@@ -8,12 +8,9 @@
 
 #include "DWARFDebugRanges.h"
 #include "DWARFUnit.h"
-#include "SymbolFileDWARF.h"
 #include "lldb/Utility/Stream.h"
-#include <assert.h>
 
 using namespace lldb_private;
-using namespace std;
 
 static dw_addr_t GetBaseAddressMarker(uint32_t addr_size) {
   switch(addr_size) {
@@ -29,25 +26,24 @@ static dw_addr_t GetBaseAddressMarker(ui
 
 DWARFDebugRanges::DWARFDebugRanges() : m_range_map() {}
 
-void DWARFDebugRanges::Extract(SymbolFileDWARF *dwarf2Data) {
+void DWARFDebugRanges::Extract(DWARFContext &context) {
   DWARFRangeList range_list;
   lldb::offset_t offset = 0;
   dw_offset_t debug_ranges_offset = offset;
-  while (Extract(dwarf2Data, &offset, range_list)) {
+  while (Extract(context, &offset, range_list)) {
     range_list.Sort();
     m_range_map[debug_ranges_offset] = range_list;
     debug_ranges_offset = offset;
   }
 }
 
-bool DWARFDebugRanges::Extract(SymbolFileDWARF *dwarf2Data,
+bool DWARFDebugRanges::Extract(DWARFContext &context,
                                lldb::offset_t *offset_ptr,
                                DWARFRangeList &range_list) {
   range_list.Clear();
 
   lldb::offset_t range_offset = *offset_ptr;
-  const DWARFDataExtractor &debug_ranges_data =
-      dwarf2Data->get_debug_ranges_data();
+  const DWARFDataExtractor &debug_ranges_data = context.getOrLoadRangesData();
   uint32_t addr_size = debug_ranges_data.GetAddressByteSize();
   dw_addr_t base_addr = 0;
   dw_addr_t base_addr_marker = GetBaseAddressMarker(addr_size);
@@ -257,8 +253,8 @@ bool DWARFDebugRngLists::FindRanges(cons
   return false;
 }
 
-void DWARFDebugRngLists::Extract(SymbolFileDWARF *dwarf2Data) {
-  const DWARFDataExtractor &data = dwarf2Data->get_debug_rnglists_data();
+void DWARFDebugRngLists::Extract(DWARFContext &context) {
+  const DWARFDataExtractor &data = context.getOrLoadRngListsData();
   lldb::offset_t offset = 0;
 
   uint64_t length = data.GetU32(&offset);

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h?rev=363400&r1=363399&r2=363400&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h Fri Jun 14 07:12:25 2019
@@ -9,16 +9,19 @@
 #ifndef SymbolFileDWARF_DWARFDebugRanges_h_
 #define SymbolFileDWARF_DWARFDebugRanges_h_
 
-#include "DWARFDIE.h"
-#include "SymbolFileDWARF.h"
-
+#include "lldb/Core/dwarf.h"
 #include <map>
 
+class DWARFUnit;
+namespace lldb_private {
+class DWARFContext;
+}
+
 class DWARFDebugRangesBase {
 public:
   virtual ~DWARFDebugRangesBase(){};
 
-  virtual void Extract(SymbolFileDWARF *dwarf2Data) = 0;
+  virtual void Extract(lldb_private::DWARFContext &context) = 0;
   virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
                           DWARFRangeList &range_list) const = 0;
   virtual uint64_t GetOffset(size_t Index) const = 0;
@@ -28,7 +31,7 @@ class DWARFDebugRanges final : public DW
 public:
   DWARFDebugRanges();
 
-  void Extract(SymbolFileDWARF *dwarf2Data) override;
+  void Extract(lldb_private::DWARFContext &context) override;
   bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
                   DWARFRangeList &range_list) const override;
   uint64_t GetOffset(size_t Index) const override;
@@ -38,7 +41,7 @@ public:
                    lldb::offset_t *offset_ptr, dw_addr_t cu_base_addr);
 
 protected:
-  bool Extract(SymbolFileDWARF *dwarf2Data, lldb::offset_t *offset_ptr,
+  bool Extract(lldb_private::DWARFContext &context, lldb::offset_t *offset_ptr,
                DWARFRangeList &range_list);
 
   typedef std::map<dw_offset_t, DWARFRangeList> range_map;
@@ -56,7 +59,7 @@ class DWARFDebugRngLists final : public
   };
 
 public:
-  void Extract(SymbolFileDWARF *dwarf2Data) override;
+  void Extract(lldb_private::DWARFContext &context) override;
   bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
                   DWARFRangeList &range_list) const override;
   uint64_t GetOffset(size_t Index) const override;

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=363400&r1=363399&r2=363400&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Jun 14 07:12:25 2019
@@ -355,8 +355,7 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectF
                                   // contain the .o file index/ID
       m_debug_map_module_wp(), m_debug_map_symfile(nullptr),
       m_context(objfile->GetModule()->GetSectionList(), dwo_section_list),
-      m_data_debug_loc(), m_data_debug_ranges(), m_data_debug_rnglists(),
-      m_abbr(), m_info(), m_fetched_external_modules(false),
+      m_data_debug_loc(), m_abbr(), m_info(), m_fetched_external_modules(false),
       m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate),
       m_unique_ast_type_map() {}
 
@@ -549,16 +548,6 @@ const DWARFDataExtractor &SymbolFileDWAR
                               m_data_debug_loclists);
 }
 
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_ranges_data() {
-  return GetCachedSectionData(eSectionTypeDWARFDebugRanges,
-                              m_data_debug_ranges);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_rnglists_data() {
-  return GetCachedSectionData(eSectionTypeDWARFDebugRngLists,
-                              m_data_debug_rnglists);
-}
-
 DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
   if (m_abbr)
     return m_abbr.get();
@@ -621,11 +610,11 @@ DWARFDebugRangesBase *SymbolFileDWARF::G
     Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
                        static_cast<void *>(this));
 
-    if (get_debug_ranges_data().GetByteSize() > 0)
+    if (m_context.getOrLoadRangesData().GetByteSize() > 0)
       m_ranges.reset(new DWARFDebugRanges());
 
     if (m_ranges)
-      m_ranges->Extract(this);
+      m_ranges->Extract(m_context);
   }
   return m_ranges.get();
 }
@@ -636,11 +625,11 @@ DWARFDebugRangesBase *SymbolFileDWARF::G
     Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
                        static_cast<void *>(this));
 
-    if (get_debug_rnglists_data().GetByteSize() > 0)
+    if (m_context.getOrLoadRngListsData().GetByteSize() > 0)
       m_rnglists.reset(new DWARFDebugRngLists());
 
     if (m_rnglists)
-      m_rnglists->Extract(this);
+      m_rnglists->Extract(m_context);
   }
   return m_rnglists.get();
 }

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=363400&r1=363399&r2=363400&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Jun 14 07:12:25 2019
@@ -215,8 +215,6 @@ public:
 
   const lldb_private::DWARFDataExtractor &get_debug_loc_data();
   const lldb_private::DWARFDataExtractor &get_debug_loclists_data();
-  const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
-  const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
 
   DWARFDebugAbbrev *DebugAbbrev();
 
@@ -457,8 +455,6 @@ protected:
 
   DWARFDataSegment m_data_debug_loc;
   DWARFDataSegment m_data_debug_loclists;
-  DWARFDataSegment m_data_debug_ranges;
-  DWARFDataSegment m_data_debug_rnglists;
 
   // The unique pointer items below are generated on demand if and when someone
   // accesses them through a non const version of this class.




More information about the lldb-commits mailing list