[PATCH] D41531: [DebugInfo/DWARF] generate aranges for CU even if it has .debug_aranges entry

Igor Sugak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 21 16:33:18 PST 2017


sugak created this revision.
sugak added reviewers: grimar, inglorion, echristo.
Herald added a subscriber: JDevlieghere.

Not all of the functions have entries in `.debug_aranges`, but there are always `.debug_info` entries for them. Currently, this generates aranges for all of the compilation unit if there are no .debug_arange entries (see how ParsedCUOffsets is used). But this is not completely correct, in practice, a compilation unit might have an entry in `.debug_arange` which doesn't cover all of the functions and it's `.debug_info`s still, have to be considered.
To solve the problem remove `ParsedCUOffsets` which is used to determine if a CU has a `.debug_arages`.

With this change I was able to get full locations in ASAN stack traces with llvm-symbolizer that previously were not decoded:
Before:

  #2 0x7f9a8807b2bb in foo(bar<void ()>) (.../libfoo.so+0xff2bb)

After:

  #2 0x7f1a85c8f2bb in fin foo(bar<void ()>) foo/foo.cpp:589


Repository:
  rL LLVM

https://reviews.llvm.org/D41531

Files:
  include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
  lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
  lib/DebugInfo/DWARF/DWARFVerifier.cpp
  tools/llvm-dwarfdump/Statistics.cpp


Index: tools/llvm-dwarfdump/Statistics.cpp
===================================================================
--- tools/llvm-dwarfdump/Statistics.cpp
+++ tools/llvm-dwarfdump/Statistics.cpp
@@ -1,4 +1,5 @@
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/DebugInfo/DIContext.h"
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
Index: lib/DebugInfo/DWARF/DWARFVerifier.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "SyntaxHighlighting.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/DebugInfo/DWARF/DWARFVerifier.h"
 #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
Index: lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
+++ lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
@@ -33,7 +33,6 @@
       uint64_t HighPC = Desc.getEndAddress();
       appendRange(CUOffset, LowPC, HighPC);
     }
-    ParsedCUOffsets.insert(CUOffset);
   }
 }
 
@@ -52,21 +51,18 @@
   // manually build aranges for the rest of them.
   for (const auto &CU : CTX->compile_units()) {
     uint32_t CUOffset = CU->getOffset();
-    if (ParsedCUOffsets.insert(CUOffset).second) {
-      DWARFAddressRangesVector CURanges;
-      CU->collectAddressRanges(CURanges);
-      for (const auto &R : CURanges)
-        appendRange(CUOffset, R.LowPC, R.HighPC);
-    }
+    DWARFAddressRangesVector CURanges;
+    CU->collectAddressRanges(CURanges);
+    for (const auto &R : CURanges)
+      appendRange(CUOffset, R.LowPC, R.HighPC);
   }
 
   construct();
 }
 
 void DWARFDebugAranges::clear() {
   Endpoints.clear();
   Aranges.clear();
-  ParsedCUOffsets.clear();
 }
 
 void DWARFDebugAranges::appendRange(uint32_t CUOffset, uint64_t LowPC,
Index: include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
===================================================================
--- include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
+++ include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
@@ -10,7 +10,6 @@
 #ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
 #define LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
 
-#include "llvm/ADT/DenseSet.h"
 #include "llvm/Support/DataExtractor.h"
 #include <cstdint>
 #include <vector>
@@ -81,7 +80,6 @@
 
   std::vector<RangeEndpoint> Endpoints;
   RangeColl Aranges;
-  DenseSet<uint32_t> ParsedCUOffsets;
 };
 
 } // end namespace llvm


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41531.127963.patch
Type: text/x-patch
Size: 2667 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171222/6e3405de/attachment.bin>


More information about the llvm-commits mailing list