1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

[ObjectYAML][DWARF] Add one helper function writeInitialLength(). NFC.

This commit is contained in:
Xing GUO 2020-06-12 21:10:14 +08:00
parent 7956ed7a6d
commit 6780e06d24

View File

@ -70,6 +70,15 @@ static void writeInitialLength(const DWARFYAML::InitialLength &Length,
writeInteger((uint64_t)Length.TotalLength64, OS, IsLittleEndian);
}
static void writeInitialLength(const dwarf::DwarfFormat Format,
const uint64_t Length, raw_ostream &OS,
bool IsLittleEndian) {
bool IsDWARF64 = Format == dwarf::DWARF64;
if (IsDWARF64)
writeVariableSizedInteger(dwarf::DW_LENGTH_DWARF64, 4, OS, IsLittleEndian);
writeVariableSizedInteger(Length, IsDWARF64 ? 8 : 4, OS, IsLittleEndian);
}
Error DWARFYAML::emitDebugStr(raw_ostream &OS, const DWARFYAML::Data &DI) {
for (auto Str : DI.DebugStrings) {
OS.write(Str.data(), Str.size());
@ -100,11 +109,7 @@ Error DWARFYAML::emitDebugAbbrev(raw_ostream &OS, const DWARFYAML::Data &DI) {
Error DWARFYAML::emitDebugAranges(raw_ostream &OS, const DWARFYAML::Data &DI) {
for (auto Range : DI.ARanges) {
auto HeaderStart = OS.tell();
if (Range.Format == dwarf::DWARF64) {
writeInteger((uint32_t)dwarf::DW_LENGTH_DWARF64, OS, DI.IsLittleEndian);
writeInteger((uint64_t)Range.Length, OS, DI.IsLittleEndian);
} else
writeInteger((uint32_t)Range.Length, OS, DI.IsLittleEndian);
writeInitialLength(Range.Format, Range.Length, OS, DI.IsLittleEndian);
writeInteger((uint16_t)Range.Version, OS, DI.IsLittleEndian);
if (Range.Format == dwarf::DWARF64)
writeInteger((uint64_t)Range.CuOffset, OS, DI.IsLittleEndian);