[PATCH] D20470: [llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Sat May 21 02:16:47 PDT 2016


grimar added inline comments.

================
Comment at: lib/DebugInfo/DWARF/DWARFContext.cpp:626
@@ +625,3 @@
+  if (Is64Bit)
+    Extractor.getUnsigned(&Offset, sizeof(Elf64_Word));
+
----------------
dblaikie wrote:
> You could just increment Offset (by sizeof(Elf64_Word)) here, I think?
Right.

================
Comment at: lib/DebugInfo/DWARF/DWARFContext.cpp:681-685
@@ -639,10 +680,7 @@
+    if (ZLibStyleCompressed || name.startswith("zdebug_")) {
+      SmallString<32> Out;
+      if (!tryDecompress(name, data, Out, ZLibStyleCompressed, IsLittleEndian,
+                         AddressSize == 8))
         continue;
-      UncompressedSections.resize(UncompressedSections.size() + 1);
-      if (zlib::uncompress(data, UncompressedSections.back(), OriginalSize) !=
-          zlib::StatusOK) {
-        UncompressedSections.pop_back();
-        continue;
-      }
-      // Make data point to uncompressed section contents and save its contents.
-      name = name.substr(1);
+      UncompressedSections.emplace_back(Out);
       data = UncompressedSections.back();
----------------
dblaikie wrote:
> This involves making extra copies of the data. Is there a reason you went with this over the original code that decompressed straight into the UncompressedSections?
My point was to avoid possible calls of pop_back right after resize if decompression fails. 
That should be rare case (I think decompression fail is infrequent, except cases of disabled zlib (now check for that is inside tryDecompress)), but code itself looks bit overcomplicated.

I just forgot to use std::move() to avoid extras when rewrote. Fixed. There should be no more extra heap allocations here.


http://reviews.llvm.org/D20470





More information about the llvm-commits mailing list