jankratochvil created this revision.
jankratochvil added a reviewer: labath.
jankratochvil added a project: LLDB.
jankratochvil added a child revision: D81334: 2/2: [lldb] Fix 
DW_TAG_GNU_call_site-DW_AT_low_pc as produced by GCC.

There is Labath's comment <https://reviews.llvm.org/D81334#inline-747719> which 
is more tricky than it looks.  So first cleanup the code a bit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81423

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -47,10 +47,9 @@
   bool Extract(const lldb_private::DWARFDataExtractor &data,
                const DWARFUnit *cu, lldb::offset_t *offset_ptr);
 
-  size_t GetAttributes(const DWARFUnit *cu,
-                       DWARFAttributes &attrs,
-                       uint32_t curr_depth = 0)
-      const; // "curr_depth" for internal use only, don't set this yourself!!!
+  size_t GetAttributes(const DWARFUnit *cu, DWARFAttributes &attrs) const {
+    return GetAttributes(cu, attrs, 0 /* curr_depth */);
+  }
 
   dw_offset_t
   GetAttributeValue(const DWARFUnit *cu, const dw_attr_t attr,
@@ -176,6 +175,11 @@
   /// A copy of the DW_TAG value so we don't have to go through the compile
   /// unit abbrev table
   dw_tag_t m_tag = llvm::dwarf::DW_TAG_null;
+
+private:
+  size_t GetAttributes(const DWARFUnit *cu, DWARFAttributes &attrs,
+                       uint32_t curr_depth)
+      const; // "curr_depth" for internal use only, don't set this yourself!!!
 };
 
 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFOENTRY_H
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -436,7 +436,8 @@
         if (form_value.ExtractValue(data, &offset)) {
           DWARFDIE spec_die = form_value.Reference();
           if (spec_die)
-            spec_die.GetAttributes(attributes, curr_depth + 1);
+            spec_die.GetDIE()->GetAttributes(spec_die.GetCU(), attributes,
+                                             curr_depth + 1);
         }
       } else {
         llvm::Optional<uint8_t> fixed_skip_size = 
DWARFFormValue::GetFixedSize(form, cu);
@@ -729,7 +730,7 @@
 DWARFDIE
 DWARFDebugInfoEntry::GetParentDeclContextDIE(DWARFUnit *cu) const {
   DWARFAttributes attributes;
-  GetAttributes(cu, attributes);
+  GetAttributes(cu, attributes, 0 /* curr_depth */);
   return GetParentDeclContextDIE(cu, attributes);
 }
 
@@ -779,7 +780,7 @@
 const char *DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
                                                   std::string &storage) const {
   DWARFAttributes attributes;
-  GetAttributes(cu, attributes);
+  GetAttributes(cu, attributes, 0 /* curr_depth */);
   return GetQualifiedName(cu, attributes, storage);
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
@@ -110,7 +110,7 @@
   uint64_t GetAttributeValueAsAddress(const dw_attr_t attr,
                                       uint64_t fail_value) const;
 
-  size_t GetAttributes(DWARFAttributes &attributes, uint32_t depth = 0) const;
+  size_t GetAttributes(DWARFAttributes &attributes) const;
 
 protected:
   DWARFUnit *m_cu;
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
@@ -104,12 +104,10 @@
   return IsValid() && 
GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu);
 }
 
-size_t DWARFBaseDIE::GetAttributes(DWARFAttributes &attributes,
-                               uint32_t depth) const {
+size_t DWARFBaseDIE::GetAttributes(DWARFAttributes &attributes) const {
   if (IsValid())
-    return m_die->GetAttributes(m_cu, attributes, depth);
-  if (depth == 0)
-    attributes.Clear();
+    return m_die->GetAttributes(m_cu, attributes);
+  attributes.Clear();
   return 0;
 }
 


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -47,10 +47,9 @@
   bool Extract(const lldb_private::DWARFDataExtractor &data,
                const DWARFUnit *cu, lldb::offset_t *offset_ptr);
 
-  size_t GetAttributes(const DWARFUnit *cu,
-                       DWARFAttributes &attrs,
-                       uint32_t curr_depth = 0)
-      const; // "curr_depth" for internal use only, don't set this yourself!!!
+  size_t GetAttributes(const DWARFUnit *cu, DWARFAttributes &attrs) const {
+    return GetAttributes(cu, attrs, 0 /* curr_depth */);
+  }
 
   dw_offset_t
   GetAttributeValue(const DWARFUnit *cu, const dw_attr_t attr,
@@ -176,6 +175,11 @@
   /// A copy of the DW_TAG value so we don't have to go through the compile
   /// unit abbrev table
   dw_tag_t m_tag = llvm::dwarf::DW_TAG_null;
+
+private:
+  size_t GetAttributes(const DWARFUnit *cu, DWARFAttributes &attrs,
+                       uint32_t curr_depth)
+      const; // "curr_depth" for internal use only, don't set this yourself!!!
 };
 
 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFOENTRY_H
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -436,7 +436,8 @@
         if (form_value.ExtractValue(data, &offset)) {
           DWARFDIE spec_die = form_value.Reference();
           if (spec_die)
-            spec_die.GetAttributes(attributes, curr_depth + 1);
+            spec_die.GetDIE()->GetAttributes(spec_die.GetCU(), attributes,
+                                             curr_depth + 1);
         }
       } else {
         llvm::Optional<uint8_t> fixed_skip_size = DWARFFormValue::GetFixedSize(form, cu);
@@ -729,7 +730,7 @@
 DWARFDIE
 DWARFDebugInfoEntry::GetParentDeclContextDIE(DWARFUnit *cu) const {
   DWARFAttributes attributes;
-  GetAttributes(cu, attributes);
+  GetAttributes(cu, attributes, 0 /* curr_depth */);
   return GetParentDeclContextDIE(cu, attributes);
 }
 
@@ -779,7 +780,7 @@
 const char *DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
                                                   std::string &storage) const {
   DWARFAttributes attributes;
-  GetAttributes(cu, attributes);
+  GetAttributes(cu, attributes, 0 /* curr_depth */);
   return GetQualifiedName(cu, attributes, storage);
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
@@ -110,7 +110,7 @@
   uint64_t GetAttributeValueAsAddress(const dw_attr_t attr,
                                       uint64_t fail_value) const;
 
-  size_t GetAttributes(DWARFAttributes &attributes, uint32_t depth = 0) const;
+  size_t GetAttributes(DWARFAttributes &attributes) const;
 
 protected:
   DWARFUnit *m_cu;
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
@@ -104,12 +104,10 @@
   return IsValid() && GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu);
 }
 
-size_t DWARFBaseDIE::GetAttributes(DWARFAttributes &attributes,
-                               uint32_t depth) const {
+size_t DWARFBaseDIE::GetAttributes(DWARFAttributes &attributes) const {
   if (IsValid())
-    return m_die->GetAttributes(m_cu, attributes, depth);
-  if (depth == 0)
-    attributes.Clear();
+    return m_die->GetAttributes(m_cu, attributes);
+  attributes.Clear();
   return 0;
 }
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to