diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/lib/DebugInfo/DWARF | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/DebugInfo/DWARF')
22 files changed, 478 insertions, 478 deletions
diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFAddressRange.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFAddressRange.cpp index 25d2e852a7..96766c48db 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFAddressRange.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFAddressRange.cpp @@ -18,9 +18,9 @@ void DWARFAddressRange::dump(raw_ostream &OS, uint32_t AddressSize, const DWARFObject *Obj) const { OS << (DumpOpts.DisplayRawContents ? " " : "["); - DWARFFormValue::dumpAddress(OS, AddressSize, LowPC); - OS << ", "; - DWARFFormValue::dumpAddress(OS, AddressSize, HighPC); + DWARFFormValue::dumpAddress(OS, AddressSize, LowPC); + OS << ", "; + DWARFFormValue::dumpAddress(OS, AddressSize, HighPC); OS << (DumpOpts.DisplayRawContents ? "" : ")"); if (Obj) diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp index 2b08120ef4..c3fceaa00f 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp @@ -22,10 +22,10 @@ void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) { << ", version = " << format("0x%04x", getVersion()); if (getVersion() >= 5) OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType()); - OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset()); - if (!getAbbreviations()) - OS << " (invalid)"; - OS << ", addr_size = " << format("0x%02x", getAddressByteSize()); + OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset()); + if (!getAbbreviations()) + OS << " (invalid)"; + OS << ", addr_size = " << format("0x%02x", getAddressByteSize()); if (getVersion() >= 5 && getUnitType() != dwarf::DW_UT_compile) OS << ", DWO_id = " << format("0x%016" PRIx64, *getDWOId()); OS << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset()) diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFContext.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFContext.cpp index 749d738af9..52cb9387e8 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -255,7 +255,7 @@ static void dumpRnglistsSection( break; Offset = TableOffset + Length; } else { - Rnglists.dump(rnglistData, OS, LookupPooledAddress, DumpOpts); + Rnglists.dump(rnglistData, OS, LookupPooledAddress, DumpOpts); } } } @@ -316,7 +316,7 @@ static void dumpLoclistsSection(raw_ostream &OS, DIDumpOptions DumpOpts, return; } - Header.dump(Data, OS, DumpOpts); + Header.dump(Data, OS, DumpOpts); uint64_t EndOffset = Header.length() + Header.getHeaderOffset(); Data.setAddressSize(Header.getAddrSize()); @@ -457,7 +457,7 @@ void DWARFContext::dump( shouldDump(Explicit, ".debug_frame", DIDT_ID_DebugFrame, DObj->getFrameSection().Data)) { if (Expected<const DWARFDebugFrame *> DF = getDebugFrame()) - (*DF)->dump(OS, DumpOpts, getRegisterInfo(), *Off); + (*DF)->dump(OS, DumpOpts, getRegisterInfo(), *Off); else RecoverableErrorHandler(DF.takeError()); } @@ -466,7 +466,7 @@ void DWARFContext::dump( shouldDump(Explicit, ".eh_frame", DIDT_ID_DebugFrame, DObj->getEHFrameSection().Data)) { if (Expected<const DWARFDebugFrame *> DF = getEHFrame()) - (*DF)->dump(OS, DumpOpts, getRegisterInfo(), *Off); + (*DF)->dump(OS, DumpOpts, getRegisterInfo(), *Off); else RecoverableErrorHandler(DF.takeError()); } @@ -502,8 +502,8 @@ void DWARFContext::dump( 0); DWARFDebugArangeSet set; while (arangesData.isValidOffset(offset)) { - if (Error E = - set.extract(arangesData, &offset, DumpOpts.WarningHandler)) { + if (Error E = + set.extract(arangesData, &offset, DumpOpts.WarningHandler)) { RecoverableErrorHandler(std::move(E)); break; } @@ -526,29 +526,29 @@ void DWARFContext::dump( } }; - auto DumpStrSection = [&](StringRef Section) { - DataExtractor StrData(Section, isLittleEndian(), 0); - uint64_t Offset = 0; - uint64_t StrOffset = 0; - while (StrData.isValidOffset(Offset)) { - Error Err = Error::success(); - const char *CStr = StrData.getCStr(&Offset, &Err); - if (Err) { - DumpOpts.WarningHandler(std::move(Err)); - return; - } - OS << format("0x%8.8" PRIx64 ": \"", StrOffset); - OS.write_escaped(CStr); - OS << "\"\n"; - StrOffset = Offset; - } - }; - + auto DumpStrSection = [&](StringRef Section) { + DataExtractor StrData(Section, isLittleEndian(), 0); + uint64_t Offset = 0; + uint64_t StrOffset = 0; + while (StrData.isValidOffset(Offset)) { + Error Err = Error::success(); + const char *CStr = StrData.getCStr(&Offset, &Err); + if (Err) { + DumpOpts.WarningHandler(std::move(Err)); + return; + } + OS << format("0x%8.8" PRIx64 ": \"", StrOffset); + OS.write_escaped(CStr); + OS << "\"\n"; + StrOffset = Offset; + } + }; + if (const auto *Off = shouldDump(Explicit, ".debug_line", DIDT_ID_DebugLine, DObj->getLineSection().Data)) { DWARFDataExtractor LineData(*DObj, DObj->getLineSection(), isLittleEndian(), 0); - DWARFDebugLine::SectionParser Parser(LineData, *this, normal_units()); + DWARFDebugLine::SectionParser Parser(LineData, *this, normal_units()); DumpLineSection(Parser, DumpOpts, *Off); } @@ -557,7 +557,7 @@ void DWARFContext::dump( DObj->getLineDWOSection().Data)) { DWARFDataExtractor LineData(*DObj, DObj->getLineDWOSection(), isLittleEndian(), 0); - DWARFDebugLine::SectionParser Parser(LineData, *this, dwo_units()); + DWARFDebugLine::SectionParser Parser(LineData, *this, dwo_units()); DumpLineSection(Parser, DumpOpts, *Off); } @@ -572,16 +572,16 @@ void DWARFContext::dump( } if (shouldDump(Explicit, ".debug_str", DIDT_ID_DebugStr, - DObj->getStrSection())) - DumpStrSection(DObj->getStrSection()); - + DObj->getStrSection())) + DumpStrSection(DObj->getStrSection()); + if (shouldDump(ExplicitDWO, ".debug_str.dwo", DIDT_ID_DebugStr, - DObj->getStrDWOSection())) - DumpStrSection(DObj->getStrDWOSection()); - + DObj->getStrDWOSection())) + DumpStrSection(DObj->getStrDWOSection()); + if (shouldDump(Explicit, ".debug_line_str", DIDT_ID_DebugLineStr, - DObj->getLineStrSection())) - DumpStrSection(DObj->getLineStrSection()); + DObj->getLineStrSection())) + DumpStrSection(DObj->getLineStrSection()); if (shouldDump(Explicit, ".debug_addr", DIDT_ID_DebugAddr, DObj->getAddrSection().Data)) { @@ -1034,9 +1034,9 @@ DWARFContext::DIEsForAddress DWARFContext::getDIEsForAddress(uint64_t Address) { static bool getFunctionNameAndStartLineForAddress(DWARFCompileUnit *CU, uint64_t Address, FunctionNameKind Kind, - DILineInfoSpecifier::FileLineInfoKind FileNameKind, + DILineInfoSpecifier::FileLineInfoKind FileNameKind, std::string &FunctionName, - std::string &StartFile, + std::string &StartFile, uint32_t &StartLine) { // The address may correspond to instruction in some inlined function, // so we have to build the chain of inlined functions and take the @@ -1053,11 +1053,11 @@ static bool getFunctionNameAndStartLineForAddress(DWARFCompileUnit *CU, FunctionName = Name; FoundResult = true; } - std::string DeclFile = DIE.getDeclFile(FileNameKind); - if (!DeclFile.empty()) { - StartFile = DeclFile; - FoundResult = true; - } + std::string DeclFile = DIE.getDeclFile(FileNameKind); + if (!DeclFile.empty()) { + StartFile = DeclFile; + FoundResult = true; + } if (auto DeclLineResult = DIE.getDeclLine()) { StartLine = DeclLineResult; FoundResult = true; @@ -1229,9 +1229,9 @@ DILineInfo DWARFContext::getLineInfoForAddress(object::SectionedAddress Address, if (!CU) return Result; - getFunctionNameAndStartLineForAddress(CU, Address.Address, Spec.FNKind, Spec.FLIKind, - Result.FunctionName, - Result.StartFileName, Result.StartLine); + getFunctionNameAndStartLineForAddress(CU, Address.Address, Spec.FNKind, Spec.FLIKind, + Result.FunctionName, + Result.StartFileName, Result.StartLine); if (Spec.FLIKind != FileLineInfoKind::None) { if (const DWARFLineTable *LineTable = getLineTableForUnit(CU)) { LineTable->getFileLineInfoForAddress( @@ -1250,17 +1250,17 @@ DILineInfoTable DWARFContext::getLineInfoForAddressRange( return Lines; uint32_t StartLine = 0; - std::string StartFileName; + std::string StartFileName; std::string FunctionName(DILineInfo::BadString); - getFunctionNameAndStartLineForAddress(CU, Address.Address, Spec.FNKind, Spec.FLIKind, - FunctionName, StartFileName, StartLine); + getFunctionNameAndStartLineForAddress(CU, Address.Address, Spec.FNKind, Spec.FLIKind, + FunctionName, StartFileName, StartLine); // If the Specifier says we don't need FileLineInfo, just // return the top-most function at the starting address. if (Spec.FLIKind == FileLineInfoKind::None) { DILineInfo Result; Result.FunctionName = FunctionName; - Result.StartFileName = StartFileName; + Result.StartFileName = StartFileName; Result.StartLine = StartLine; Lines.push_back(std::make_pair(Address.Address, Result)); return Lines; @@ -1284,7 +1284,7 @@ DILineInfoTable DWARFContext::getLineInfoForAddressRange( Result.FunctionName = FunctionName; Result.Line = Row.Line; Result.Column = Row.Column; - Result.StartFileName = StartFileName; + Result.StartFileName = StartFileName; Result.StartLine = StartLine; Lines.push_back(std::make_pair(Row.Address.Address, Result)); } @@ -1327,7 +1327,7 @@ DWARFContext::getInliningInfoForAddress(object::SectionedAddress Address, Frame.FunctionName = Name; if (auto DeclLineResult = FunctionDIE.getDeclLine()) Frame.StartLine = DeclLineResult; - Frame.StartFileName = FunctionDIE.getDeclFile(Spec.FLIKind); + Frame.StartFileName = FunctionDIE.getDeclFile(Spec.FLIKind); if (Spec.FLIKind != FileLineInfoKind::None) { if (i == 0) { // For the topmost frame, initialize the line table of this @@ -1709,17 +1709,17 @@ public: // FIXME: Use the other dwo range section when we emit it. RangesDWOSection.Data = Data; } - } else if (InfoSectionMap *Sections = - StringSwitch<InfoSectionMap *>(Name) - .Case("debug_info", &InfoSections) - .Case("debug_info.dwo", &InfoDWOSections) - .Case("debug_types", &TypesSections) - .Case("debug_types.dwo", &TypesDWOSections) - .Default(nullptr)) { + } else if (InfoSectionMap *Sections = + StringSwitch<InfoSectionMap *>(Name) + .Case("debug_info", &InfoSections) + .Case("debug_info.dwo", &InfoDWOSections) + .Case("debug_types", &TypesSections) + .Case("debug_types.dwo", &TypesDWOSections) + .Default(nullptr)) { // Find debug_info and debug_types data by section rather than name as // there are multiple, comdat grouped, of these sections. - DWARFSectionMap &S = (*Sections)[Section]; - S.Data = Data; + DWARFSectionMap &S = (*Sections)[Section]; + S.Data = Data; } if (RelocatedSection == Obj.section_end()) @@ -1780,7 +1780,7 @@ public: // Symbol to [address, section index] cache mapping. std::map<SymbolRef, SymInfo> AddrCache; - SupportsRelocation Supports; + SupportsRelocation Supports; RelocationResolver Resolver; std::tie(Supports, Resolver) = getRelocationResolver(Obj); for (const RelocationRef &Reloc : Section.relocations()) { @@ -1998,6 +1998,6 @@ uint8_t DWARFContext::getCUAddrSize() { // first compile unit. In practice the address size field is repeated across // various DWARF headers (at least in version 5) to make it easier to dump // them independently, not to enable varying the address size. - auto CUs = compile_units(); + auto CUs = compile_units(); return CUs.empty() ? 0 : (*CUs.begin())->getAddressByteSize(); } diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp index da6f6ad903..fb16d8b35a 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp @@ -53,16 +53,16 @@ uint64_t DWARFDataExtractor::getRelocatedValue(uint32_t Size, uint64_t *Off, ErrorAsOutParameter ErrAsOut(Err); Optional<RelocAddrEntry> E = Obj->find(*Section, *Off); - uint64_t LocData = getUnsigned(Off, Size, Err); + uint64_t LocData = getUnsigned(Off, Size, Err); if (!E || (Err && *Err)) - return LocData; + return LocData; if (SecNdx) *SecNdx = E->SectionIndex; - - uint64_t R = - object::resolveRelocation(E->Resolver, E->Reloc, E->SymbolValue, LocData); + + uint64_t R = + object::resolveRelocation(E->Resolver, E->Reloc, E->SymbolValue, LocData); if (E->Reloc2) - R = object::resolveRelocation(E->Resolver, *E->Reloc2, E->SymbolValue2, R); + R = object::resolveRelocation(E->Resolver, *E->Reloc2, E->SymbolValue2, R); return R; } @@ -106,10 +106,10 @@ DWARFDataExtractor::getEncodedPointer(uint64_t *Offset, uint8_t Encoding, Result = getSigned(Offset, 2); break; case dwarf::DW_EH_PE_sdata4: - Result = SignExtend64<32>(getRelocatedValue(4, Offset)); + Result = SignExtend64<32>(getRelocatedValue(4, Offset)); break; case dwarf::DW_EH_PE_sdata8: - Result = getRelocatedValue(8, Offset); + Result = getRelocatedValue(8, Offset); break; default: return None; diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp index 598e3ecee3..8a7809598d 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp @@ -8,7 +8,7 @@ #include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h" #include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" +#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" @@ -21,11 +21,11 @@ using namespace llvm; void DWARFDebugArangeSet::Descriptor::dump(raw_ostream &OS, uint32_t AddressSize) const { - OS << '['; - DWARFFormValue::dumpAddress(OS, AddressSize, Address); - OS << ", "; - DWARFFormValue::dumpAddress(OS, AddressSize, getEndAddress()); - OS << ')'; + OS << '['; + DWARFFormValue::dumpAddress(OS, AddressSize, Address); + OS << ", "; + DWARFFormValue::dumpAddress(OS, AddressSize, getEndAddress()); + OS << ')'; } void DWARFDebugArangeSet::clear() { @@ -35,8 +35,8 @@ void DWARFDebugArangeSet::clear() { } Error DWARFDebugArangeSet::extract(DWARFDataExtractor data, - uint64_t *offset_ptr, - function_ref<void(Error)> WarningHandler) { + uint64_t *offset_ptr, + function_ref<void(Error)> WarningHandler) { assert(data.isValidOffset(*offset_ptr)); ArangeDescriptors.clear(); Offset = *offset_ptr; @@ -145,11 +145,11 @@ Error DWARFDebugArangeSet::extract(DWARFDataExtractor data, if (arangeDescriptor.Length == 0 && arangeDescriptor.Address == 0) { if (*offset_ptr == end_offset) return ErrorSuccess(); - WarningHandler(createStringError( + WarningHandler(createStringError( errc::invalid_argument, "address range table at offset 0x%" PRIx64 " has a premature terminator entry at offset 0x%" PRIx64, - Offset, EntryOffset)); + Offset, EntryOffset)); } ArangeDescriptors.push_back(arangeDescriptor); diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp index e0db469752..fbbf8af840 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp @@ -28,8 +28,8 @@ void DWARFDebugAranges::extract( DWARFDebugArangeSet Set; while (DebugArangesData.isValidOffset(Offset)) { - if (Error E = - Set.extract(DebugArangesData, &Offset, RecoverableErrorHandler)) { + if (Error E = + Set.extract(DebugArangesData, &Offset, RecoverableErrorHandler)) { RecoverableErrorHandler(std::move(E)); return; } diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp index b74ecac681..788ea89400 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -12,7 +12,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/MC/MCRegisterInfo.h" +#include "llvm/MC/MCRegisterInfo.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/DataExtractor.h" @@ -30,18 +30,18 @@ using namespace llvm; using namespace dwarf; -static void printRegister(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH, - unsigned RegNum) { - if (MRI) { - if (Optional<unsigned> LLVMRegNum = MRI->getLLVMRegNum(RegNum, IsEH)) { - if (const char *RegName = MRI->getName(*LLVMRegNum)) { - OS << RegName; - return; - } - } - } - OS << "reg" << RegNum; -} +static void printRegister(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH, + unsigned RegNum) { + if (MRI) { + if (Optional<unsigned> LLVMRegNum = MRI->getLLVMRegNum(RegNum, IsEH)) { + if (const char *RegName = MRI->getName(*LLVMRegNum)) { + OS << RegName; + return; + } + } + } + OS << "reg" << RegNum; +} // See DWARF standard v3, section 7.23 const uint8_t DWARF_CFI_PRIMARY_OPCODE_MASK = 0xc0; @@ -234,10 +234,10 @@ ArrayRef<CFIProgram::OperandType[2]> CFIProgram::getOperandTypes() { } /// Print \p Opcode's operand number \p OperandIdx which has value \p Operand. -void CFIProgram::printOperand(raw_ostream &OS, DIDumpOptions DumpOpts, - const MCRegisterInfo *MRI, bool IsEH, - const Instruction &Instr, unsigned OperandIdx, - uint64_t Operand) const { +void CFIProgram::printOperand(raw_ostream &OS, DIDumpOptions DumpOpts, + const MCRegisterInfo *MRI, bool IsEH, + const Instruction &Instr, unsigned OperandIdx, + uint64_t Operand) const { assert(OperandIdx < 2); uint8_t Opcode = Instr.Opcode; OperandType Type = getOperandTypes()[Opcode][OperandIdx]; @@ -282,19 +282,19 @@ void CFIProgram::printOperand(raw_ostream &OS, DIDumpOptions DumpOpts, OS << format(" %" PRId64 "*data_alignment_factor" , Operand); break; case OT_Register: - OS << ' '; - printRegister(OS, MRI, IsEH, Operand); + OS << ' '; + printRegister(OS, MRI, IsEH, Operand); break; case OT_Expression: assert(Instr.Expression && "missing DWARFExpression object"); OS << " "; - Instr.Expression->print(OS, DumpOpts, MRI, nullptr, IsEH); + Instr.Expression->print(OS, DumpOpts, MRI, nullptr, IsEH); break; } } -void CFIProgram::dump(raw_ostream &OS, DIDumpOptions DumpOpts, - const MCRegisterInfo *MRI, bool IsEH, +void CFIProgram::dump(raw_ostream &OS, DIDumpOptions DumpOpts, + const MCRegisterInfo *MRI, bool IsEH, unsigned IndentLevel) const { for (const auto &Instr : Instructions) { uint8_t Opcode = Instr.Opcode; @@ -303,7 +303,7 @@ void CFIProgram::dump(raw_ostream &OS, DIDumpOptions DumpOpts, OS.indent(2 * IndentLevel); OS << CallFrameString(Opcode, Arch) << ":"; for (unsigned i = 0; i < Instr.Ops.size(); ++i) - printOperand(OS, DumpOpts, MRI, IsEH, Instr, i, Instr.Ops[i]); + printOperand(OS, DumpOpts, MRI, IsEH, Instr, i, Instr.Ops[i]); OS << '\n'; } } @@ -320,8 +320,8 @@ constexpr uint64_t getCIEId(bool IsDWARF64, bool IsEH) { return DW_CIE_ID; } -void CIE::dump(raw_ostream &OS, DIDumpOptions DumpOpts, - const MCRegisterInfo *MRI, bool IsEH) const { +void CIE::dump(raw_ostream &OS, DIDumpOptions DumpOpts, + const MCRegisterInfo *MRI, bool IsEH) const { // A CIE with a zero length is a terminator entry in the .eh_frame section. if (IsEH && Length == 0) { OS << format("%08" PRIx64, Offset) << " ZERO terminator\n"; @@ -353,12 +353,12 @@ void CIE::dump(raw_ostream &OS, DIDumpOptions DumpOpts, OS << "\n"; } OS << "\n"; - CFIs.dump(OS, DumpOpts, MRI, IsEH); + CFIs.dump(OS, DumpOpts, MRI, IsEH); OS << "\n"; } -void FDE::dump(raw_ostream &OS, DIDumpOptions DumpOpts, - const MCRegisterInfo *MRI, bool IsEH) const { +void FDE::dump(raw_ostream &OS, DIDumpOptions DumpOpts, + const MCRegisterInfo *MRI, bool IsEH) const { OS << format("%08" PRIx64, Offset) << format(" %0*" PRIx64, IsDWARF64 ? 16 : 8, Length) << format(" %0*" PRIx64, IsDWARF64 && !IsEH ? 16 : 8, CIEPointer) @@ -372,7 +372,7 @@ void FDE::dump(raw_ostream &OS, DIDumpOptions DumpOpts, OS << " Format: " << FormatString(IsDWARF64) << "\n"; if (LSDAAddress) OS << format(" LSDA Address: %016" PRIx64 "\n", *LSDAAddress); - CFIs.dump(OS, DumpOpts, MRI, IsEH); + CFIs.dump(OS, DumpOpts, MRI, IsEH); OS << "\n"; } @@ -539,9 +539,9 @@ Error DWARFDebugFrame::parse(DWARFDataExtractor Data) { "parsing FDE data at 0x%" PRIx64 " failed due to missing CIE", StartOffset); - if (auto Val = - Data.getEncodedPointer(&Offset, Cie->getFDEPointerEncoding(), - EHFrameAddress + Offset)) { + if (auto Val = + Data.getEncodedPointer(&Offset, Cie->getFDEPointerEncoding(), + EHFrameAddress + Offset)) { InitialLocation = *Val; } if (auto Val = Data.getEncodedPointer( @@ -601,16 +601,16 @@ FrameEntry *DWARFDebugFrame::getEntryAtOffset(uint64_t Offset) const { return nullptr; } -void DWARFDebugFrame::dump(raw_ostream &OS, DIDumpOptions DumpOpts, - const MCRegisterInfo *MRI, +void DWARFDebugFrame::dump(raw_ostream &OS, DIDumpOptions DumpOpts, + const MCRegisterInfo *MRI, Optional<uint64_t> Offset) const { if (Offset) { if (auto *Entry = getEntryAtOffset(*Offset)) - Entry->dump(OS, DumpOpts, MRI, IsEH); + Entry->dump(OS, DumpOpts, MRI, IsEH); return; } OS << "\n"; for (const auto &Entry : Entries) - Entry->dump(OS, DumpOpts, MRI, IsEH); + Entry->dump(OS, DumpOpts, MRI, IsEH); } diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp index 2b7d0c3363..ce3a49201f 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp @@ -38,8 +38,8 @@ bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint64_t *OffsetPtr, AbbrevDecl = nullptr; return true; } - if (const auto *AbbrevSet = U.getAbbreviations()) - AbbrevDecl = AbbrevSet->getAbbreviationDeclaration(AbbrCode); + if (const auto *AbbrevSet = U.getAbbreviations()) + AbbrevDecl = AbbrevSet->getAbbreviationDeclaration(AbbrCode); if (nullptr == AbbrevDecl) { // Restore the original offset. *OffsetPtr = Offset; diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index bda41b1f34..a0758247a6 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -79,18 +79,18 @@ bool DWARFDebugLine::Prologue::hasFileAtIndex(uint64_t FileIndex) const { return FileIndex != 0 && FileIndex <= FileNames.size(); } -Optional<uint64_t> DWARFDebugLine::Prologue::getLastValidFileIndex() const { - if (FileNames.empty()) - return None; - uint16_t DwarfVersion = getVersion(); - assert(DwarfVersion != 0 && - "line table prologue has no dwarf version information"); - // In DWARF v5 the file names are 0-indexed. - if (DwarfVersion >= 5) - return FileNames.size() - 1; - return FileNames.size(); -} - +Optional<uint64_t> DWARFDebugLine::Prologue::getLastValidFileIndex() const { + if (FileNames.empty()) + return None; + uint16_t DwarfVersion = getVersion(); + assert(DwarfVersion != 0 && + "line table prologue has no dwarf version information"); + // In DWARF v5 the file names are 0-indexed. + if (DwarfVersion >= 5) + return FileNames.size() - 1; + return FileNames.size(); +} + const llvm::DWARFDebugLine::FileNameEntry & DWARFDebugLine::Prologue::getFileNameEntry(uint64_t Index) const { uint16_t DwarfVersion = getVersion(); @@ -783,18 +783,18 @@ Error DWARFDebugLine::LineTable::parse( *OS << '\n'; Row::dumpTableHeader(*OS, /*Indent=*/Verbose ? 12 : 0); } - bool TombstonedAddress = false; - auto EmitRow = [&] { - if (!TombstonedAddress) { - if (Verbose) { - *OS << "\n"; - OS->indent(12); - } - if (OS) - State.Row.dump(*OS); - State.appendRowToMatrix(); - } - }; + bool TombstonedAddress = false; + auto EmitRow = [&] { + if (!TombstonedAddress) { + if (Verbose) { + *OS << "\n"; + OS->indent(12); + } + if (OS) + State.Row.dump(*OS); + State.appendRowToMatrix(); + } + }; while (*OffsetPtr < EndOffset) { DataExtractor::Cursor Cursor(*OffsetPtr); @@ -846,7 +846,7 @@ Error DWARFDebugLine::LineTable::parse( // No need to test the Cursor is valid here, since it must be to get // into this code path - if it were invalid, the default case would be // followed. - EmitRow(); + EmitRow(); State.resetRowAndSequence(); break; @@ -888,20 +888,20 @@ Error DWARFDebugLine::LineTable::parse( State.Row.Address.Address = TableData.getRelocatedAddress( Cursor, &State.Row.Address.SectionIndex); - uint64_t Tombstone = - dwarf::computeTombstoneAddress(OpcodeAddressSize); - TombstonedAddress = State.Row.Address.Address == Tombstone; - + uint64_t Tombstone = + dwarf::computeTombstoneAddress(OpcodeAddressSize); + TombstonedAddress = State.Row.Address.Address == Tombstone; + // Restore the address size if the extractor already had it. if (ExtractorAddressSize != 0) TableData.setAddressSize(ExtractorAddressSize); } - if (Cursor && Verbose) { - *OS << " ("; - DWARFFormValue::dumpAddress(*OS, OpcodeAddressSize, State.Row.Address.Address); - *OS << ')'; - } + if (Cursor && Verbose) { + *OS << " ("; + DWARFFormValue::dumpAddress(*OS, OpcodeAddressSize, State.Row.Address.Address); + *OS << ')'; + } } break; @@ -994,7 +994,7 @@ Error DWARFDebugLine::LineTable::parse( case DW_LNS_copy: // Takes no arguments. Append a row to the matrix using the // current values of the state-machine registers. - EmitRow(); + EmitRow(); break; case DW_LNS_advance_pc: @@ -1159,9 +1159,9 @@ Error DWARFDebugLine::LineTable::parse( ParsingState::AddrAndLineDelta Delta = State.handleSpecialOpcode(Opcode, OpcodeOffset); - if (Verbose) - *OS << "address += " << Delta.Address << ", line += " << Delta.Line; - EmitRow(); + if (Verbose) + *OS << "address += " << Delta.Address << ", line += " << Delta.Line; + EmitRow(); *OffsetPtr = Cursor.tell(); } @@ -1419,20 +1419,20 @@ bool DWARFDebugLine::LineTable::getFileLineInfoForAddress( // Therefore, collect up handles on all the Units that point into the // line-table section. static DWARFDebugLine::SectionParser::LineToUnitMap -buildLineToUnitMap(DWARFUnitVector::iterator_range Units) { +buildLineToUnitMap(DWARFUnitVector::iterator_range Units) { DWARFDebugLine::SectionParser::LineToUnitMap LineToUnit; - for (const auto &U : Units) - if (auto CUDIE = U->getUnitDIE()) + for (const auto &U : Units) + if (auto CUDIE = U->getUnitDIE()) if (auto StmtOffset = toSectionOffset(CUDIE.find(DW_AT_stmt_list))) - LineToUnit.insert(std::make_pair(*StmtOffset, &*U)); + LineToUnit.insert(std::make_pair(*StmtOffset, &*U)); return LineToUnit; } -DWARFDebugLine::SectionParser::SectionParser( - DWARFDataExtractor &Data, const DWARFContext &C, - DWARFUnitVector::iterator_range Units) +DWARFDebugLine::SectionParser::SectionParser( + DWARFDataExtractor &Data, const DWARFContext &C, + DWARFUnitVector::iterator_range Units) : DebugLineData(Data), Context(C) { - LineToUnit = buildLineToUnitMap(Units); + LineToUnit = buildLineToUnitMap(Units); if (!DebugLineData.isValidOffset(Offset)) Done = true; } diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp index cdffb36741..710a0536fa 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp @@ -106,16 +106,16 @@ DWARFLocationInterpreter::Interpret(const DWARFLocationEntry &E) { } } -static void dumpExpression(raw_ostream &OS, DIDumpOptions DumpOpts, - ArrayRef<uint8_t> Data, bool IsLittleEndian, - unsigned AddressSize, const MCRegisterInfo *MRI, - DWARFUnit *U) { +static void dumpExpression(raw_ostream &OS, DIDumpOptions DumpOpts, + ArrayRef<uint8_t> Data, bool IsLittleEndian, + unsigned AddressSize, const MCRegisterInfo *MRI, + DWARFUnit *U) { DWARFDataExtractor Extractor(Data, IsLittleEndian, AddressSize); // Note. We do not pass any format to DWARFExpression, even if the // corresponding unit is known. For now, there is only one operation, // DW_OP_call_ref, which depends on the format; it is rarely used, and // is unexpected in location tables. - DWARFExpression(Extractor, AddressSize).print(OS, DumpOpts, MRI, U); + DWARFExpression(Extractor, AddressSize).print(OS, DumpOpts, MRI, U); } bool DWARFLocationTable::dumpLocationList(uint64_t *Offset, raw_ostream &OS, @@ -155,8 +155,8 @@ bool DWARFLocationTable::dumpLocationList(uint64_t *Offset, raw_ostream &OS, E.Kind != dwarf::DW_LLE_base_addressx && E.Kind != dwarf::DW_LLE_end_of_list) { OS << ": "; - dumpExpression(OS, DumpOpts, E.Loc, Data.isLittleEndian(), - Data.getAddressSize(), MRI, U); + dumpExpression(OS, DumpOpts, E.Loc, Data.isLittleEndian(), + Data.getAddressSize(), MRI, U); } return true; }); diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp index 80ffd81b34..c153186b61 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp @@ -40,7 +40,7 @@ void DWARFDebugMacro::dump(raw_ostream &OS) const { unsigned IndLevel = 0; for (const auto &Macros : MacroLists) { OS << format("0x%08" PRIx64 ":\n", Macros.Offset); - if (Macros.IsDebugMacro) + if (Macros.IsDebugMacro) Macros.Header.dumpMacroHeader(OS); for (const Entry &E : Macros.Macros) { // There should not be DW_MACINFO_end_file when IndLevel is Zero. However, @@ -52,10 +52,10 @@ void DWARFDebugMacro::dump(raw_ostream &OS) const { OS << " "; IndLevel += (E.Type == DW_MACINFO_start_file); // Based on which version we are handling choose appropriate macro forms. - if (Macros.IsDebugMacro) - WithColor(OS, HighlightColor::Macro).get() - << (Macros.Header.Version < 5 ? GnuMacroString(E.Type) - : MacroString(E.Type)); + if (Macros.IsDebugMacro) + WithColor(OS, HighlightColor::Macro).get() + << (Macros.Header.Version < 5 ? GnuMacroString(E.Type) + : MacroString(E.Type)); else WithColor(OS, HighlightColor::Macro).get() << MacinfoString(E.Type); switch (E.Type) { @@ -69,9 +69,9 @@ void DWARFDebugMacro::dump(raw_ostream &OS) const { // DW_MACRO_start_file == DW_MACINFO_start_file // DW_MACRO_end_file == DW_MACINFO_end_file // For readability/uniformity we are using DW_MACRO_*. - // - // The GNU .debug_macro extension's entries have the same encoding - // as DWARF 5's DW_MACRO_* entries, so we only use the latter here. + // + // The GNU .debug_macro extension's entries have the same encoding + // as DWARF 5's DW_MACRO_* entries, so we only use the latter here. case DW_MACRO_define: case DW_MACRO_undef: case DW_MACRO_define_strp: @@ -102,7 +102,7 @@ void DWARFDebugMacro::dump(raw_ostream &OS) const { } Error DWARFDebugMacro::parseImpl( - Optional<DWARFUnitVector::compile_unit_range> Units, + Optional<DWARFUnitVector::compile_unit_range> Units, Optional<DataExtractor> StringExtractor, DWARFDataExtractor Data, bool IsMacro) { uint64_t Offset = 0; @@ -123,7 +123,7 @@ Error DWARFDebugMacro::parseImpl( MacroLists.emplace_back(); M = &MacroLists.back(); M->Offset = Offset; - M->IsDebugMacro = IsMacro; + M->IsDebugMacro = IsMacro; if (IsMacro) { auto Err = M->Header.parseMacroHeader(Data, &Offset); if (Err) diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp index dc7da5d934..38bc79c3ed 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp @@ -70,9 +70,9 @@ void DWARFDebugRangeList::dump(raw_ostream &OS) const { DWARFAddressRangesVector DWARFDebugRangeList::getAbsoluteRanges( llvm::Optional<object::SectionedAddress> BaseAddr) const { DWARFAddressRangesVector Res; - // debug_addr can't use the max integer tombstone because that's used for the - // base address specifier entry - so use max-1. - uint64_t Tombstone = dwarf::computeTombstoneAddress(AddressSize) - 1; + // debug_addr can't use the max integer tombstone because that's used for the + // base address specifier entry - so use max-1. + uint64_t Tombstone = dwarf::computeTombstoneAddress(AddressSize) - 1; for (const RangeListEntry &RLE : Entries) { if (RLE.isBaseAddressSelectionEntry(AddressSize)) { BaseAddr = {RLE.EndAddress, RLE.SectionIndex}; @@ -81,16 +81,16 @@ DWARFAddressRangesVector DWARFDebugRangeList::getAbsoluteRanges( DWARFAddressRange E; E.LowPC = RLE.StartAddress; - if (E.LowPC == Tombstone) - continue; + if (E.LowPC == Tombstone) + continue; E.HighPC = RLE.EndAddress; E.SectionIndex = RLE.SectionIndex; // Base address of a range list entry is determined by the closest preceding // base address selection entry in the same range list. It defaults to the // base address of the compilation unit if there is no such entry. if (BaseAddr) { - if (BaseAddr->Address == Tombstone) - continue; + if (BaseAddr->Address == Tombstone) + continue; E.LowPC += BaseAddr->Address; E.HighPC += BaseAddr->Address; if (E.SectionIndex == -1ULL) diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp index d12acca196..bca8512467 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp @@ -8,7 +8,7 @@ #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h" #include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" +#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" #include "llvm/DebugInfo/DWARF/DWARFUnit.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Error.h" @@ -17,87 +17,87 @@ using namespace llvm; -Error RangeListEntry::extract(DWARFDataExtractor Data, uint64_t *OffsetPtr) { +Error RangeListEntry::extract(DWARFDataExtractor Data, uint64_t *OffsetPtr) { Offset = *OffsetPtr; SectionIndex = -1ULL; // The caller should guarantee that we have at least 1 byte available, so // we just assert instead of revalidate. - assert(*OffsetPtr < Data.size() && + assert(*OffsetPtr < Data.size() && "not enough space to extract a rangelist encoding"); uint8_t Encoding = Data.getU8(OffsetPtr); - DataExtractor::Cursor C(*OffsetPtr); + DataExtractor::Cursor C(*OffsetPtr); switch (Encoding) { case dwarf::DW_RLE_end_of_list: Value0 = Value1 = 0; break; // TODO: Support other encodings. case dwarf::DW_RLE_base_addressx: { - Value0 = Data.getULEB128(C); + Value0 = Data.getULEB128(C); break; } case dwarf::DW_RLE_startx_endx: - Value0 = Data.getULEB128(C); - Value1 = Data.getULEB128(C); - break; + Value0 = Data.getULEB128(C); + Value1 = Data.getULEB128(C); + break; case dwarf::DW_RLE_startx_length: { - Value0 = Data.getULEB128(C); - Value1 = Data.getULEB128(C); + Value0 = Data.getULEB128(C); + Value1 = Data.getULEB128(C); break; } case dwarf::DW_RLE_offset_pair: { - Value0 = Data.getULEB128(C); - Value1 = Data.getULEB128(C); + Value0 = Data.getULEB128(C); + Value1 = Data.getULEB128(C); break; } case dwarf::DW_RLE_base_address: { - Value0 = Data.getRelocatedAddress(C, &SectionIndex); + Value0 = Data.getRelocatedAddress(C, &SectionIndex); break; } case dwarf::DW_RLE_start_end: { - Value0 = Data.getRelocatedAddress(C, &SectionIndex); - Value1 = Data.getRelocatedAddress(C); + Value0 = Data.getRelocatedAddress(C, &SectionIndex); + Value1 = Data.getRelocatedAddress(C); break; } case dwarf::DW_RLE_start_length: { - Value0 = Data.getRelocatedAddress(C, &SectionIndex); - Value1 = Data.getULEB128(C); + Value0 = Data.getRelocatedAddress(C, &SectionIndex); + Value1 = Data.getULEB128(C); break; } default: - consumeError(C.takeError()); + consumeError(C.takeError()); return createStringError(errc::not_supported, - "unknown rnglists encoding 0x%" PRIx32 - " at offset 0x%" PRIx64, - uint32_t(Encoding), Offset); - } - - if (!C) { - consumeError(C.takeError()); - return createStringError( - errc::invalid_argument, - "read past end of table when reading %s encoding at offset 0x%" PRIx64, - dwarf::RLEString(Encoding).data(), Offset); + "unknown rnglists encoding 0x%" PRIx32 + " at offset 0x%" PRIx64, + uint32_t(Encoding), Offset); } - *OffsetPtr = C.tell(); + if (!C) { + consumeError(C.takeError()); + return createStringError( + errc::invalid_argument, + "read past end of table when reading %s encoding at offset 0x%" PRIx64, + dwarf::RLEString(Encoding).data(), Offset); + } + + *OffsetPtr = C.tell(); EntryKind = Encoding; return Error::success(); } DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges( llvm::Optional<object::SectionedAddress> BaseAddr, DWARFUnit &U) const { - return getAbsoluteRanges( - BaseAddr, U.getAddressByteSize(), - [&](uint32_t Index) { return U.getAddrOffsetSectionItem(Index); }); + return getAbsoluteRanges( + BaseAddr, U.getAddressByteSize(), + [&](uint32_t Index) { return U.getAddrOffsetSectionItem(Index); }); } DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges( - Optional<object::SectionedAddress> BaseAddr, uint8_t AddressByteSize, + Optional<object::SectionedAddress> BaseAddr, uint8_t AddressByteSize, function_ref<Optional<object::SectionedAddress>(uint32_t)> LookupPooledAddress) const { DWARFAddressRangesVector Res; - uint64_t Tombstone = dwarf::computeTombstoneAddress(AddressByteSize); + uint64_t Tombstone = dwarf::computeTombstoneAddress(AddressByteSize); for (const RangeListEntry &RLE : Entries) { if (RLE.EntryKind == dwarf::DW_RLE_end_of_list) break; @@ -120,12 +120,12 @@ DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges( switch (RLE.EntryKind) { case dwarf::DW_RLE_offset_pair: E.LowPC = RLE.Value0; - if (E.LowPC == Tombstone) - continue; + if (E.LowPC == Tombstone) + continue; E.HighPC = RLE.Value1; if (BaseAddr) { - if (BaseAddr->Address == Tombstone) - continue; + if (BaseAddr->Address == Tombstone) + continue; E.LowPC += BaseAddr->Address; E.HighPC += BaseAddr->Address; } @@ -147,26 +147,26 @@ DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges( E.HighPC = E.LowPC + RLE.Value1; break; } - case dwarf::DW_RLE_startx_endx: { - auto Start = LookupPooledAddress(RLE.Value0); - if (!Start) - Start = {0, -1ULL}; - auto End = LookupPooledAddress(RLE.Value1); - if (!End) - End = {0, -1ULL}; - // FIXME: Some error handling if Start.SectionIndex != End.SectionIndex - E.SectionIndex = Start->SectionIndex; - E.LowPC = Start->Address; - E.HighPC = End->Address; - break; - } + case dwarf::DW_RLE_startx_endx: { + auto Start = LookupPooledAddress(RLE.Value0); + if (!Start) + Start = {0, -1ULL}; + auto End = LookupPooledAddress(RLE.Value1); + if (!End) + End = {0, -1ULL}; + // FIXME: Some error handling if Start.SectionIndex != End.SectionIndex + E.SectionIndex = Start->SectionIndex; + E.LowPC = Start->Address; + E.HighPC = End->Address; + break; + } default: // Unsupported encodings should have been reported during extraction, // so we should not run into any here. llvm_unreachable("Unsupported range list encoding"); } - if (E.LowPC == Tombstone) - continue; + if (E.LowPC == Tombstone) + continue; Res.push_back(E); } return Res; @@ -199,8 +199,8 @@ void RangeListEntry::dump( OS << ": "; } - uint64_t Tombstone = dwarf::computeTombstoneAddress(AddrSize); - + uint64_t Tombstone = dwarf::computeTombstoneAddress(AddrSize); + switch (EntryKind) { case dwarf::DW_RLE_end_of_list: OS << (DumpOpts.Verbose ? "" : "<End of list>"); @@ -212,7 +212,7 @@ void RangeListEntry::dump( CurrentBase = Value0; if (!DumpOpts.Verbose) return; - DWARFFormValue::dumpAddress(OS << ' ', AddrSize, Value0); + DWARFFormValue::dumpAddress(OS << ' ', AddrSize, Value0); break; } case dwarf::DW_RLE_base_address: @@ -220,7 +220,7 @@ void RangeListEntry::dump( CurrentBase = Value0; if (!DumpOpts.Verbose) return; - DWARFFormValue::dumpAddress(OS << ' ', AddrSize, Value0); + DWARFFormValue::dumpAddress(OS << ' ', AddrSize, Value0); break; case dwarf::DW_RLE_start_length: PrintRawEntry(OS, *this, AddrSize, DumpOpts); @@ -228,11 +228,11 @@ void RangeListEntry::dump( break; case dwarf::DW_RLE_offset_pair: PrintRawEntry(OS, *this, AddrSize, DumpOpts); - if (CurrentBase != Tombstone) - DWARFAddressRange(Value0 + CurrentBase, Value1 + CurrentBase) - .dump(OS, AddrSize, DumpOpts); - else - OS << "dead code"; + if (CurrentBase != Tombstone) + DWARFAddressRange(Value0 + CurrentBase, Value1 + CurrentBase) + .dump(OS, AddrSize, DumpOpts); + else + OS << "dead code"; break; case dwarf::DW_RLE_start_end: DWARFAddressRange(Value0, Value1).dump(OS, AddrSize, DumpOpts); @@ -245,17 +245,17 @@ void RangeListEntry::dump( DWARFAddressRange(Start, Start + Value1).dump(OS, AddrSize, DumpOpts); break; } - case dwarf::DW_RLE_startx_endx: { - PrintRawEntry(OS, *this, AddrSize, DumpOpts); - uint64_t Start = 0; - if (auto SA = LookupPooledAddress(Value0)) - Start = SA->Address; - uint64_t End = 0; - if (auto SA = LookupPooledAddress(Value1)) - End = SA->Address; - DWARFAddressRange(Start, End).dump(OS, AddrSize, DumpOpts); - break; - } + case dwarf::DW_RLE_startx_endx: { + PrintRawEntry(OS, *this, AddrSize, DumpOpts); + uint64_t Start = 0; + if (auto SA = LookupPooledAddress(Value0)) + Start = SA->Address; + uint64_t End = 0; + if (auto SA = LookupPooledAddress(Value1)) + End = SA->Address; + DWARFAddressRange(Start, End).dump(OS, AddrSize, DumpOpts); + break; + } default: llvm_unreachable("Unsupported range list encoding"); } diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDie.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDie.cpp index 5a55f3a041..ad67e8af85 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -69,7 +69,7 @@ static void dumpRanges(const DWARFObject &Obj, raw_ostream &OS, } } -static void dumpLocation(raw_ostream &OS, const DWARFFormValue &FormValue, +static void dumpLocation(raw_ostream &OS, const DWARFFormValue &FormValue, DWARFUnit *U, unsigned Indent, DIDumpOptions DumpOpts) { DWARFContext &Ctx = U->getContext(); @@ -80,7 +80,7 @@ static void dumpLocation(raw_ostream &OS, const DWARFFormValue &FormValue, DataExtractor Data(StringRef((const char *)Expr.data(), Expr.size()), Ctx.isLittleEndian(), 0); DWARFExpression(Data, U->getAddressByteSize(), U->getFormParams().Format) - .print(OS, DumpOpts, MRI, U); + .print(OS, DumpOpts, MRI, U); return; } @@ -230,22 +230,22 @@ static void dumpTypeName(raw_ostream &OS, const DWARFDie &D) { } static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die, - const DWARFAttribute &AttrValue, unsigned Indent, + const DWARFAttribute &AttrValue, unsigned Indent, DIDumpOptions DumpOpts) { if (!Die.isValid()) return; const char BaseIndent[] = " "; OS << BaseIndent; OS.indent(Indent + 2); - dwarf::Attribute Attr = AttrValue.Attr; + dwarf::Attribute Attr = AttrValue.Attr; WithColor(OS, HighlightColor::Attribute) << formatv("{0}", Attr); - dwarf::Form Form = AttrValue.Value.getForm(); + dwarf::Form Form = AttrValue.Value.getForm(); if (DumpOpts.Verbose || DumpOpts.ShowForm) OS << formatv(" [{0}]", Form); DWARFUnit *U = Die.getDwarfUnit(); - const DWARFFormValue &FormValue = AttrValue.Value; + const DWARFFormValue &FormValue = AttrValue.Value; OS << "\t("; @@ -269,23 +269,23 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die, WithColor(OS, Color) << Name; else if (Attr == DW_AT_decl_line || Attr == DW_AT_call_line) OS << *FormValue.getAsUnsignedConstant(); - else if (Attr == DW_AT_low_pc && - (FormValue.getAsAddress() == - dwarf::computeTombstoneAddress(U->getAddressByteSize()))) { - if (DumpOpts.Verbose) { - FormValue.dump(OS, DumpOpts); - OS << " ("; - } - OS << "dead code"; - if (DumpOpts.Verbose) - OS << ')'; - } else if (Attr == DW_AT_high_pc && !DumpOpts.ShowForm && !DumpOpts.Verbose && - FormValue.getAsUnsignedConstant()) { + else if (Attr == DW_AT_low_pc && + (FormValue.getAsAddress() == + dwarf::computeTombstoneAddress(U->getAddressByteSize()))) { + if (DumpOpts.Verbose) { + FormValue.dump(OS, DumpOpts); + OS << " ("; + } + OS << "dead code"; + if (DumpOpts.Verbose) + OS << ')'; + } else if (Attr == DW_AT_high_pc && !DumpOpts.ShowForm && !DumpOpts.Verbose && + FormValue.getAsUnsignedConstant()) { if (DumpOpts.ShowAddresses) { // Print the actual address rather than the offset. uint64_t LowPC, HighPC, Index; if (Die.getLowAndHighPC(LowPC, HighPC, Index)) - DWARFFormValue::dumpAddress(OS, U->getAddressByteSize(), HighPC); + DWARFFormValue::dumpAddress(OS, U->getAddressByteSize(), HighPC); else FormValue.dump(OS, DumpOpts); } @@ -378,7 +378,7 @@ DWARFDie::findRecursively(ArrayRef<dwarf::Attribute> Attrs) const { Seen.insert(*this); while (!Worklist.empty()) { - DWARFDie Die = Worklist.pop_back_val(); + DWARFDie Die = Worklist.pop_back_val(); if (!Die.isValid()) continue; @@ -425,9 +425,9 @@ Optional<uint64_t> DWARFDie::getLocBaseAttribute() const { } Optional<uint64_t> DWARFDie::getHighPC(uint64_t LowPC) const { - uint64_t Tombstone = dwarf::computeTombstoneAddress(U->getAddressByteSize()); - if (LowPC == Tombstone) - return None; + uint64_t Tombstone = dwarf::computeTombstoneAddress(U->getAddressByteSize()); + if (LowPC == Tombstone) + return None; if (auto FormValue = find(DW_AT_high_pc)) { if (auto Address = FormValue->getAsAddress()) { // High PC is an address. @@ -479,7 +479,7 @@ void DWARFDie::collectChildrenAddressRanges( return; if (isSubprogramDIE()) { if (auto DIERangesOrError = getAddressRanges()) - llvm::append_range(Ranges, DIERangesOrError.get()); + llvm::append_range(Ranges, DIERangesOrError.get()); else llvm::consumeError(DIERangesOrError.takeError()); } @@ -569,17 +569,17 @@ uint64_t DWARFDie::getDeclLine() const { return toUnsigned(findRecursively(DW_AT_decl_line), 0); } -std::string -DWARFDie::getDeclFile(DILineInfoSpecifier::FileLineInfoKind Kind) const { - std::string FileName; - if (auto DeclFile = toUnsigned(findRecursively(DW_AT_decl_file))) { - if (const auto *LT = U->getContext().getLineTableForUnit(U)) { - LT->getFileNameByIndex(*DeclFile, U->getCompilationDir(), Kind, FileName); - } - } - return FileName; -} - +std::string +DWARFDie::getDeclFile(DILineInfoSpecifier::FileLineInfoKind Kind) const { + std::string FileName; + if (auto DeclFile = toUnsigned(findRecursively(DW_AT_decl_file))) { + if (const auto *LT = U->getContext().getLineTableForUnit(U)) { + LT->getFileNameByIndex(*DeclFile, U->getCompilationDir(), Kind, FileName); + } + } + return FileName; +} + void DWARFDie::getCallerFrame(uint32_t &CallFile, uint32_t &CallLine, uint32_t &CallColumn, uint32_t &CallDiscriminator) const { @@ -632,8 +632,8 @@ void DWARFDie::dump(raw_ostream &OS, unsigned Indent, OS << '\n'; // Dump all data in the DIE for the attributes. - for (const DWARFAttribute &AttrValue : attributes()) - dumpAttribute(OS, *this, AttrValue, Indent, DumpOpts); + for (const DWARFAttribute &AttrValue : attributes()) + dumpAttribute(OS, *this, AttrValue, Indent, DumpOpts); DWARFDie child = getFirstChild(); if (DumpOpts.ShowChildren && DumpOpts.ChildRecurseDepth > 0 && child) { @@ -716,16 +716,16 @@ void DWARFDie::attribute_iterator::updateForIndex( // Add the previous byte size of any previous attribute value. AttrValue.Offset += AttrValue.ByteSize; uint64_t ParseOffset = AttrValue.Offset; - if (AbbrDecl.getAttrIsImplicitConstByIndex(Index)) - AttrValue.Value = DWARFFormValue::createFromSValue( - AbbrDecl.getFormByIndex(Index), - AbbrDecl.getAttrImplicitConstValueByIndex(Index)); - else { - auto U = Die.getDwarfUnit(); - assert(U && "Die must have valid DWARF unit"); - AttrValue.Value = DWARFFormValue::createFromUnit( - AbbrDecl.getFormByIndex(Index), U, &ParseOffset); - } + if (AbbrDecl.getAttrIsImplicitConstByIndex(Index)) + AttrValue.Value = DWARFFormValue::createFromSValue( + AbbrDecl.getFormByIndex(Index), + AbbrDecl.getAttrImplicitConstValueByIndex(Index)); + else { + auto U = Die.getDwarfUnit(); + assert(U && "Die must have valid DWARF unit"); + AttrValue.Value = DWARFFormValue::createFromUnit( + AbbrDecl.getFormByIndex(Index), U, &ParseOffset); + } AttrValue.ByteSize = ParseOffset - AttrValue.Offset; } else { assert(Index == NumAttrs && "Indexes should be [0, NumAttrs) only"); diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFExpression.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFExpression.cpp index 811716111b..aeb9063d7a 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFExpression.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFExpression.cpp @@ -204,15 +204,15 @@ bool DWARFExpression::Operation::extract(DataExtractor Data, } static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS, - DIDumpOptions DumpOpts, uint64_t Operands[2], - unsigned Operand) { + DIDumpOptions DumpOpts, uint64_t Operands[2], + unsigned Operand) { assert(Operand < 2 && "operand out of bounds"); auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]); if (Die && Die.getTag() == dwarf::DW_TAG_base_type) { - OS << " ("; - if (DumpOpts.Verbose) - OS << format("0x%08" PRIx64 " -> ", Operands[Operand]); - OS << format("0x%08" PRIx64 ")", U->getOffset() + Operands[Operand]); + OS << " ("; + if (DumpOpts.Verbose) + OS << format("0x%08" PRIx64 " -> ", Operands[Operand]); + OS << format("0x%08" PRIx64 ")", U->getOffset() + Operands[Operand]); if (auto Name = Die.find(dwarf::DW_AT_name)) OS << " \"" << Name->getAsCString() << "\""; } else { @@ -221,8 +221,8 @@ static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS, } } -static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS, - DIDumpOptions DumpOpts, uint8_t Opcode, +static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS, + DIDumpOptions DumpOpts, uint8_t Opcode, uint64_t Operands[2], const MCRegisterInfo *MRI, bool isEH) { if (!MRI) @@ -248,7 +248,7 @@ static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS, OS << ' ' << RegName; if (Opcode == DW_OP_regval_type) - prettyPrintBaseTypeRef(U, OS, DumpOpts, Operands, 1); + prettyPrintBaseTypeRef(U, OS, DumpOpts, Operands, 1); return true; } } @@ -256,10 +256,10 @@ static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS, return false; } -bool DWARFExpression::Operation::print(raw_ostream &OS, DIDumpOptions DumpOpts, +bool DWARFExpression::Operation::print(raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, const MCRegisterInfo *RegInfo, - DWARFUnit *U, bool isEH) { + DWARFUnit *U, bool isEH) { if (Error) { OS << "<decoding error>"; return false; @@ -273,7 +273,7 @@ bool DWARFExpression::Operation::print(raw_ostream &OS, DIDumpOptions DumpOpts, (Opcode >= DW_OP_reg0 && Opcode <= DW_OP_reg31) || Opcode == DW_OP_bregx || Opcode == DW_OP_regx || Opcode == DW_OP_regval_type) - if (prettyPrintRegisterOp(U, OS, DumpOpts, Opcode, Operands, RegInfo, isEH)) + if (prettyPrintRegisterOp(U, OS, DumpOpts, Opcode, Operands, RegInfo, isEH)) return true; for (unsigned Operand = 0; Operand < 2; ++Operand) { @@ -290,7 +290,7 @@ bool DWARFExpression::Operation::print(raw_ostream &OS, DIDumpOptions DumpOpts, if (Opcode == DW_OP_convert && Operands[Operand] == 0) OS << " 0x0"; else - prettyPrintBaseTypeRef(U, OS, DumpOpts, Operands, Operand); + prettyPrintBaseTypeRef(U, OS, DumpOpts, Operands, Operand); } else if (Size == Operation::WasmLocationArg) { assert(Operand == 1); switch (Operands[0]) { @@ -315,12 +315,12 @@ bool DWARFExpression::Operation::print(raw_ostream &OS, DIDumpOptions DumpOpts, return true; } -void DWARFExpression::print(raw_ostream &OS, DIDumpOptions DumpOpts, - const MCRegisterInfo *RegInfo, DWARFUnit *U, - bool IsEH) const { +void DWARFExpression::print(raw_ostream &OS, DIDumpOptions DumpOpts, + const MCRegisterInfo *RegInfo, DWARFUnit *U, + bool IsEH) const { uint32_t EntryValExprSize = 0; for (auto &Op : *this) { - if (!Op.print(OS, DumpOpts, this, RegInfo, U, IsEH)) { + if (!Op.print(OS, DumpOpts, this, RegInfo, U, IsEH)) { uint64_t FailOffset = Op.getEndOffset(); while (FailOffset < Data.getData().size()) OS << format(" %02x", Data.getU8(&FailOffset)); diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFFormValue.cpp index 2559765876..4e1f7b1d48 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFFormValue.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFFormValue.cpp @@ -168,7 +168,7 @@ bool DWARFFormValue::skipValue(dwarf::Form Form, DataExtractor DebugInfoData, case DW_FORM_line_strp: case DW_FORM_GNU_ref_alt: case DW_FORM_GNU_strp_alt: - case DW_FORM_implicit_const: + case DW_FORM_implicit_const: if (Optional<uint8_t> FixedSize = dwarf::getFixedFormByteSize(Form, Params)) { *OffsetPtr += *FixedSize; @@ -346,9 +346,9 @@ bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data, case DW_FORM_ref_sig8: Value.uval = Data.getU64(OffsetPtr, &Err); break; - case DW_FORM_implicit_const: - // Value has been already set by DWARFFormValue::createFromSValue. - break; + case DW_FORM_implicit_const: + // Value has been already set by DWARFFormValue::createFromSValue. + break; default: // DWARFFormValue::skipValue() will have caught this and caused all // DWARF DIEs to fail to be parsed, so this code is not be reachable. @@ -362,16 +362,16 @@ bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data, return !errorToBool(std::move(Err)); } -void DWARFFormValue::dumpAddress(raw_ostream &OS, uint8_t AddressSize, - uint64_t Address) { - uint8_t HexDigits = AddressSize * 2; - OS << format("0x%*.*" PRIx64, HexDigits, HexDigits, Address); -} - +void DWARFFormValue::dumpAddress(raw_ostream &OS, uint8_t AddressSize, + uint64_t Address) { + uint8_t HexDigits = AddressSize * 2; + OS << format("0x%*.*" PRIx64, HexDigits, HexDigits, Address); +} + void DWARFFormValue::dumpSectionedAddress(raw_ostream &OS, DIDumpOptions DumpOpts, object::SectionedAddress SA) const { - dumpAddress(OS, U->getAddressByteSize(), SA.Address); + dumpAddress(OS, U->getAddressByteSize(), SA.Address); dumpAddressSection(U->getContext().getDWARFObj(), OS, DumpOpts, SA.SectionIndex); } @@ -486,7 +486,7 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const { break; case DW_FORM_sdata: - case DW_FORM_implicit_const: + case DW_FORM_implicit_const: OS << Value.sval; break; case DW_FORM_udata: diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp index ace7000f07..caee9f333d 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp @@ -71,8 +71,8 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const { StringRef Name = ConstantPoolStrings.substr( ConstantPoolOffset - StringPoolOffset + E.NameOffset); - auto CuVector = llvm::find_if( - ConstantPoolVectors, + auto CuVector = llvm::find_if( + ConstantPoolVectors, [&](const std::pair<uint32_t, SmallVector<uint32_t, 0>> &V) { return V.first == E.VecOffset; }); diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFListTable.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFListTable.cpp index c876af1e9b..9d9b85b472 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFListTable.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFListTable.cpp @@ -71,12 +71,12 @@ Error DWARFListTableHeader::extract(DWARFDataExtractor Data, ") than there is space for", SectionName.data(), HeaderOffset, HeaderData.OffsetEntryCount); Data.setAddressSize(HeaderData.AddrSize); - *OffsetPtr += HeaderData.OffsetEntryCount * OffsetByteSize; + *OffsetPtr += HeaderData.OffsetEntryCount * OffsetByteSize; return Error::success(); } -void DWARFListTableHeader::dump(DataExtractor Data, raw_ostream &OS, - DIDumpOptions DumpOpts) const { +void DWARFListTableHeader::dump(DataExtractor Data, raw_ostream &OS, + DIDumpOptions DumpOpts) const { if (DumpOpts.Verbose) OS << format("0x%8.8" PRIx64 ": ", HeaderOffset); int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(Format); @@ -91,8 +91,8 @@ void DWARFListTableHeader::dump(DataExtractor Data, raw_ostream &OS, if (HeaderData.OffsetEntryCount > 0) { OS << "offsets: ["; - for (uint32_t I = 0; I < HeaderData.OffsetEntryCount; ++I) { - auto Off = *getOffsetEntry(Data, I); + for (uint32_t I = 0; I < HeaderData.OffsetEntryCount; ++I) { + auto Off = *getOffsetEntry(Data, I); OS << format("\n0x%0*" PRIx64, OffsetDumpWidth, Off); if (DumpOpts.Verbose) OS << format(" => 0x%08" PRIx64, diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp index a301b65dd4..527e3cbcaf 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp @@ -36,10 +36,10 @@ void DWARFTypeUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) { << ", version = " << format("0x%04x", getVersion()); if (getVersion() >= 5) OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType()); - OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset()); - if (!getAbbreviations()) - OS << " (invalid)"; - OS << ", addr_size = " << format("0x%02x", getAddressByteSize()) + OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset()); + if (!getAbbreviations()) + OS << " (invalid)"; + OS << ", addr_size = " << format("0x%02x", getAddressByteSize()) << ", name = '" << Name << "'" << ", type_signature = " << format("0x%016" PRIx64, getTypeHash()) << ", type_offset = " << format("0x%04" PRIx64, getTypeOffset()) diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFUnit.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFUnit.cpp index 8493950a29..3688321ad6 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -198,8 +198,8 @@ DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const { // probably shouldn't be valid, but if a use case is found, here's where to // support it (probably have to linearly search for the matching skeleton CU // here) - if (hasSingleElement(R)) - return (*R.begin())->getAddrOffsetSectionItem(Index); + if (hasSingleElement(R)) + return (*R.begin())->getAddrOffsetSectionItem(Index); } if (!AddrOffsetSectionBase) return None; @@ -467,7 +467,7 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) { if (getVersion() >= 5) { // In case of DWP, the base offset from the index has to be added. if (IsDWO) { - uint64_t ContributionBaseOffset = 0; + uint64_t ContributionBaseOffset = 0; if (auto *IndexEntry = Header.getIndexEntry()) if (auto *Contrib = IndexEntry->getContribution(DW_SECT_RNGLISTS)) ContributionBaseOffset = Contrib->Offset; @@ -477,36 +477,36 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) { DWARFListTableHeader::getHeaderSize(Header.getFormat())); } else setRangesSection(&Context.getDWARFObj().getRnglistsSection(), - toSectionOffset(UnitDie.find(DW_AT_rnglists_base), - DWARFListTableHeader::getHeaderSize( - Header.getFormat()))); - } - - if (IsDWO) { - // If we are reading a package file, we need to adjust the location list - // data based on the index entries. - StringRef Data = Header.getVersion() >= 5 - ? Context.getDWARFObj().getLoclistsDWOSection().Data - : Context.getDWARFObj().getLocDWOSection().Data; - if (auto *IndexEntry = Header.getIndexEntry()) - if (const auto *C = IndexEntry->getContribution( - Header.getVersion() >= 5 ? DW_SECT_LOCLISTS : DW_SECT_EXT_LOC)) - Data = Data.substr(C->Offset, C->Length); - - DWARFDataExtractor DWARFData(Data, isLittleEndian, getAddressByteSize()); - LocTable = - std::make_unique<DWARFDebugLoclists>(DWARFData, Header.getVersion()); - LocSectionBase = DWARFListTableHeader::getHeaderSize(Header.getFormat()); - } else if (getVersion() >= 5) { - LocTable = std::make_unique<DWARFDebugLoclists>( - DWARFDataExtractor(Context.getDWARFObj(), - Context.getDWARFObj().getLoclistsSection(), - isLittleEndian, getAddressByteSize()), - getVersion()); - } else { - LocTable = std::make_unique<DWARFDebugLoc>(DWARFDataExtractor( - Context.getDWARFObj(), Context.getDWARFObj().getLocSection(), - isLittleEndian, getAddressByteSize())); + toSectionOffset(UnitDie.find(DW_AT_rnglists_base), + DWARFListTableHeader::getHeaderSize( + Header.getFormat()))); + } + + if (IsDWO) { + // If we are reading a package file, we need to adjust the location list + // data based on the index entries. + StringRef Data = Header.getVersion() >= 5 + ? Context.getDWARFObj().getLoclistsDWOSection().Data + : Context.getDWARFObj().getLocDWOSection().Data; + if (auto *IndexEntry = Header.getIndexEntry()) + if (const auto *C = IndexEntry->getContribution( + Header.getVersion() >= 5 ? DW_SECT_LOCLISTS : DW_SECT_EXT_LOC)) + Data = Data.substr(C->Offset, C->Length); + + DWARFDataExtractor DWARFData(Data, isLittleEndian, getAddressByteSize()); + LocTable = + std::make_unique<DWARFDebugLoclists>(DWARFData, Header.getVersion()); + LocSectionBase = DWARFListTableHeader::getHeaderSize(Header.getFormat()); + } else if (getVersion() >= 5) { + LocTable = std::make_unique<DWARFDebugLoclists>( + DWARFDataExtractor(Context.getDWARFObj(), + Context.getDWARFObj().getLoclistsSection(), + isLittleEndian, getAddressByteSize()), + getVersion()); + } else { + LocTable = std::make_unique<DWARFDebugLoc>(DWARFDataExtractor( + Context.getDWARFObj(), Context.getDWARFObj().getLocSection(), + isLittleEndian, getAddressByteSize())); } // Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for @@ -549,8 +549,8 @@ bool DWARFUnit::parseDWO() { if (AddrOffsetSectionBase) DWO->setAddrOffsetSection(AddrOffsetSection, *AddrOffsetSectionBase); if (getVersion() >= 5) { - DWO->setRangesSection(&Context.getDWARFObj().getRnglistsDWOSection(), - DWARFListTableHeader::getHeaderSize(getFormat())); + DWO->setRangesSection(&Context.getDWARFObj().getRnglistsDWOSection(), + DWARFListTableHeader::getHeaderSize(getFormat())); } else { auto DWORangesBase = UnitDie.getRangesBaseAttribute(); DWO->setRangesSection(RangeSection, DWORangesBase ? *DWORangesBase : 0); @@ -574,13 +574,13 @@ DWARFUnit::findRnglistFromOffset(uint64_t Offset) { return std::move(E); return RangeList.getAbsoluteRanges(getBaseAddress()); } - DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection, - isLittleEndian, Header.getAddressByteSize()); - DWARFDebugRnglistTable RnglistTable; - auto RangeListOrError = RnglistTable.findList(RangesData, Offset); - if (RangeListOrError) - return RangeListOrError.get().getAbsoluteRanges(getBaseAddress(), *this); - return RangeListOrError.takeError(); + DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection, + isLittleEndian, Header.getAddressByteSize()); + DWARFDebugRnglistTable RnglistTable; + auto RangeListOrError = RnglistTable.findList(RangesData, Offset); + if (RangeListOrError) + return RangeListOrError.get().getAbsoluteRanges(getBaseAddress(), *this); + return RangeListOrError.takeError(); } Expected<DWARFAddressRangesVector> @@ -589,9 +589,9 @@ DWARFUnit::findRnglistFromIndex(uint32_t Index) { return findRnglistFromOffset(*Offset); return createStringError(errc::invalid_argument, - "invalid range list table index %d (possibly " - "missing the entire range list table)", - Index); + "invalid range list table index %d (possibly " + "missing the entire range list table)", + Index); } Expected<DWARFAddressRangesVector> DWARFUnit::collectAddressRanges() { @@ -921,35 +921,35 @@ DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor & DA) { // Prior to DWARF v5, we derive the contribution size from the // index table (in a package file). In a .dwo file it is simply // the length of the string offsets section. - StrOffsetsContributionDescriptor Desc; + StrOffsetsContributionDescriptor Desc; if (C) - Desc = StrOffsetsContributionDescriptor(C->Offset, C->Length, 4, - Header.getFormat()); - else if (!IndexEntry && !StringOffsetSection.Data.empty()) - Desc = StrOffsetsContributionDescriptor(0, StringOffsetSection.Data.size(), - 4, Header.getFormat()); - else - return None; - auto DescOrError = Desc.validateContributionSize(DA); - if (!DescOrError) - return DescOrError.takeError(); - return *DescOrError; -} - -Optional<uint64_t> DWARFUnit::getRnglistOffset(uint32_t Index) { - DataExtractor RangesData(RangeSection->Data, isLittleEndian, - getAddressByteSize()); - DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection, - isLittleEndian, 0); - if (Optional<uint64_t> Off = llvm::DWARFListTableHeader::getOffsetEntry( - RangesData, RangeSectionBase, getFormat(), Index)) - return *Off + RangeSectionBase; - return None; -} - -Optional<uint64_t> DWARFUnit::getLoclistOffset(uint32_t Index) { - if (Optional<uint64_t> Off = llvm::DWARFListTableHeader::getOffsetEntry( - LocTable->getData(), LocSectionBase, getFormat(), Index)) - return *Off + LocSectionBase; + Desc = StrOffsetsContributionDescriptor(C->Offset, C->Length, 4, + Header.getFormat()); + else if (!IndexEntry && !StringOffsetSection.Data.empty()) + Desc = StrOffsetsContributionDescriptor(0, StringOffsetSection.Data.size(), + 4, Header.getFormat()); + else + return None; + auto DescOrError = Desc.validateContributionSize(DA); + if (!DescOrError) + return DescOrError.takeError(); + return *DescOrError; +} + +Optional<uint64_t> DWARFUnit::getRnglistOffset(uint32_t Index) { + DataExtractor RangesData(RangeSection->Data, isLittleEndian, + getAddressByteSize()); + DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection, + isLittleEndian, 0); + if (Optional<uint64_t> Off = llvm::DWARFListTableHeader::getOffsetEntry( + RangesData, RangeSectionBase, getFormat(), Index)) + return *Off + RangeSectionBase; return None; } + +Optional<uint64_t> DWARFUnit::getLoclistOffset(uint32_t Index) { + if (Optional<uint64_t> Off = llvm::DWARFListTableHeader::getOffsetEntry( + LocTable->getData(), LocSectionBase, getFormat(), Index)) + return *Off + LocSectionBase; + return None; +} diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFVerifier.cpp index ac624ec8b8..34f7d70883 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -172,15 +172,15 @@ unsigned DWARFVerifier::verifyUnitContents(DWARFUnit &Unit) { NumUnitErrors += verifyDebugInfoForm(Die, AttrValue); } - if (Die.hasChildren()) { - if (Die.getFirstChild().isValid() && - Die.getFirstChild().getTag() == DW_TAG_null) { - warn() << dwarf::TagString(Die.getTag()) - << " has DW_CHILDREN_yes but DIE has no children: "; - Die.dump(OS); - } - } - + if (Die.hasChildren()) { + if (Die.getFirstChild().isValid() && + Die.getFirstChild().getTag() == DW_TAG_null) { + warn() << dwarf::TagString(Die.getTag()) + << " has DW_CHILDREN_yes but DIE has no children: "; + Die.dump(OS); + } + } + NumUnitErrors += verifyDebugInfoCallSite(Die); } @@ -547,39 +547,39 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die, } break; } - case DW_AT_call_file: - case DW_AT_decl_file: { - if (auto FileIdx = AttrValue.Value.getAsUnsignedConstant()) { - DWARFUnit *U = Die.getDwarfUnit(); - const auto *LT = U->getContext().getLineTableForUnit(U); - if (LT) { - if (!LT->hasFileAtIndex(*FileIdx)) { - bool IsZeroIndexed = LT->Prologue.getVersion() >= 5; - if (Optional<uint64_t> LastFileIdx = LT->getLastValidFileIndex()) { - ReportError("DIE has " + AttributeString(Attr) + - " with an invalid file index " + - llvm::formatv("{0}", *FileIdx) + - " (valid values are [" + (IsZeroIndexed ? "0-" : "1-") + - llvm::formatv("{0}", *LastFileIdx) + "])"); - } else { - ReportError("DIE has " + AttributeString(Attr) + - " with an invalid file index " + - llvm::formatv("{0}", *FileIdx) + - " (the file table in the prologue is empty)"); - } - } - } else { - ReportError("DIE has " + AttributeString(Attr) + - " that references a file with index " + - llvm::formatv("{0}", *FileIdx) + - " and the compile unit has no line table"); - } - } else { - ReportError("DIE has " + AttributeString(Attr) + - " with invalid encoding"); - } - break; - } + case DW_AT_call_file: + case DW_AT_decl_file: { + if (auto FileIdx = AttrValue.Value.getAsUnsignedConstant()) { + DWARFUnit *U = Die.getDwarfUnit(); + const auto *LT = U->getContext().getLineTableForUnit(U); + if (LT) { + if (!LT->hasFileAtIndex(*FileIdx)) { + bool IsZeroIndexed = LT->Prologue.getVersion() >= 5; + if (Optional<uint64_t> LastFileIdx = LT->getLastValidFileIndex()) { + ReportError("DIE has " + AttributeString(Attr) + + " with an invalid file index " + + llvm::formatv("{0}", *FileIdx) + + " (valid values are [" + (IsZeroIndexed ? "0-" : "1-") + + llvm::formatv("{0}", *LastFileIdx) + "])"); + } else { + ReportError("DIE has " + AttributeString(Attr) + + " with an invalid file index " + + llvm::formatv("{0}", *FileIdx) + + " (the file table in the prologue is empty)"); + } + } + } else { + ReportError("DIE has " + AttributeString(Attr) + + " that references a file with index " + + llvm::formatv("{0}", *FileIdx) + + " and the compile unit has no line table"); + } + } else { + ReportError("DIE has " + AttributeString(Attr) + + " with invalid encoding"); + } + break; + } default: break; } diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/ya.make b/contrib/libs/llvm12/lib/DebugInfo/DWARF/ya.make index 5cb9397828..c17506f9d5 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/DWARF/ya.make +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/ya.make @@ -12,11 +12,11 @@ LICENSE(Apache-2.0 WITH LLVM-exception) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) PEERDIR( - contrib/libs/llvm12 - contrib/libs/llvm12/lib/BinaryFormat - contrib/libs/llvm12/lib/MC - contrib/libs/llvm12/lib/Object - contrib/libs/llvm12/lib/Support + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support ) ADDINCL( |