summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 179d6afa579..246899ac12b 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -957,6 +957,26 @@ static bool isRelocScattered(const object::ObjectFile &Obj,
return MachObj->isRelocationScattered(RelocInfo);
}
+Error DWARFContextInMemory::maybeDecompress(const SectionRef &Sec,
+ StringRef Name, StringRef &Data) {
+ if (!Decompressor::isCompressed(Sec))
+ return Error::success();
+
+ Expected<Decompressor> Decompressor =
+ Decompressor::create(Name, Data, IsLittleEndian, AddressSize == 8);
+ if (!Decompressor)
+ return Decompressor.takeError();
+
+ SmallString<32> Out;
+ if (auto Err = Decompressor->decompress(Out))
+ return Err;
+
+ UncompressedSections.emplace_back(std::move(Out));
+ Data = UncompressedSections.back();
+
+ return Error::success();
+}
+
DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
const LoadedObjectInfo *L)
: IsLittleEndian(Obj.isLittleEndian()),
@@ -980,16 +1000,11 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
if (!L || !L->getLoadedSectionContents(*RelocatedSection,data))
Section.getContents(data);
- if (Decompressor::isCompressed(Section)) {
- Expected<Decompressor> Decompressor =
- Decompressor::create(name, data, IsLittleEndian, AddressSize == 8);
- if (!Decompressor)
- continue;
- SmallString<32> Out;
- if (auto Err = Decompressor->decompress(Out))
- continue;
- UncompressedSections.emplace_back(std::move(Out));
- data = UncompressedSections.back();
+ if (auto Err = maybeDecompress(Section, name, data)) {
+ errs() << "error: failed to decompress '" + name + "', " +
+ toString(std::move(Err))
+ << '\n';
+ continue;
}
// Compressed sections names in GNU style starts from ".z",
OpenPOWER on IntegriCloud