[Lldb-commits] [lldb] 9b737f1 - [lldb] Limit trusting aranges to dSYMs only.

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 9 15:38:12 PST 2023


Author: Jonas Devlieghere
Date: 2023-01-09T15:38:05-08:00
New Revision: 9b737f148d88501a0a778e1adacf342108286bb0

URL: https://github.com/llvm/llvm-project/commit/9b737f148d88501a0a778e1adacf342108286bb0
DIFF: https://github.com/llvm/llvm-project/commit/9b737f148d88501a0a778e1adacf342108286bb0.diff

LOG: [lldb] Limit trusting aranges to dSYMs only.

Limit trusting the arange accelerator tables (8b259fe573e1) to dSYMs
only, and not any debug info object file.

Differential revision: https://reviews.llvm.org/D141330

Added: 
    

Modified: 
    lldb/include/lldb/Symbol/ObjectFile.h
    lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
    lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h
index 4d6c8f1105a04..e2e0623c9f9ed 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -682,6 +682,10 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
     return symbol_name;
   }
 
+  /// Can we trust the address ranges accelerator associated with this object
+  /// file to be complete.
+  virtual bool CanTrustAddressRanges() { return false; }
+
   static lldb::SymbolType GetSymbolTypeFromName(
       llvm::StringRef name,
       lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined);

diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 767ab87c2f529..84856590fe8ad 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -6094,6 +6094,12 @@ bool ObjectFileMachO::GetIsDynamicLinkEditor() {
   return m_header.filetype == llvm::MachO::MH_DYLINKER;
 }
 
+bool ObjectFileMachO::CanTrustAddressRanges() {
+  // Dsymutil guarantees that the .debug_aranges accelerator is complete and can
+  // be trusted by LLDB.
+  return m_header.filetype == llvm::MachO::MH_DSYM;
+}
+
 bool ObjectFileMachO::AllowAssemblyEmulationUnwindPlans() {
   return m_allow_assembly_emulation_unwind_plans;
 }

diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
index 343e3bc004b6f..3b458d8da8342 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
@@ -143,6 +143,8 @@ class ObjectFileMachO : public lldb_private::ObjectFile {
 
   bool GetIsDynamicLinkEditor() override;
 
+  bool CanTrustAddressRanges() override;
+
   static bool ParseHeader(lldb_private::DataExtractor &data,
                           lldb::offset_t *data_offset_ptr,
                           llvm::MachO::mach_header &header);

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 47f9672ba5968..b631985d60c45 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -53,12 +53,13 @@ const DWARFDebugAranges &DWARFDebugInfo::GetCompileUnitAranges() {
   }
 
   // Manually build arange data for everything that wasn't in .debug_aranges.
-  // Skip this step for dSYMs as we can trust dsymutil to have emitted complete
-  // aranges.
-  const bool is_dsym =
-      m_dwarf.GetObjectFile() &&
-      m_dwarf.GetObjectFile()->GetType() == ObjectFile::eTypeDebugInfo;
-  if (!is_dsym) {
+  // The .debug_aranges accelerator is not guaranteed to be complete.
+  // Tools such as dsymutil can provide stronger guarantees than required by the
+  // standard. Without that guarantee, we have to iterate over every CU in the
+  // .debug_info and make sure there's a corresponding entry in the table and if
+  // not, add one for every subprogram.
+  ObjectFile *OF = m_dwarf.GetObjectFile();
+  if (!OF || !OF->CanTrustAddressRanges()) {
     const size_t num_units = GetNumUnits();
     for (size_t idx = 0; idx < num_units; ++idx) {
       DWARFUnit *cu = GetUnitAtIndex(idx);


        


More information about the lldb-commits mailing list