mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
llvm-dwp: Pull out compression handling helper
llvm-svn: 270496
This commit is contained in:
parent
46f1665f19
commit
dbfa9e5cd4
@ -359,6 +359,25 @@ std::string buildDWODescription(StringRef Name, StringRef DWPName, StringRef DWO
|
|||||||
return Text;
|
return Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Error handleCompressedSection(
|
||||||
|
SmallVector<SmallString<32>, 4> &UncompressedSections, StringRef &Name,
|
||||||
|
StringRef &Contents) {
|
||||||
|
if (!Name.startswith("zdebug_"))
|
||||||
|
return Error();
|
||||||
|
UncompressedSections.emplace_back();
|
||||||
|
uint64_t OriginalSize;
|
||||||
|
if (!zlib::isAvailable())
|
||||||
|
return make_error<DWPError>("zlib not available");
|
||||||
|
if (!consumeCompressedDebugSectionHeader(Contents, OriginalSize) ||
|
||||||
|
zlib::uncompress(Contents, UncompressedSections.back(), OriginalSize) !=
|
||||||
|
zlib::StatusOK)
|
||||||
|
return make_error<DWPError>(
|
||||||
|
("failure while decompressing compressed section: '" + Name + "\'")
|
||||||
|
.str());
|
||||||
|
Name = Name.substr(1);
|
||||||
|
Contents = UncompressedSections.back();
|
||||||
|
return Error();
|
||||||
|
}
|
||||||
Error buildDuplicateError(const std::pair<uint64_t, UnitIndexEntry> &PrevE,
|
Error buildDuplicateError(const std::pair<uint64_t, UnitIndexEntry> &PrevE,
|
||||||
const CompileUnitIdentifiers &ID, StringRef DWPName) {
|
const CompileUnitIdentifiers &ID, StringRef DWPName) {
|
||||||
return make_error<DWPError>(
|
return make_error<DWPError>(
|
||||||
@ -431,21 +450,9 @@ static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
|
|||||||
if (auto Err = Section.getContents(Contents))
|
if (auto Err = Section.getContents(Contents))
|
||||||
return errorCodeToError(Err);
|
return errorCodeToError(Err);
|
||||||
|
|
||||||
if (Name.startswith("zdebug_")) {
|
if (auto Err =
|
||||||
UncompressedSections.emplace_back();
|
handleCompressedSection(UncompressedSections, Name, Contents))
|
||||||
uint64_t OriginalSize;
|
return Err;
|
||||||
if (!zlib::isAvailable())
|
|
||||||
return make_error<DWPError>("zlib not available");
|
|
||||||
if (!consumeCompressedDebugSectionHeader(Contents, OriginalSize) ||
|
|
||||||
zlib::uncompress(Contents, UncompressedSections.back(),
|
|
||||||
OriginalSize) != zlib::StatusOK)
|
|
||||||
return make_error<DWPError>(
|
|
||||||
("failure while decompressing compressed section: '" + Name +
|
|
||||||
"\'")
|
|
||||||
.str());
|
|
||||||
Name = Name.substr(1);
|
|
||||||
Contents = UncompressedSections.back();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto SectionPair = KnownSections.find(Name);
|
auto SectionPair = KnownSections.find(Name);
|
||||||
if (SectionPair == KnownSections.end())
|
if (SectionPair == KnownSections.end())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user