[Lldb-commits] [PATCH] Fixed parsing of the .debug_aranges section.

Richard Mitton richard at codersnotes.com
Thu Sep 5 11:15:59 PDT 2013


Fixed parsing of the .debug_aranges section so that LLDB will still work correctly even if arange data is not available for every object file in the program.

This fixes the bug where a program built using a mix of gcc and clang would not be able to debug the clang parts.

http://llvm-reviews.chandlerc.com/D1609

Files:
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -66,18 +66,37 @@
             m_cu_aranges_ap->Extract (debug_aranges_data);
             
         }
-        else
+
+        // Make a list of all CUs represented by the arange data in the file.
+        std::set<DWARFCompileUnit *> cus_with_data;
+        for (size_t n=0;n<m_cu_aranges_ap.get()->GetNumRanges();n++)
         {
-            if (log)
-                log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" by parsing", 
-                             m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
-            const size_t num_compile_units = GetNumCompileUnits();
-            const bool clear_dies_if_already_not_parsed = true;
-            for (size_t idx = 0; idx < num_compile_units; ++idx)
+            dw_offset_t offset = m_cu_aranges_ap.get()->OffsetAtIndex(n);
+            if (offset != DW_INVALID_OFFSET)
             {
-                DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx);
-                if (cu)
-                    cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get(), clear_dies_if_already_not_parsed);
+                DWARFCompileUnitSP cu = GetCompileUnit (offset);
+                if (cu.get())
+                    cus_with_data.insert (cu.get());
+            }
+        }
+
+        // Manually build arange data for everything that wasn't in the .debug_aranges table.
+        bool printed = false;
+        const size_t num_compile_units = GetNumCompileUnits();
+        const bool clear_dies_if_already_not_parsed = true;
+        for (size_t idx = 0; idx < num_compile_units; ++idx)
+        {
+            DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx);
+            if (cu && cus_with_data.find(cu) == cus_with_data.end())
+            {
+                if (log)
+                {
+                    if (!printed)
+                        log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" by parsing",
+                                     m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
+                    printed = true;
+                }
+                cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get(), clear_dies_if_already_not_parsed);
             }
         }
 
Index: source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
@@ -174,10 +174,11 @@
 {
     strm->Printf ("Logging categories for '%s':\n"
                   "  all - turn on all available logging categories\n"
-                  "  info - log the parsing if .debug_info\n"
-                  "  line - log the parsing if .debug_line\n"
-                  "  pubnames - log the parsing if .debug_pubnames\n"
-                  "  pubtypes - log the parsing if .debug_pubtypes\n"
+                  "  info - log the parsing of .debug_info\n"
+                  "  line - log the parsing of .debug_line\n"
+                  "  pubnames - log the parsing of .debug_pubnames\n"
+                  "  pubtypes - log the parsing of .debug_pubtypes\n"
+                  "  aranges - log the parsing of .debug_aranges\n"
                   "  lookups - log any lookups that happen by name, regex, or address\n"
                   "  completion - log struct/unions/class type completions\n"
                   "  map - log insertions of object files into DWARF debug maps\n",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1609.1.patch
Type: text/x-patch
Size: 3718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20130905/78a257d8/attachment.bin>


More information about the lldb-commits mailing list