diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/libs/llvm12/lib/DebugInfo | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/DebugInfo')
58 files changed, 1207 insertions, 1207 deletions
diff --git a/contrib/libs/llvm12/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp b/contrib/libs/llvm12/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp index 2e029feb5e..9bc69abea1 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp @@ -47,9 +47,9 @@ Error DebugFrameDataSubsection::commit(BinaryStreamWriter &Writer) const { } std::vector<FrameData> SortedFrames(Frames.begin(), Frames.end()); - llvm::sort(SortedFrames, [](const FrameData &LHS, const FrameData &RHS) { - return LHS.RvaStart < RHS.RvaStart; - }); + llvm::sort(SortedFrames, [](const FrameData &LHS, const FrameData &RHS) { + return LHS.RvaStart < RHS.RvaStart; + }); if (auto EC = Writer.writeArray(makeArrayRef(SortedFrames))) return EC; return Error::success(); diff --git a/contrib/libs/llvm12/lib/DebugInfo/CodeView/EnumTables.cpp b/contrib/libs/llvm12/lib/DebugInfo/CodeView/EnumTables.cpp index 46bd73b4bc..949707bf54 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/CodeView/EnumTables.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/CodeView/EnumTables.cpp @@ -39,14 +39,14 @@ static const EnumEntry<uint16_t> RegisterNames_X86[] = { #undef CV_REGISTERS_X86 }; -static const EnumEntry<uint16_t> RegisterNames_ARM[] = { -#define CV_REGISTERS_ARM -#define CV_REGISTER(name, val) CV_ENUM_CLASS_ENT(RegisterId, name), -#include "llvm/DebugInfo/CodeView/CodeViewRegisters.def" -#undef CV_REGISTER -#undef CV_REGISTERS_ARM -}; - +static const EnumEntry<uint16_t> RegisterNames_ARM[] = { +#define CV_REGISTERS_ARM +#define CV_REGISTER(name, val) CV_ENUM_CLASS_ENT(RegisterId, name), +#include "llvm/DebugInfo/CodeView/CodeViewRegisters.def" +#undef CV_REGISTER +#undef CV_REGISTERS_ARM +}; + static const EnumEntry<uint16_t> RegisterNames_ARM64[] = { #define CV_REGISTERS_ARM64 #define CV_REGISTER(name, val) CV_ENUM_CLASS_ENT(RegisterId, name), @@ -442,9 +442,9 @@ ArrayRef<EnumEntry<TypeLeafKind>> getTypeLeafNames() { } ArrayRef<EnumEntry<uint16_t>> getRegisterNames(CPUType Cpu) { - if (Cpu == CPUType::ARMNT) { - return makeArrayRef(RegisterNames_ARM); - } else if (Cpu == CPUType::ARM64) { + if (Cpu == CPUType::ARMNT) { + return makeArrayRef(RegisterNames_ARM); + } else if (Cpu == CPUType::ARM64) { return makeArrayRef(RegisterNames_ARM64); } return makeArrayRef(RegisterNames_X86); diff --git a/contrib/libs/llvm12/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp b/contrib/libs/llvm12/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp index d924a5809d..c0fc3e0ef6 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp @@ -172,10 +172,10 @@ Error LazyRandomTypeCollection::visitRangeForType(TypeIndex TI) { if (PartialOffsets.empty()) return fullScanForType(TI); - auto Next = llvm::upper_bound(PartialOffsets, TI, - [](TypeIndex Value, const TypeIndexOffset &IO) { - return Value < IO.Type; - }); + auto Next = llvm::upper_bound(PartialOffsets, TI, + [](TypeIndex Value, const TypeIndexOffset &IO) { + return Value < IO.Type; + }); assert(Next != PartialOffsets.begin()); auto Prev = std::prev(Next); @@ -185,7 +185,7 @@ Error LazyRandomTypeCollection::visitRangeForType(TypeIndex TI) { // They've asked us to fetch a type index, but the entry we found in the // partial offsets array has already been visited. Since we visit an entire // block every time, that means this record should have been previously - // discovered. Ultimately, this means this is a request for a non-existent + // discovered. Ultimately, this means this is a request for a non-existent // type index. return make_error<CodeViewError>("Invalid type index"); } diff --git a/contrib/libs/llvm12/lib/DebugInfo/CodeView/RecordName.cpp b/contrib/libs/llvm12/lib/DebugInfo/CodeView/RecordName.cpp index 80c3408491..1ca899789b 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/CodeView/RecordName.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/CodeView/RecordName.cpp @@ -9,7 +9,7 @@ #include "llvm/DebugInfo/CodeView/RecordName.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h" #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" #include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h" @@ -78,10 +78,10 @@ Error TypeNameComputer::visitKnownRecord(CVType &CVR, ArgListRecord &Args) { uint32_t Size = Indices.size(); Name = "("; for (uint32_t I = 0; I < Size; ++I) { - if (Indices[I] < CurrentTypeIndex) - Name.append(Types.getTypeName(Indices[I])); - else - Name.append("<unknown 0x" + utohexstr(Indices[I].getIndex()) + ">"); + if (Indices[I] < CurrentTypeIndex) + Name.append(Types.getTypeName(Indices[I])); + else + Name.append("<unknown 0x" + utohexstr(Indices[I].getIndex()) + ">"); if (I + 1 != Size) Name.append(", "); } diff --git a/contrib/libs/llvm12/lib/DebugInfo/CodeView/RecordSerialization.cpp b/contrib/libs/llvm12/lib/DebugInfo/CodeView/RecordSerialization.cpp index 68a2a7b715..63ce302a4e 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/CodeView/RecordSerialization.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/CodeView/RecordSerialization.cpp @@ -34,7 +34,7 @@ StringRef llvm::codeview::getBytesAsCString(ArrayRef<uint8_t> LeafData) { } Error llvm::codeview::consume(BinaryStreamReader &Reader, APSInt &Num) { - // Used to avoid overload ambiguity on APInt constructor. + // Used to avoid overload ambiguity on APInt constructor. bool FalseVal = false; uint16_t Short; if (auto EC = Reader.readInteger(Short)) diff --git a/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp b/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp index a8af5419e7..682747a2b8 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// - + #include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/Endian.h" diff --git a/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeRecordMapping.cpp b/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeRecordMapping.cpp index b049252f09..7ac3761561 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeRecordMapping.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeRecordMapping.cpp @@ -232,7 +232,7 @@ Error TypeRecordMapping::visitMemberBegin(CVMemberRecord &Record) { // The largest possible subrecord is one in which there is a record prefix, // followed by the subrecord, followed by a continuation, and that entire - // sequence spawns `MaxRecordLength` bytes. So the record's length is + // sequence spawns `MaxRecordLength` bytes. So the record's length is // calculated as follows. constexpr uint32_t ContinuationLength = 8; diff --git a/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeStreamMerger.cpp b/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeStreamMerger.cpp index 52c8621738..587a68142a 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeStreamMerger.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/CodeView/TypeStreamMerger.cpp @@ -38,7 +38,7 @@ namespace { /// 0x1000. /// /// Type records are only allowed to use type indices smaller than their own, so -/// a type stream is effectively a topologically sorted DAG. Cycles occurring in +/// a type stream is effectively a topologically sorted DAG. Cycles occurring in /// the type graph of the source program are resolved with forward declarations /// of composite types. This class implements the following type stream merging /// algorithm, which relies on this DAG structure: diff --git a/contrib/libs/llvm12/lib/DebugInfo/CodeView/ya.make b/contrib/libs/llvm12/lib/DebugInfo/CodeView/ya.make index 000c00e8e9..8829a8f09f 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/CodeView/ya.make +++ b/contrib/libs/llvm12/lib/DebugInfo/CodeView/ya.make @@ -12,9 +12,9 @@ LICENSE(Apache-2.0 WITH LLVM-exception) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) PEERDIR( - contrib/libs/llvm12 - contrib/libs/llvm12/lib/DebugInfo/MSF - contrib/libs/llvm12/lib/Support + contrib/libs/llvm12 + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/Support ) ADDINCL( diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFAddressRange.cpp b/contrib/libs/llvm12/lib/DebugInfo/DWARF/DWARFAddressRange.cpp index 96766c48db..25d2e852a7 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 c3fceaa00f..2b08120ef4 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 52cb9387e8..749d738af9 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 fb16d8b35a..da6f6ad903 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 8a7809598d..598e3ecee3 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 fbbf8af840..e0db469752 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 788ea89400..b74ecac681 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 ce3a49201f..2b7d0c3363 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 a0758247a6..bda41b1f34 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 710a0536fa..cdffb36741 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 c153186b61..80ffd81b34 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 38bc79c3ed..dc7da5d934 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 bca8512467..d12acca196 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); + "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); } - 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(); + *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 ad67e8af85..5a55f3a041 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 aeb9063d7a..811716111b 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 4e1f7b1d48..2559765876 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 caee9f333d..ace7000f07 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 9d9b85b472..c876af1e9b 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 527e3cbcaf..a301b65dd4 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 3688321ad6..8493950a29 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; + 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; } - -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 34f7d70883..ac624ec8b8 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 c17506f9d5..5cb9397828 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( diff --git a/contrib/libs/llvm12/lib/DebugInfo/MSF/MSFBuilder.cpp b/contrib/libs/llvm12/lib/DebugInfo/MSF/MSFBuilder.cpp index 7c5356908f..f946dd4860 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/MSF/MSFBuilder.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/MSF/MSFBuilder.cpp @@ -204,7 +204,7 @@ Error MSFBuilder::setStreamSize(uint32_t Idx, uint32_t Size) { if (auto EC = allocateBlocks(AddedBlocks, AddedBlockList)) return EC; auto &CurrentBlocks = StreamData[Idx].second; - llvm::append_range(CurrentBlocks, AddedBlockList); + llvm::append_range(CurrentBlocks, AddedBlockList); } else if (OldBlocks > NewBlocks) { // For shrinking, free all the Blocks in the Block map, update the stream // data, then shrink the directory. @@ -267,7 +267,7 @@ Expected<MSFLayout> MSFBuilder::generateLayout() { ExtraBlocks.resize(NumExtraBlocks); if (auto EC = allocateBlocks(NumExtraBlocks, ExtraBlocks)) return std::move(EC); - llvm::append_range(DirectoryBlocks, ExtraBlocks); + llvm::append_range(DirectoryBlocks, ExtraBlocks); } else if (NumDirectoryBlocks < DirectoryBlocks.size()) { uint32_t NumUnnecessaryBlocks = DirectoryBlocks.size() - NumDirectoryBlocks; for (auto B : diff --git a/contrib/libs/llvm12/lib/DebugInfo/MSF/ya.make b/contrib/libs/llvm12/lib/DebugInfo/MSF/ya.make index d114fb5377..a9daa7d1aa 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/MSF/ya.make +++ b/contrib/libs/llvm12/lib/DebugInfo/MSF/ya.make @@ -12,8 +12,8 @@ LICENSE(Apache-2.0 WITH LLVM-exception) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) PEERDIR( - contrib/libs/llvm12 - contrib/libs/llvm12/lib/Support + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support ) ADDINCL( diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp index 4fcf0f60e2..b6f11a942a 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp @@ -74,7 +74,7 @@ void DbiModuleDescriptorBuilder::addSymbolsInBulk( if (BulkSymbols.empty()) return; - Symbols.push_back(SymbolListWrapper(BulkSymbols)); + Symbols.push_back(SymbolListWrapper(BulkSymbols)); // Symbols written to a PDB file are required to be 4 byte aligned. The same // is not true of object files. assert(BulkSymbols.size() % alignOf(CodeViewContainer::Pdb) == 0 && @@ -82,18 +82,18 @@ void DbiModuleDescriptorBuilder::addSymbolsInBulk( SymbolByteSize += BulkSymbols.size(); } -void DbiModuleDescriptorBuilder::addUnmergedSymbols(void *SymSrc, - uint32_t SymLength) { - assert(SymLength > 0); - Symbols.push_back(SymbolListWrapper(SymSrc, SymLength)); - - // Symbols written to a PDB file are required to be 4 byte aligned. The same - // is not true of object files. - assert(SymLength % alignOf(CodeViewContainer::Pdb) == 0 && - "Invalid Symbol alignment!"); - SymbolByteSize += SymLength; -} - +void DbiModuleDescriptorBuilder::addUnmergedSymbols(void *SymSrc, + uint32_t SymLength) { + assert(SymLength > 0); + Symbols.push_back(SymbolListWrapper(SymSrc, SymLength)); + + // Symbols written to a PDB file are required to be 4 byte aligned. The same + // is not true of object files. + assert(SymLength % alignOf(CodeViewContainer::Pdb) == 0 && + "Invalid Symbol alignment!"); + SymbolByteSize += SymLength; +} + void DbiModuleDescriptorBuilder::addSourceFile(StringRef Path) { SourceFiles.push_back(std::string(Path)); } @@ -143,7 +143,7 @@ Error DbiModuleDescriptorBuilder::finalizeMsfLayout() { return Error::success(); } -Error DbiModuleDescriptorBuilder::commit(BinaryStreamWriter &ModiWriter) { +Error DbiModuleDescriptorBuilder::commit(BinaryStreamWriter &ModiWriter) { // We write the Modi record to the `ModiWriter`, but we additionally write its // symbol stream to a brand new stream. if (auto EC = ModiWriter.writeObject(Layout)) @@ -154,55 +154,55 @@ Error DbiModuleDescriptorBuilder::commit(BinaryStreamWriter &ModiWriter) { return EC; if (auto EC = ModiWriter.padToAlignment(sizeof(uint32_t))) return EC; - return Error::success(); -} - -Error DbiModuleDescriptorBuilder::commitSymbolStream( - const msf::MSFLayout &MsfLayout, WritableBinaryStreamRef MsfBuffer) { - if (Layout.ModDiStream == kInvalidStreamIndex) - return Error::success(); - - auto NS = WritableMappedBlockStream::createIndexedStream( - MsfLayout, MsfBuffer, Layout.ModDiStream, MSF.getAllocator()); - WritableBinaryStreamRef Ref(*NS); - BinaryStreamWriter SymbolWriter(Ref); - // Write the symbols. - if (auto EC = SymbolWriter.writeInteger<uint32_t>(COFF::DEBUG_SECTION_MAGIC)) - return EC; - for (const SymbolListWrapper &Sym : Symbols) { - if (Sym.NeedsToBeMerged) { - assert(MergeSymsCallback); - if (auto EC = MergeSymsCallback(MergeSymsCtx, Sym.SymPtr, SymbolWriter)) + return Error::success(); +} + +Error DbiModuleDescriptorBuilder::commitSymbolStream( + const msf::MSFLayout &MsfLayout, WritableBinaryStreamRef MsfBuffer) { + if (Layout.ModDiStream == kInvalidStreamIndex) + return Error::success(); + + auto NS = WritableMappedBlockStream::createIndexedStream( + MsfLayout, MsfBuffer, Layout.ModDiStream, MSF.getAllocator()); + WritableBinaryStreamRef Ref(*NS); + BinaryStreamWriter SymbolWriter(Ref); + // Write the symbols. + if (auto EC = SymbolWriter.writeInteger<uint32_t>(COFF::DEBUG_SECTION_MAGIC)) + return EC; + for (const SymbolListWrapper &Sym : Symbols) { + if (Sym.NeedsToBeMerged) { + assert(MergeSymsCallback); + if (auto EC = MergeSymsCallback(MergeSymsCtx, Sym.SymPtr, SymbolWriter)) return EC; - } else { - if (auto EC = SymbolWriter.writeBytes(Sym.asArray())) + } else { + if (auto EC = SymbolWriter.writeBytes(Sym.asArray())) return EC; } - } - - // Apply the string table fixups. - auto SavedOffset = SymbolWriter.getOffset(); - for (const StringTableFixup &Fixup : StringTableFixups) { - SymbolWriter.setOffset(Fixup.SymOffsetOfReference); - if (auto E = SymbolWriter.writeInteger<uint32_t>(Fixup.StrTabOffset)) - return E; - } - SymbolWriter.setOffset(SavedOffset); - - assert(SymbolWriter.getOffset() % alignOf(CodeViewContainer::Pdb) == 0 && - "Invalid debug section alignment!"); - // TODO: Write C11 Line data - for (const auto &Builder : C13Builders) { - if (auto EC = Builder.commit(SymbolWriter, CodeViewContainer::Pdb)) + } + + // Apply the string table fixups. + auto SavedOffset = SymbolWriter.getOffset(); + for (const StringTableFixup &Fixup : StringTableFixups) { + SymbolWriter.setOffset(Fixup.SymOffsetOfReference); + if (auto E = SymbolWriter.writeInteger<uint32_t>(Fixup.StrTabOffset)) + return E; + } + SymbolWriter.setOffset(SavedOffset); + + assert(SymbolWriter.getOffset() % alignOf(CodeViewContainer::Pdb) == 0 && + "Invalid debug section alignment!"); + // TODO: Write C11 Line data + for (const auto &Builder : C13Builders) { + if (auto EC = Builder.commit(SymbolWriter, CodeViewContainer::Pdb)) return EC; } - - // TODO: Figure out what GlobalRefs substream actually is and populate it. - if (auto EC = SymbolWriter.writeInteger<uint32_t>(0)) - return EC; - if (SymbolWriter.bytesRemaining() > 0) - return make_error<RawError>(raw_error_code::stream_too_long); - + + // TODO: Figure out what GlobalRefs substream actually is and populate it. + if (auto EC = SymbolWriter.writeInteger<uint32_t>(0)) + return EC; + if (SymbolWriter.bytesRemaining() > 0) + return make_error<RawError>(raw_error_code::stream_too_long); + return Error::success(); } diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp index 48321ae3d9..98a8acaffd 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp @@ -18,7 +18,7 @@ #include "llvm/DebugInfo/PDB/Native/RawError.h" #include "llvm/Object/COFF.h" #include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/Parallel.h" +#include "llvm/Support/Parallel.h" using namespace llvm; using namespace llvm::codeview; @@ -395,17 +395,17 @@ Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout, return EC; for (auto &M : ModiList) { - if (auto EC = M->commit(Writer)) + if (auto EC = M->commit(Writer)) return EC; } - // Commit symbol streams. This is a lot of data, so do it in parallel. - if (auto EC = parallelForEachError( - ModiList, [&](std::unique_ptr<DbiModuleDescriptorBuilder> &M) { - return M->commitSymbolStream(Layout, MsfBuffer); - })) - return EC; - + // Commit symbol streams. This is a lot of data, so do it in parallel. + if (auto EC = parallelForEachError( + ModiList, [&](std::unique_ptr<DbiModuleDescriptorBuilder> &M) { + return M->commitSymbolStream(Layout, MsfBuffer); + })) + return EC; + if (!SectionContribs.empty()) { if (auto EC = Writer.writeEnum(DbiSecContribVer60)) return EC; diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp index 6cad5474bb..52df26b679 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp @@ -162,7 +162,7 @@ static int gsiRecordCmp(StringRef S1, StringRef S2) { if (LLVM_UNLIKELY(!isAsciiString(S1) || !isAsciiString(S2))) return memcmp(S1.data(), S2.data(), LS); - // Both strings are ascii, perform a case-insensitive comparison. + // Both strings are ascii, perform a case-insensitive comparison. return S1.compare_lower(S2.data()); } diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp index dfe545c889..1d873b87b3 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp @@ -116,7 +116,7 @@ StringMap<uint32_t> NamedStreamMap::entries() const { uint32_t NamedStreamMap::appendStringData(StringRef S) { uint32_t Offset = NamesBuffer.size(); - llvm::append_range(NamesBuffer, S); + llvm::append_range(NamesBuffer, S); NamesBuffer.push_back('\0'); return Offset; } diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeEnumSymbols.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeEnumSymbols.cpp index c861163b3f..feede1dbc9 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeEnumSymbols.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeEnumSymbols.cpp @@ -1,41 +1,41 @@ -//==- NativeEnumSymbols.cpp - Native Symbol Enumerator impl ------*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "llvm/DebugInfo/PDB/Native/NativeEnumSymbols.h" - -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" -#include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h" - -using namespace llvm; -using namespace llvm::codeview; -using namespace llvm::pdb; - -NativeEnumSymbols::NativeEnumSymbols(NativeSession &PDBSession, - std::vector<SymIndexId> Symbols) - : Symbols(std::move(Symbols)), Index(0), Session(PDBSession) {} - -uint32_t NativeEnumSymbols::getChildCount() const { - return static_cast<uint32_t>(Symbols.size()); -} - -std::unique_ptr<PDBSymbol> -NativeEnumSymbols::getChildAtIndex(uint32_t N) const { - if (N < Symbols.size()) { - return Session.getSymbolCache().getSymbolById(Symbols[N]); - } - return nullptr; -} - -std::unique_ptr<PDBSymbol> NativeEnumSymbols::getNext() { - return getChildAtIndex(Index++); -} - -void NativeEnumSymbols::reset() { Index = 0; } +//==- NativeEnumSymbols.cpp - Native Symbol Enumerator impl ------*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "llvm/DebugInfo/PDB/Native/NativeEnumSymbols.h" + +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" +#include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h" +#include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h" + +using namespace llvm; +using namespace llvm::codeview; +using namespace llvm::pdb; + +NativeEnumSymbols::NativeEnumSymbols(NativeSession &PDBSession, + std::vector<SymIndexId> Symbols) + : Symbols(std::move(Symbols)), Index(0), Session(PDBSession) {} + +uint32_t NativeEnumSymbols::getChildCount() const { + return static_cast<uint32_t>(Symbols.size()); +} + +std::unique_ptr<PDBSymbol> +NativeEnumSymbols::getChildAtIndex(uint32_t N) const { + if (N < Symbols.size()) { + return Session.getSymbolCache().getSymbolById(Symbols[N]); + } + return nullptr; +} + +std::unique_ptr<PDBSymbol> NativeEnumSymbols::getNext() { + return getChildAtIndex(Index++); +} + +void NativeEnumSymbols::reset() { Index = 0; } diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeFunctionSymbol.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeFunctionSymbol.cpp index 0a8d3de330..7f3b35c297 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeFunctionSymbol.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeFunctionSymbol.cpp @@ -8,9 +8,9 @@ #include "llvm/DebugInfo/PDB/Native/NativeFunctionSymbol.h" -#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h" +#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/PDB/Native/NativeEnumSymbols.h" +#include "llvm/DebugInfo/PDB/Native/NativeEnumSymbols.h" #include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h" #include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h" @@ -20,10 +20,10 @@ using namespace llvm::pdb; NativeFunctionSymbol::NativeFunctionSymbol(NativeSession &Session, SymIndexId Id, - const codeview::ProcSym &Sym, - uint32_t Offset) - : NativeRawSymbol(Session, PDB_SymType::Function, Id), Sym(Sym), - RecordOffset(Offset) {} + const codeview::ProcSym &Sym, + uint32_t Offset) + : NativeRawSymbol(Session, PDB_SymType::Function, Id), Sym(Sym), + RecordOffset(Offset) {} NativeFunctionSymbol::~NativeFunctionSymbol() {} @@ -55,89 +55,89 @@ uint32_t NativeFunctionSymbol::getRelativeVirtualAddress() const { uint64_t NativeFunctionSymbol::getVirtualAddress() const { return Session.getVAFromSectOffset(Sym.Segment, Sym.CodeOffset); } - -static bool inlineSiteContainsAddress(InlineSiteSym &IS, - uint32_t OffsetInFunc) { - // Returns true if inline site contains the offset. - bool Found = false; - uint32_t CodeOffset = 0; - for (auto &Annot : IS.annotations()) { - switch (Annot.OpCode) { - case BinaryAnnotationsOpCode::CodeOffset: - case BinaryAnnotationsOpCode::ChangeCodeOffset: - case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: - CodeOffset += Annot.U1; - if (OffsetInFunc >= CodeOffset) - Found = true; - break; - case BinaryAnnotationsOpCode::ChangeCodeLength: - CodeOffset += Annot.U1; - if (Found && OffsetInFunc < CodeOffset) - return true; - Found = false; - break; - case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: - CodeOffset += Annot.U2; - if (OffsetInFunc >= CodeOffset && OffsetInFunc < CodeOffset + Annot.U1) - return true; - Found = false; - break; - default: - break; - } - } - return false; -} - -std::unique_ptr<IPDBEnumSymbols> -NativeFunctionSymbol::findInlineFramesByVA(uint64_t VA) const { - uint16_t Modi; - if (!Session.moduleIndexForVA(VA, Modi)) - return nullptr; - - Expected<ModuleDebugStreamRef> ModS = Session.getModuleDebugStream(Modi); - if (!ModS) { - consumeError(ModS.takeError()); - return nullptr; - } - CVSymbolArray Syms = ModS->getSymbolArray(); - - // Search for inline sites. There should be one matching top level inline - // site. Then search in its nested inline sites. - std::vector<SymIndexId> Frames; - uint32_t CodeOffset = VA - getVirtualAddress(); - auto Start = Syms.at(RecordOffset); - auto End = Syms.at(Sym.End); - while (Start != End) { - bool Found = false; - // Find matching inline site within Start and End. - for (; Start != End; ++Start) { - if (Start->kind() != S_INLINESITE) - continue; - - InlineSiteSym IS = - cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(*Start)); - if (inlineSiteContainsAddress(IS, CodeOffset)) { - // Insert frames in reverse order. - SymIndexId Id = Session.getSymbolCache().getOrCreateInlineSymbol( - IS, getVirtualAddress(), Modi, Start.offset()); - Frames.insert(Frames.begin(), Id); - - // Update offsets to search within this inline site. - ++Start; - End = Syms.at(IS.End); - Found = true; - break; - } - - Start = Syms.at(IS.End); - if (Start == End) - break; - } - - if (!Found) - break; - } - - return std::make_unique<NativeEnumSymbols>(Session, std::move(Frames)); -} + +static bool inlineSiteContainsAddress(InlineSiteSym &IS, + uint32_t OffsetInFunc) { + // Returns true if inline site contains the offset. + bool Found = false; + uint32_t CodeOffset = 0; + for (auto &Annot : IS.annotations()) { + switch (Annot.OpCode) { + case BinaryAnnotationsOpCode::CodeOffset: + case BinaryAnnotationsOpCode::ChangeCodeOffset: + case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: + CodeOffset += Annot.U1; + if (OffsetInFunc >= CodeOffset) + Found = true; + break; + case BinaryAnnotationsOpCode::ChangeCodeLength: + CodeOffset += Annot.U1; + if (Found && OffsetInFunc < CodeOffset) + return true; + Found = false; + break; + case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: + CodeOffset += Annot.U2; + if (OffsetInFunc >= CodeOffset && OffsetInFunc < CodeOffset + Annot.U1) + return true; + Found = false; + break; + default: + break; + } + } + return false; +} + +std::unique_ptr<IPDBEnumSymbols> +NativeFunctionSymbol::findInlineFramesByVA(uint64_t VA) const { + uint16_t Modi; + if (!Session.moduleIndexForVA(VA, Modi)) + return nullptr; + + Expected<ModuleDebugStreamRef> ModS = Session.getModuleDebugStream(Modi); + if (!ModS) { + consumeError(ModS.takeError()); + return nullptr; + } + CVSymbolArray Syms = ModS->getSymbolArray(); + + // Search for inline sites. There should be one matching top level inline + // site. Then search in its nested inline sites. + std::vector<SymIndexId> Frames; + uint32_t CodeOffset = VA - getVirtualAddress(); + auto Start = Syms.at(RecordOffset); + auto End = Syms.at(Sym.End); + while (Start != End) { + bool Found = false; + // Find matching inline site within Start and End. + for (; Start != End; ++Start) { + if (Start->kind() != S_INLINESITE) + continue; + + InlineSiteSym IS = + cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(*Start)); + if (inlineSiteContainsAddress(IS, CodeOffset)) { + // Insert frames in reverse order. + SymIndexId Id = Session.getSymbolCache().getOrCreateInlineSymbol( + IS, getVirtualAddress(), Modi, Start.offset()); + Frames.insert(Frames.begin(), Id); + + // Update offsets to search within this inline site. + ++Start; + End = Syms.at(IS.End); + Found = true; + break; + } + + Start = Syms.at(IS.End); + if (Start == End) + break; + } + + if (!Found) + break; + } + + return std::make_unique<NativeEnumSymbols>(Session, std::move(Frames)); +} diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeInlineSiteSymbol.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeInlineSiteSymbol.cpp index 9708976f28..8314353c38 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeInlineSiteSymbol.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeInlineSiteSymbol.cpp @@ -1,177 +1,177 @@ -//===- NativeInlineSiteSymbol.cpp - info about inline sites -----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "llvm/DebugInfo/PDB/Native/NativeInlineSiteSymbol.h" - -#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" -#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/CodeView/TypeDeserializer.h" -#include "llvm/DebugInfo/PDB/Native/NativeEnumLineNumbers.h" -#include "llvm/DebugInfo/PDB/Native/TpiStream.h" - -using namespace llvm; -using namespace llvm::codeview; -using namespace llvm::pdb; - -NativeInlineSiteSymbol::NativeInlineSiteSymbol( - NativeSession &Session, SymIndexId Id, const codeview::InlineSiteSym &Sym, - uint64_t ParentAddr) - : NativeRawSymbol(Session, PDB_SymType::InlineSite, Id), Sym(Sym), - ParentAddr(ParentAddr) {} - -NativeInlineSiteSymbol::~NativeInlineSiteSymbol() {} - -void NativeInlineSiteSymbol::dump(raw_ostream &OS, int Indent, - PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const { - NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields); - dumpSymbolField(OS, "name", getName(), Indent); -} - -static Optional<InlineeSourceLine> -findInlineeByTypeIndex(TypeIndex Id, ModuleDebugStreamRef &ModS) { - for (const auto &SS : ModS.getSubsectionsArray()) { - if (SS.kind() != DebugSubsectionKind::InlineeLines) - continue; - - DebugInlineeLinesSubsectionRef InlineeLines; - BinaryStreamReader Reader(SS.getRecordData()); - if (auto EC = InlineeLines.initialize(Reader)) { - consumeError(std::move(EC)); - continue; - } - - for (const InlineeSourceLine &Line : InlineeLines) - if (Line.Header->Inlinee == Id) - return Line; - } - return None; -} - -std::string NativeInlineSiteSymbol::getName() const { - auto Tpi = Session.getPDBFile().getPDBTpiStream(); - if (!Tpi) { - consumeError(Tpi.takeError()); - return ""; - } - auto Ipi = Session.getPDBFile().getPDBIpiStream(); - if (!Ipi) { - consumeError(Ipi.takeError()); - return ""; - } - - LazyRandomTypeCollection &Types = Tpi->typeCollection(); - LazyRandomTypeCollection &Ids = Ipi->typeCollection(); - CVType InlineeType = Ids.getType(Sym.Inlinee); - std::string QualifiedName; - if (InlineeType.kind() == LF_MFUNC_ID) { - MemberFuncIdRecord MFRecord; - cantFail(TypeDeserializer::deserializeAs<MemberFuncIdRecord>(InlineeType, - MFRecord)); - TypeIndex ClassTy = MFRecord.getClassType(); - QualifiedName.append(std::string(Types.getTypeName(ClassTy))); - QualifiedName.append("::"); - } else if (InlineeType.kind() == LF_FUNC_ID) { - FuncIdRecord FRecord; - cantFail( - TypeDeserializer::deserializeAs<FuncIdRecord>(InlineeType, FRecord)); - TypeIndex ParentScope = FRecord.getParentScope(); - if (!ParentScope.isNoneType()) { - QualifiedName.append(std::string(Ids.getTypeName(ParentScope))); - QualifiedName.append("::"); - } - } - - QualifiedName.append(std::string(Ids.getTypeName(Sym.Inlinee))); - return QualifiedName; -} - -void NativeInlineSiteSymbol::getLineOffset(uint32_t OffsetInFunc, - uint32_t &LineOffset, - uint32_t &FileOffset) const { - LineOffset = 0; - FileOffset = 0; - uint32_t CodeOffset = 0; - for (const auto &Annot : Sym.annotations()) { - switch (Annot.OpCode) { - case BinaryAnnotationsOpCode::CodeOffset: - case BinaryAnnotationsOpCode::ChangeCodeOffset: - case BinaryAnnotationsOpCode::ChangeCodeLength: - CodeOffset += Annot.U1; - break; - case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: - CodeOffset += Annot.U2; - break; - case BinaryAnnotationsOpCode::ChangeLineOffset: - case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: - CodeOffset += Annot.U1; - LineOffset += Annot.S1; - break; - case BinaryAnnotationsOpCode::ChangeFile: - FileOffset = Annot.U1; - break; - default: - break; - } - - if (CodeOffset >= OffsetInFunc) - return; - } -} - -std::unique_ptr<IPDBEnumLineNumbers> -NativeInlineSiteSymbol::findInlineeLinesByVA(uint64_t VA, - uint32_t Length) const { - uint16_t Modi; - if (!Session.moduleIndexForVA(VA, Modi)) - return nullptr; - - Expected<ModuleDebugStreamRef> ModS = Session.getModuleDebugStream(Modi); - if (!ModS) { - consumeError(ModS.takeError()); - return nullptr; - } - - Expected<DebugChecksumsSubsectionRef> Checksums = - ModS->findChecksumsSubsection(); - if (!Checksums) { - consumeError(Checksums.takeError()); - return nullptr; - } - - // Get the line number offset and source file offset. - uint32_t SrcLineOffset; - uint32_t SrcFileOffset; - getLineOffset(VA - ParentAddr, SrcLineOffset, SrcFileOffset); - - // Get line info from inlinee line table. - Optional<InlineeSourceLine> Inlinee = - findInlineeByTypeIndex(Sym.Inlinee, ModS.get()); - - if (!Inlinee) - return nullptr; - - uint32_t SrcLine = Inlinee->Header->SourceLineNum + SrcLineOffset; - uint32_t SrcCol = 0; // Inline sites don't seem to have column info. - uint32_t FileChecksumOffset = - (SrcFileOffset == 0) ? Inlinee->Header->FileID : SrcFileOffset; - - auto ChecksumIter = Checksums->getArray().at(FileChecksumOffset); - uint32_t SrcFileId = - Session.getSymbolCache().getOrCreateSourceFile(*ChecksumIter); - - uint32_t LineSect, LineOff; - Session.addressForVA(VA, LineSect, LineOff); - NativeLineNumber LineNum(Session, SrcLine, SrcCol, LineSect, LineOff, Length, - SrcFileId, Modi); - auto SrcFile = Session.getSymbolCache().getSourceFileById(SrcFileId); - std::vector<NativeLineNumber> Lines{LineNum}; - - return std::make_unique<NativeEnumLineNumbers>(std::move(Lines)); -} +//===- NativeInlineSiteSymbol.cpp - info about inline sites -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "llvm/DebugInfo/PDB/Native/NativeInlineSiteSymbol.h" + +#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" +#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/CodeView/TypeDeserializer.h" +#include "llvm/DebugInfo/PDB/Native/NativeEnumLineNumbers.h" +#include "llvm/DebugInfo/PDB/Native/TpiStream.h" + +using namespace llvm; +using namespace llvm::codeview; +using namespace llvm::pdb; + +NativeInlineSiteSymbol::NativeInlineSiteSymbol( + NativeSession &Session, SymIndexId Id, const codeview::InlineSiteSym &Sym, + uint64_t ParentAddr) + : NativeRawSymbol(Session, PDB_SymType::InlineSite, Id), Sym(Sym), + ParentAddr(ParentAddr) {} + +NativeInlineSiteSymbol::~NativeInlineSiteSymbol() {} + +void NativeInlineSiteSymbol::dump(raw_ostream &OS, int Indent, + PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const { + NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields); + dumpSymbolField(OS, "name", getName(), Indent); +} + +static Optional<InlineeSourceLine> +findInlineeByTypeIndex(TypeIndex Id, ModuleDebugStreamRef &ModS) { + for (const auto &SS : ModS.getSubsectionsArray()) { + if (SS.kind() != DebugSubsectionKind::InlineeLines) + continue; + + DebugInlineeLinesSubsectionRef InlineeLines; + BinaryStreamReader Reader(SS.getRecordData()); + if (auto EC = InlineeLines.initialize(Reader)) { + consumeError(std::move(EC)); + continue; + } + + for (const InlineeSourceLine &Line : InlineeLines) + if (Line.Header->Inlinee == Id) + return Line; + } + return None; +} + +std::string NativeInlineSiteSymbol::getName() const { + auto Tpi = Session.getPDBFile().getPDBTpiStream(); + if (!Tpi) { + consumeError(Tpi.takeError()); + return ""; + } + auto Ipi = Session.getPDBFile().getPDBIpiStream(); + if (!Ipi) { + consumeError(Ipi.takeError()); + return ""; + } + + LazyRandomTypeCollection &Types = Tpi->typeCollection(); + LazyRandomTypeCollection &Ids = Ipi->typeCollection(); + CVType InlineeType = Ids.getType(Sym.Inlinee); + std::string QualifiedName; + if (InlineeType.kind() == LF_MFUNC_ID) { + MemberFuncIdRecord MFRecord; + cantFail(TypeDeserializer::deserializeAs<MemberFuncIdRecord>(InlineeType, + MFRecord)); + TypeIndex ClassTy = MFRecord.getClassType(); + QualifiedName.append(std::string(Types.getTypeName(ClassTy))); + QualifiedName.append("::"); + } else if (InlineeType.kind() == LF_FUNC_ID) { + FuncIdRecord FRecord; + cantFail( + TypeDeserializer::deserializeAs<FuncIdRecord>(InlineeType, FRecord)); + TypeIndex ParentScope = FRecord.getParentScope(); + if (!ParentScope.isNoneType()) { + QualifiedName.append(std::string(Ids.getTypeName(ParentScope))); + QualifiedName.append("::"); + } + } + + QualifiedName.append(std::string(Ids.getTypeName(Sym.Inlinee))); + return QualifiedName; +} + +void NativeInlineSiteSymbol::getLineOffset(uint32_t OffsetInFunc, + uint32_t &LineOffset, + uint32_t &FileOffset) const { + LineOffset = 0; + FileOffset = 0; + uint32_t CodeOffset = 0; + for (const auto &Annot : Sym.annotations()) { + switch (Annot.OpCode) { + case BinaryAnnotationsOpCode::CodeOffset: + case BinaryAnnotationsOpCode::ChangeCodeOffset: + case BinaryAnnotationsOpCode::ChangeCodeLength: + CodeOffset += Annot.U1; + break; + case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: + CodeOffset += Annot.U2; + break; + case BinaryAnnotationsOpCode::ChangeLineOffset: + case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: + CodeOffset += Annot.U1; + LineOffset += Annot.S1; + break; + case BinaryAnnotationsOpCode::ChangeFile: + FileOffset = Annot.U1; + break; + default: + break; + } + + if (CodeOffset >= OffsetInFunc) + return; + } +} + +std::unique_ptr<IPDBEnumLineNumbers> +NativeInlineSiteSymbol::findInlineeLinesByVA(uint64_t VA, + uint32_t Length) const { + uint16_t Modi; + if (!Session.moduleIndexForVA(VA, Modi)) + return nullptr; + + Expected<ModuleDebugStreamRef> ModS = Session.getModuleDebugStream(Modi); + if (!ModS) { + consumeError(ModS.takeError()); + return nullptr; + } + + Expected<DebugChecksumsSubsectionRef> Checksums = + ModS->findChecksumsSubsection(); + if (!Checksums) { + consumeError(Checksums.takeError()); + return nullptr; + } + + // Get the line number offset and source file offset. + uint32_t SrcLineOffset; + uint32_t SrcFileOffset; + getLineOffset(VA - ParentAddr, SrcLineOffset, SrcFileOffset); + + // Get line info from inlinee line table. + Optional<InlineeSourceLine> Inlinee = + findInlineeByTypeIndex(Sym.Inlinee, ModS.get()); + + if (!Inlinee) + return nullptr; + + uint32_t SrcLine = Inlinee->Header->SourceLineNum + SrcLineOffset; + uint32_t SrcCol = 0; // Inline sites don't seem to have column info. + uint32_t FileChecksumOffset = + (SrcFileOffset == 0) ? Inlinee->Header->FileID : SrcFileOffset; + + auto ChecksumIter = Checksums->getArray().at(FileChecksumOffset); + uint32_t SrcFileId = + Session.getSymbolCache().getOrCreateSourceFile(*ChecksumIter); + + uint32_t LineSect, LineOff; + Session.addressForVA(VA, LineSect, LineOff); + NativeLineNumber LineNum(Session, SrcLine, SrcCol, LineSect, LineOff, Length, + SrcFileId, Modi); + auto SrcFile = Session.getSymbolCache().getSourceFileById(SrcFileId); + std::vector<NativeLineNumber> Lines{LineNum}; + + return std::make_unique<NativeEnumLineNumbers>(std::move(Lines)); +} diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeLineNumber.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeLineNumber.cpp index aefacfd23f..155ed0cdb8 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeLineNumber.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeLineNumber.cpp @@ -15,10 +15,10 @@ NativeLineNumber::NativeLineNumber(const NativeSession &Session, const codeview::LineInfo Line, uint32_t ColumnNumber, uint32_t Section, uint32_t Offset, uint32_t Length, - uint32_t SrcFileId, uint32_t CompilandId) + uint32_t SrcFileId, uint32_t CompilandId) : Session(Session), Line(Line), ColumnNumber(ColumnNumber), - Section(Section), Offset(Offset), Length(Length), SrcFileId(SrcFileId), - CompilandId(CompilandId) {} + Section(Section), Offset(Offset), Length(Length), SrcFileId(SrcFileId), + CompilandId(CompilandId) {} uint32_t NativeLineNumber::getLineNumber() const { return Line.getStartLine(); } @@ -46,6 +46,6 @@ uint32_t NativeLineNumber::getLength() const { return Length; } uint32_t NativeLineNumber::getSourceFileId() const { return SrcFileId; } -uint32_t NativeLineNumber::getCompilandId() const { return CompilandId; } +uint32_t NativeLineNumber::getCompilandId() const { return CompilandId; } bool NativeLineNumber::isStatement() const { return Line.isStatement(); } diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativePublicSymbol.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativePublicSymbol.cpp index 501b3003ba..1265e688b8 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativePublicSymbol.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativePublicSymbol.cpp @@ -18,7 +18,7 @@ using namespace llvm::pdb; NativePublicSymbol::NativePublicSymbol(NativeSession &Session, SymIndexId Id, const codeview::PublicSym32 &Sym) - : NativeRawSymbol(Session, PDB_SymType::PublicSymbol, Id), Sym(Sym) {} + : NativeRawSymbol(Session, PDB_SymType::PublicSymbol, Id), Sym(Sym) {} NativePublicSymbol::~NativePublicSymbol() {} diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSession.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSession.cpp index 6a7e7ee4d8..5d7946cdc2 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSession.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSession.cpp @@ -13,7 +13,7 @@ #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBSourceFile.h" #include "llvm/DebugInfo/PDB/Native/DbiStream.h" -#include "llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h" +#include "llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h" #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h" #include "llvm/DebugInfo/PDB/Native/NativeEnumInjectedSources.h" #include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h" @@ -57,7 +57,7 @@ static DbiStream *getDbiStreamPtr(PDBFile &File) { NativeSession::NativeSession(std::unique_ptr<PDBFile> PdbFile, std::unique_ptr<BumpPtrAllocator> Allocator) : Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)), - Cache(*this, getDbiStreamPtr(*Pdb)), AddrToModuleIndex(IMapAllocator) {} + Cache(*this, getDbiStreamPtr(*Pdb)), AddrToModuleIndex(IMapAllocator) {} NativeSession::~NativeSession() = default; @@ -256,9 +256,9 @@ std::unique_ptr<PDBSymbol> NativeSession::findSymbolByRVA(uint32_t RVA, std::unique_ptr<PDBSymbol> NativeSession::findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, PDB_SymType Type) { - if (AddrToModuleIndex.empty()) - parseSectionContribs(); - + if (AddrToModuleIndex.empty()) + parseSectionContribs(); + return Cache.findSymbolBySectOffset(Sect, Offset, Type); } @@ -276,14 +276,14 @@ NativeSession::findLineNumbersByAddress(uint64_t Address, std::unique_ptr<IPDBEnumLineNumbers> NativeSession::findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const { - return Cache.findLineNumbersByVA(getLoadAddress() + RVA, Length); + return Cache.findLineNumbersByVA(getLoadAddress() + RVA, Length); } std::unique_ptr<IPDBEnumLineNumbers> NativeSession::findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, uint32_t Length) const { uint64_t VA = getVAFromSectOffset(Section, Offset); - return Cache.findLineNumbersByVA(VA, Length); + return Cache.findLineNumbersByVA(VA, Length); } std::unique_ptr<IPDBEnumSourceFiles> @@ -390,74 +390,74 @@ uint64_t NativeSession::getVAFromSectOffset(uint32_t Section, uint32_t Offset) const { return LoadAddress + getRVAFromSectOffset(Section, Offset); } - -bool NativeSession::moduleIndexForVA(uint64_t VA, uint16_t &ModuleIndex) const { - ModuleIndex = 0; - auto Iter = AddrToModuleIndex.find(VA); - if (Iter == AddrToModuleIndex.end()) - return false; - ModuleIndex = Iter.value(); - return true; -} - -bool NativeSession::moduleIndexForSectOffset(uint32_t Sect, uint32_t Offset, - uint16_t &ModuleIndex) const { - ModuleIndex = 0; - auto Iter = AddrToModuleIndex.find(getVAFromSectOffset(Sect, Offset)); - if (Iter == AddrToModuleIndex.end()) - return false; - ModuleIndex = Iter.value(); - return true; -} - -void NativeSession::parseSectionContribs() { - auto Dbi = Pdb->getPDBDbiStream(); - if (!Dbi) - return; - - class Visitor : public ISectionContribVisitor { - NativeSession &Session; - IMap &AddrMap; - - public: - Visitor(NativeSession &Session, IMap &AddrMap) - : Session(Session), AddrMap(AddrMap) {} - void visit(const SectionContrib &C) override { - if (C.Size == 0) - return; - - uint64_t VA = Session.getVAFromSectOffset(C.ISect, C.Off); - uint64_t End = VA + C.Size; - - // Ignore overlapping sections based on the assumption that a valid - // PDB file should not have overlaps. - if (!AddrMap.overlaps(VA, End)) - AddrMap.insert(VA, End, C.Imod); - } - void visit(const SectionContrib2 &C) override { visit(C.Base); } - }; - - Visitor V(*this, AddrToModuleIndex); - Dbi->visitSectionContributions(V); -} - -Expected<ModuleDebugStreamRef> -NativeSession::getModuleDebugStream(uint32_t Index) const { - auto *Dbi = getDbiStreamPtr(*Pdb); - assert(Dbi && "Dbi stream not present"); - - DbiModuleDescriptor Modi = Dbi->modules().getModuleDescriptor(Index); - - uint16_t ModiStream = Modi.getModuleStreamIndex(); - if (ModiStream == kInvalidStreamIndex) - return make_error<RawError>("Module stream not present"); - - std::unique_ptr<msf::MappedBlockStream> ModStreamData = - Pdb->createIndexedStream(ModiStream); - - ModuleDebugStreamRef ModS(Modi, std::move(ModStreamData)); - if (auto EC = ModS.reload()) - return std::move(EC); - - return std::move(ModS); -} + +bool NativeSession::moduleIndexForVA(uint64_t VA, uint16_t &ModuleIndex) const { + ModuleIndex = 0; + auto Iter = AddrToModuleIndex.find(VA); + if (Iter == AddrToModuleIndex.end()) + return false; + ModuleIndex = Iter.value(); + return true; +} + +bool NativeSession::moduleIndexForSectOffset(uint32_t Sect, uint32_t Offset, + uint16_t &ModuleIndex) const { + ModuleIndex = 0; + auto Iter = AddrToModuleIndex.find(getVAFromSectOffset(Sect, Offset)); + if (Iter == AddrToModuleIndex.end()) + return false; + ModuleIndex = Iter.value(); + return true; +} + +void NativeSession::parseSectionContribs() { + auto Dbi = Pdb->getPDBDbiStream(); + if (!Dbi) + return; + + class Visitor : public ISectionContribVisitor { + NativeSession &Session; + IMap &AddrMap; + + public: + Visitor(NativeSession &Session, IMap &AddrMap) + : Session(Session), AddrMap(AddrMap) {} + void visit(const SectionContrib &C) override { + if (C.Size == 0) + return; + + uint64_t VA = Session.getVAFromSectOffset(C.ISect, C.Off); + uint64_t End = VA + C.Size; + + // Ignore overlapping sections based on the assumption that a valid + // PDB file should not have overlaps. + if (!AddrMap.overlaps(VA, End)) + AddrMap.insert(VA, End, C.Imod); + } + void visit(const SectionContrib2 &C) override { visit(C.Base); } + }; + + Visitor V(*this, AddrToModuleIndex); + Dbi->visitSectionContributions(V); +} + +Expected<ModuleDebugStreamRef> +NativeSession::getModuleDebugStream(uint32_t Index) const { + auto *Dbi = getDbiStreamPtr(*Pdb); + assert(Dbi && "Dbi stream not present"); + + DbiModuleDescriptor Modi = Dbi->modules().getModuleDescriptor(Index); + + uint16_t ModiStream = Modi.getModuleStreamIndex(); + if (ModiStream == kInvalidStreamIndex) + return make_error<RawError>("Module stream not present"); + + std::unique_ptr<msf::MappedBlockStream> ModStreamData = + Pdb->createIndexedStream(ModiStream); + + ModuleDebugStreamRef ModS(Modi, std::move(ModStreamData)); + if (auto EC = ModS.reload()) + return std::move(EC); + + return std::move(ModS); +} diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSourceFile.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSourceFile.cpp index e494635182..fd813dee6b 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSourceFile.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSourceFile.cpp @@ -1,4 +1,4 @@ -//===- NativeSourceFile.cpp - Native line number implementation -*- C++ -*-===// +//===- NativeSourceFile.cpp - Native line number implementation -*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp index 401efc0511..917ec14e58 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp @@ -120,7 +120,7 @@ PDB_UdtType NativeTypeUDT::getUdtKind() const { case TypeRecordKind::Interface: return PDB_UdtType::Interface; default: - llvm_unreachable("Unexpected udt kind"); + llvm_unreachable("Unexpected udt kind"); } } diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/SymbolCache.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/SymbolCache.cpp index 5bf434f845..fd9a0deb54 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/SymbolCache.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/SymbolCache.cpp @@ -1,6 +1,6 @@ #include "llvm/DebugInfo/PDB/Native/SymbolCache.h" -#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h" #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h" #include "llvm/DebugInfo/CodeView/TypeDeserializer.h" @@ -11,10 +11,10 @@ #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h" #include "llvm/DebugInfo/PDB/Native/NativeEnumGlobals.h" #include "llvm/DebugInfo/PDB/Native/NativeEnumLineNumbers.h" -#include "llvm/DebugInfo/PDB/Native/NativeEnumSymbols.h" +#include "llvm/DebugInfo/PDB/Native/NativeEnumSymbols.h" #include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h" #include "llvm/DebugInfo/PDB/Native/NativeFunctionSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeInlineSiteSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeInlineSiteSymbol.h" #include "llvm/DebugInfo/PDB/Native/NativePublicSymbol.h" #include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" #include "llvm/DebugInfo/PDB/Native/NativeSession.h" @@ -71,7 +71,7 @@ static const struct BuiltinTypeEntry { }; SymbolCache::SymbolCache(NativeSession &Session, DbiStream *Dbi) - : Session(Session), Dbi(Dbi) { + : Session(Session), Dbi(Dbi) { // Id 0 is reserved for the invalid symbol. Cache.push_back(nullptr); SourceFiles.push_back(nullptr); @@ -104,15 +104,15 @@ SymbolCache::createGlobalsEnumerator(codeview::SymbolKind Kind) { } SymIndexId SymbolCache::createSimpleType(TypeIndex Index, - ModifierOptions Mods) const { + ModifierOptions Mods) const { if (Index.getSimpleMode() != codeview::SimpleTypeMode::Direct) return createSymbol<NativeTypePointer>(Index); const auto Kind = Index.getSimpleKind(); - const auto It = - llvm::find_if(BuiltinTypes, [Kind](const BuiltinTypeEntry &Builtin) { - return Builtin.Kind == Kind; - }); + const auto It = + llvm::find_if(BuiltinTypes, [Kind](const BuiltinTypeEntry &Builtin) { + return Builtin.Kind == Kind; + }); if (It == std::end(BuiltinTypes)) return 0; return createSymbol<NativeTypeBuiltin>(Mods, It->Type, It->Size); @@ -120,7 +120,7 @@ SymIndexId SymbolCache::createSimpleType(TypeIndex Index, SymIndexId SymbolCache::createSymbolForModifiedType(codeview::TypeIndex ModifierTI, - codeview::CVType CVT) const { + codeview::CVType CVT) const { ModifierRecord Record; if (auto EC = TypeDeserializer::deserializeAs<ModifierRecord>(CVT, Record)) { consumeError(std::move(EC)); @@ -150,7 +150,7 @@ SymbolCache::createSymbolForModifiedType(codeview::TypeIndex ModifierTI, return 0; } -SymIndexId SymbolCache::findSymbolByTypeIndex(codeview::TypeIndex Index) const { +SymIndexId SymbolCache::findSymbolByTypeIndex(codeview::TypeIndex Index) const { // First see if it's already in our cache. const auto Entry = TypeIndexToSymbolId.find(Index); if (Entry != TypeIndexToSymbolId.end()) @@ -247,7 +247,7 @@ SymbolCache::getSymbolById(SymIndexId SymbolId) const { return nullptr; // Make sure to handle the case where we've inserted a placeholder symbol - // for types we don't yet support. + // for types we don't yet support. NativeRawSymbol *NRS = Cache[SymbolId].get(); if (!NRS) return nullptr; @@ -292,17 +292,17 @@ SymIndexId SymbolCache::getOrCreateGlobalSymbolByOffset(uint32_t Offset) { return Id; } -SymIndexId SymbolCache::getOrCreateInlineSymbol(InlineSiteSym Sym, - uint64_t ParentAddr, - uint16_t Modi, - uint32_t RecordOffset) const { - auto Iter = SymTabOffsetToSymbolId.find({Modi, RecordOffset}); - if (Iter != SymTabOffsetToSymbolId.end()) - return Iter->second; - - SymIndexId Id = createSymbol<NativeInlineSiteSymbol>(Sym, ParentAddr); - SymTabOffsetToSymbolId.insert({{Modi, RecordOffset}, Id}); - return Id; +SymIndexId SymbolCache::getOrCreateInlineSymbol(InlineSiteSym Sym, + uint64_t ParentAddr, + uint16_t Modi, + uint32_t RecordOffset) const { + auto Iter = SymTabOffsetToSymbolId.find({Modi, RecordOffset}); + if (Iter != SymTabOffsetToSymbolId.end()) + return Iter->second; + + SymIndexId Id = createSymbol<NativeInlineSiteSymbol>(Sym, ParentAddr); + SymTabOffsetToSymbolId.insert({{Modi, RecordOffset}, Id}); + return Id; } std::unique_ptr<PDBSymbol> @@ -313,15 +313,15 @@ SymbolCache::findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, return findFunctionSymbolBySectOffset(Sect, Offset); case PDB_SymType::PublicSymbol: return findPublicSymbolBySectOffset(Sect, Offset); - case PDB_SymType::Compiland: { - uint16_t Modi; - if (!Session.moduleIndexForSectOffset(Sect, Offset, Modi)) - return nullptr; - return getOrCreateCompiland(Modi); - } + case PDB_SymType::Compiland: { + uint16_t Modi; + if (!Session.moduleIndexForSectOffset(Sect, Offset, Modi)) + return nullptr; + return getOrCreateCompiland(Modi); + } case PDB_SymType::None: { - // FIXME: Implement for PDB_SymType::Data. The symbolizer calls this but - // only uses it to find the symbol length. + // FIXME: Implement for PDB_SymType::Data. The symbolizer calls this but + // only uses it to find the symbol length. if (auto Sym = findFunctionSymbolBySectOffset(Sect, Offset)) return Sym; return nullptr; @@ -333,19 +333,19 @@ SymbolCache::findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, std::unique_ptr<PDBSymbol> SymbolCache::findFunctionSymbolBySectOffset(uint32_t Sect, uint32_t Offset) { - auto Iter = AddressToSymbolId.find({Sect, Offset}); - if (Iter != AddressToSymbolId.end()) + auto Iter = AddressToSymbolId.find({Sect, Offset}); + if (Iter != AddressToSymbolId.end()) return getSymbolById(Iter->second); if (!Dbi) return nullptr; - uint16_t Modi; - if (!Session.moduleIndexForSectOffset(Sect, Offset, Modi)) + uint16_t Modi; + if (!Session.moduleIndexForSectOffset(Sect, Offset, Modi)) return nullptr; - Expected<ModuleDebugStreamRef> ExpectedModS = - Session.getModuleDebugStream(Modi); + Expected<ModuleDebugStreamRef> ExpectedModS = + Session.getModuleDebugStream(Modi); if (!ExpectedModS) { consumeError(ExpectedModS.takeError()); return nullptr; @@ -359,14 +359,14 @@ SymbolCache::findFunctionSymbolBySectOffset(uint32_t Sect, uint32_t Offset) { auto PS = cantFail(SymbolDeserializer::deserializeAs<ProcSym>(*I)); if (Sect == PS.Segment && Offset >= PS.CodeOffset && Offset < PS.CodeOffset + PS.CodeSize) { - // Check if the symbol is already cached. - auto Found = AddressToSymbolId.find({PS.Segment, PS.CodeOffset}); - if (Found != AddressToSymbolId.end()) - return getSymbolById(Found->second); - - // Otherwise, create a new symbol. - SymIndexId Id = createSymbol<NativeFunctionSymbol>(PS, I.offset()); - AddressToSymbolId.insert({{PS.Segment, PS.CodeOffset}, Id}); + // Check if the symbol is already cached. + auto Found = AddressToSymbolId.find({PS.Segment, PS.CodeOffset}); + if (Found != AddressToSymbolId.end()) + return getSymbolById(Found->second); + + // Otherwise, create a new symbol. + SymIndexId Id = createSymbol<NativeFunctionSymbol>(PS, I.offset()); + AddressToSymbolId.insert({{PS.Segment, PS.CodeOffset}, Id}); return getSymbolById(Id); } @@ -426,16 +426,16 @@ SymbolCache::findPublicSymbolBySectOffset(uint32_t Sect, uint32_t Offset) { consumeError(Sym.takeError()); return nullptr; } - - // Check if the symbol is already cached. + + // Check if the symbol is already cached. auto PS = cantFail(SymbolDeserializer::deserializeAs<PublicSym32>(Sym.get())); - auto Found = AddressToPublicSymId.find({PS.Segment, PS.Offset}); - if (Found != AddressToPublicSymId.end()) - return getSymbolById(Found->second); - - // Otherwise, create a new symbol. + auto Found = AddressToPublicSymId.find({PS.Segment, PS.Offset}); + if (Found != AddressToPublicSymId.end()) + return getSymbolById(Found->second); + + // Otherwise, create a new symbol. SymIndexId Id = createSymbol<NativePublicSymbol>(PS); - AddressToPublicSymId.insert({{PS.Segment, PS.Offset}, Id}); + AddressToPublicSymId.insert({{PS.Segment, PS.Offset}, Id}); return getSymbolById(Id); } @@ -450,8 +450,8 @@ SymbolCache::findLineTable(uint16_t Modi) const { // If there is an error or there are no lines, just return the // empty vector. - Expected<ModuleDebugStreamRef> ExpectedModS = - Session.getModuleDebugStream(Modi); + Expected<ModuleDebugStreamRef> ExpectedModS = + Session.getModuleDebugStream(Modi); if (!ExpectedModS) { consumeError(ExpectedModS.takeError()); return ModuleLineTable; @@ -482,19 +482,19 @@ SymbolCache::findLineTable(uint16_t Modi) const { auto ColIt = Group.Columns.begin(); auto ColsEnd = Group.Columns.end(); - // Add a line to mark the beginning of this section. - uint64_t StartAddr = - Session.getVAFromSectOffset(RelocSegment, RelocOffset); - LineInfo FirstLine(Group.LineNumbers.front().Flags); - uint32_t ColNum = - (Lines.hasColumnInfo()) ? Group.Columns.front().StartColumn : 0; - Entries.push_back({StartAddr, FirstLine, ColNum, Group.NameIndex, false}); - + // Add a line to mark the beginning of this section. + uint64_t StartAddr = + Session.getVAFromSectOffset(RelocSegment, RelocOffset); + LineInfo FirstLine(Group.LineNumbers.front().Flags); + uint32_t ColNum = + (Lines.hasColumnInfo()) ? Group.Columns.front().StartColumn : 0; + Entries.push_back({StartAddr, FirstLine, ColNum, Group.NameIndex, false}); + for (const LineNumberEntry &LN : Group.LineNumbers) { uint64_t VA = Session.getVAFromSectOffset(RelocSegment, RelocOffset + LN.Offset); LineInfo Line(LN.Flags); - ColNum = 0; + ColNum = 0; if (Lines.hasColumnInfo() && ColIt != ColsEnd) { ColNum = ColIt->StartColumn; @@ -504,30 +504,30 @@ SymbolCache::findLineTable(uint16_t Modi) const { } // Add a terminal entry line to mark the end of this subsection. - uint64_t EndAddr = StartAddr + Lines.header()->CodeSize; + uint64_t EndAddr = StartAddr + Lines.header()->CodeSize; LineInfo LastLine(Group.LineNumbers.back().Flags); - ColNum = (Lines.hasColumnInfo()) ? Group.Columns.back().StartColumn : 0; - Entries.push_back({EndAddr, LastLine, ColNum, Group.NameIndex, true}); + ColNum = (Lines.hasColumnInfo()) ? Group.Columns.back().StartColumn : 0; + Entries.push_back({EndAddr, LastLine, ColNum, Group.NameIndex, true}); EntryList.push_back(Entries); } } // Sort EntryList, and add flattened contents to the line table. - llvm::sort(EntryList, [](const std::vector<LineTableEntry> &LHS, - const std::vector<LineTableEntry> &RHS) { - return LHS[0].Addr < RHS[0].Addr; - }); + llvm::sort(EntryList, [](const std::vector<LineTableEntry> &LHS, + const std::vector<LineTableEntry> &RHS) { + return LHS[0].Addr < RHS[0].Addr; + }); for (size_t I = 0; I < EntryList.size(); ++I) - llvm::append_range(ModuleLineTable, EntryList[I]); + llvm::append_range(ModuleLineTable, EntryList[I]); return ModuleLineTable; } std::unique_ptr<IPDBEnumLineNumbers> SymbolCache::findLineNumbersByVA(uint64_t VA, uint32_t Length) const { - uint16_t Modi; - if (!Session.moduleIndexForVA(VA, Modi)) + uint16_t Modi; + if (!Session.moduleIndexForVA(VA, Modi)) return nullptr; std::vector<LineTableEntry> Lines = findLineTable(Modi); @@ -547,8 +547,8 @@ SymbolCache::findLineNumbersByVA(uint64_t VA, uint32_t Length) const { --LineIter; } - Expected<ModuleDebugStreamRef> ExpectedModS = - Session.getModuleDebugStream(Modi); + Expected<ModuleDebugStreamRef> ExpectedModS = + Session.getModuleDebugStream(Modi); if (!ExpectedModS) { consumeError(ExpectedModS.takeError()); return nullptr; @@ -563,7 +563,7 @@ SymbolCache::findLineNumbersByVA(uint64_t VA, uint32_t Length) const { // Populate a vector of NativeLineNumbers that have addresses in the given // address range. std::vector<NativeLineNumber> LineNumbers; - while (LineIter != Lines.end()) { + while (LineIter != Lines.end()) { if (LineIter->IsTerminalEntry) { ++LineIter; continue; @@ -581,7 +581,7 @@ SymbolCache::findLineNumbersByVA(uint64_t VA, uint32_t Length) const { ExpectedChecksums->getArray().at(LineIter->FileNameIndex); uint32_t SrcFileId = getOrCreateSourceFile(*ChecksumIter); NativeLineNumber LineNum(Session, LineIter->Line, LineIter->ColumnNumber, - LineSect, LineOff, LineLength, SrcFileId, Modi); + LineSect, LineOff, LineLength, SrcFileId, Modi); LineNumbers.push_back(LineNum); ++LineIter; } diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp index da44463f39..5f4f497690 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp @@ -25,7 +25,7 @@ #include "llvm/Support/Error.h" #include <algorithm> #include <cstdint> -#include <numeric> +#include <numeric> using namespace llvm; using namespace llvm::msf; @@ -42,58 +42,58 @@ void TpiStreamBuilder::setVersionHeader(PdbRaw_TpiVer Version) { VerHeader = Version; } -void TpiStreamBuilder::updateTypeIndexOffsets(ArrayRef<uint16_t> Sizes) { - // If we just crossed an 8KB threshold, add a type index offset. - for (uint16_t Size : Sizes) { - size_t NewSize = TypeRecordBytes + Size; - constexpr size_t EightKB = 8 * 1024; - if (NewSize / EightKB > TypeRecordBytes / EightKB || TypeRecordCount == 0) { - TypeIndexOffsets.push_back( - {codeview::TypeIndex(codeview::TypeIndex::FirstNonSimpleIndex + - TypeRecordCount), - ulittle32_t(TypeRecordBytes)}); - } - ++TypeRecordCount; - TypeRecordBytes = NewSize; - } -} - +void TpiStreamBuilder::updateTypeIndexOffsets(ArrayRef<uint16_t> Sizes) { + // If we just crossed an 8KB threshold, add a type index offset. + for (uint16_t Size : Sizes) { + size_t NewSize = TypeRecordBytes + Size; + constexpr size_t EightKB = 8 * 1024; + if (NewSize / EightKB > TypeRecordBytes / EightKB || TypeRecordCount == 0) { + TypeIndexOffsets.push_back( + {codeview::TypeIndex(codeview::TypeIndex::FirstNonSimpleIndex + + TypeRecordCount), + ulittle32_t(TypeRecordBytes)}); + } + ++TypeRecordCount; + TypeRecordBytes = NewSize; + } +} + void TpiStreamBuilder::addTypeRecord(ArrayRef<uint8_t> Record, Optional<uint32_t> Hash) { assert(((Record.size() & 3) == 0) && "The type record's size is not a multiple of 4 bytes which will " "cause misalignment in the output TPI stream!"); - assert(Record.size() <= codeview::MaxRecordLength); - uint16_t OneSize = (uint16_t)Record.size(); - updateTypeIndexOffsets(makeArrayRef(&OneSize, 1)); + assert(Record.size() <= codeview::MaxRecordLength); + uint16_t OneSize = (uint16_t)Record.size(); + updateTypeIndexOffsets(makeArrayRef(&OneSize, 1)); - TypeRecBuffers.push_back(Record); - // FIXME: Require it. + TypeRecBuffers.push_back(Record); + // FIXME: Require it. if (Hash) TypeHashes.push_back(*Hash); } -void TpiStreamBuilder::addTypeRecords(ArrayRef<uint8_t> Types, - ArrayRef<uint16_t> Sizes, - ArrayRef<uint32_t> Hashes) { - // Ignore empty type buffers. There should be no hashes or sizes in this case. - if (Types.empty()) { - assert(Sizes.empty() && Hashes.empty()); - return; - } - - assert(((Types.size() & 3) == 0) && - "The type record's size is not a multiple of 4 bytes which will " - "cause misalignment in the output TPI stream!"); - assert(Sizes.size() == Hashes.size() && "sizes and hashes should be in sync"); - assert(std::accumulate(Sizes.begin(), Sizes.end(), 0U) == Types.size() && - "sizes of type records should sum to the size of the types"); - updateTypeIndexOffsets(Sizes); - - TypeRecBuffers.push_back(Types); - llvm::append_range(TypeHashes, Hashes); -} - +void TpiStreamBuilder::addTypeRecords(ArrayRef<uint8_t> Types, + ArrayRef<uint16_t> Sizes, + ArrayRef<uint32_t> Hashes) { + // Ignore empty type buffers. There should be no hashes or sizes in this case. + if (Types.empty()) { + assert(Sizes.empty() && Hashes.empty()); + return; + } + + assert(((Types.size() & 3) == 0) && + "The type record's size is not a multiple of 4 bytes which will " + "cause misalignment in the output TPI stream!"); + assert(Sizes.size() == Hashes.size() && "sizes and hashes should be in sync"); + assert(std::accumulate(Sizes.begin(), Sizes.end(), 0U) == Types.size() && + "sizes of type records should sum to the size of the types"); + updateTypeIndexOffsets(Sizes); + + TypeRecBuffers.push_back(Types); + llvm::append_range(TypeHashes, Hashes); +} + Error TpiStreamBuilder::finalize() { if (Header) return Error::success(); @@ -103,7 +103,7 @@ Error TpiStreamBuilder::finalize() { H->Version = VerHeader; H->HeaderSize = sizeof(TpiStreamHeader); H->TypeIndexBegin = codeview::TypeIndex::FirstNonSimpleIndex; - H->TypeIndexEnd = H->TypeIndexBegin + TypeRecordCount; + H->TypeIndexEnd = H->TypeIndexBegin + TypeRecordCount; H->TypeRecordBytes = TypeRecordBytes; H->HashStreamIndex = HashStreamIndex; @@ -134,7 +134,7 @@ uint32_t TpiStreamBuilder::calculateSerializedLength() { } uint32_t TpiStreamBuilder::calculateHashBufferSize() const { - assert((TypeRecordCount == TypeHashes.size() || TypeHashes.empty()) && + assert((TypeRecordCount == TypeHashes.size() || TypeHashes.empty()) && "either all or no type records should have hashes"); return TypeHashes.size() * sizeof(ulittle32_t); } @@ -185,7 +185,7 @@ Error TpiStreamBuilder::commit(const msf::MSFLayout &Layout, if (auto EC = Writer.writeObject(*Header)) return EC; - for (auto Rec : TypeRecBuffers) { + for (auto Rec : TypeRecBuffers) { assert(!Rec.empty() && "Attempting to write an empty type record shifts " "all offsets in the TPI stream!"); assert(((Rec.size() & 3) == 0) && diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/PDB.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/PDB.cpp index 50e48bfbdb..6dc42715fb 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/PDB.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/PDB.cpp @@ -11,7 +11,7 @@ #include "llvm/Config/config.h" #include "llvm/DebugInfo/PDB/GenericError.h" #if LLVM_ENABLE_DIA_SDK -#error #include "llvm/DebugInfo/PDB/DIA/DIASession.h" +#error #include "llvm/DebugInfo/PDB/DIA/DIASession.h" #endif #include "llvm/DebugInfo/PDB/Native/NativeSession.h" #include "llvm/Support/Error.h" diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBContext.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBContext.cpp index 2fca37dd38..0ebb70e010 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBContext.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBContext.cpp @@ -86,43 +86,43 @@ DIInliningInfo PDBContext::getInliningInfoForAddress(object::SectionedAddress Address, DILineInfoSpecifier Specifier) { DIInliningInfo InlineInfo; - DILineInfo CurrentLine = getLineInfoForAddress(Address, Specifier); - - // Find the function at this address. - std::unique_ptr<PDBSymbol> ParentFunc = - Session->findSymbolByAddress(Address.Address, PDB_SymType::Function); - if (!ParentFunc) { - InlineInfo.addFrame(CurrentLine); - return InlineInfo; - } - - auto Frames = ParentFunc->findInlineFramesByVA(Address.Address); - if (!Frames || Frames->getChildCount() == 0) { - InlineInfo.addFrame(CurrentLine); - return InlineInfo; - } - - while (auto Frame = Frames->getNext()) { - uint32_t Length = 1; - auto LineNumbers = Frame->findInlineeLinesByVA(Address.Address, Length); - if (!LineNumbers || LineNumbers->getChildCount() == 0) - break; - - std::unique_ptr<IPDBLineNumber> Line = LineNumbers->getNext(); - assert(Line); - - DILineInfo LineInfo; - LineInfo.FunctionName = Frame->getName(); - auto SourceFile = Session->getSourceFileById(Line->getSourceFileId()); - if (SourceFile && - Specifier.FLIKind != DILineInfoSpecifier::FileLineInfoKind::None) - LineInfo.FileName = SourceFile->getFileName(); - LineInfo.Line = Line->getLineNumber(); - LineInfo.Column = Line->getColumnNumber(); - InlineInfo.addFrame(LineInfo); - } - - InlineInfo.addFrame(CurrentLine); + DILineInfo CurrentLine = getLineInfoForAddress(Address, Specifier); + + // Find the function at this address. + std::unique_ptr<PDBSymbol> ParentFunc = + Session->findSymbolByAddress(Address.Address, PDB_SymType::Function); + if (!ParentFunc) { + InlineInfo.addFrame(CurrentLine); + return InlineInfo; + } + + auto Frames = ParentFunc->findInlineFramesByVA(Address.Address); + if (!Frames || Frames->getChildCount() == 0) { + InlineInfo.addFrame(CurrentLine); + return InlineInfo; + } + + while (auto Frame = Frames->getNext()) { + uint32_t Length = 1; + auto LineNumbers = Frame->findInlineeLinesByVA(Address.Address, Length); + if (!LineNumbers || LineNumbers->getChildCount() == 0) + break; + + std::unique_ptr<IPDBLineNumber> Line = LineNumbers->getNext(); + assert(Line); + + DILineInfo LineInfo; + LineInfo.FunctionName = Frame->getName(); + auto SourceFile = Session->getSourceFileById(Line->getSourceFileId()); + if (SourceFile && + Specifier.FLIKind != DILineInfoSpecifier::FileLineInfoKind::None) + LineInfo.FileName = SourceFile->getFileName(); + LineInfo.Line = Line->getLineNumber(); + LineInfo.Column = Line->getColumnNumber(); + InlineInfo.addFrame(LineInfo); + } + + InlineInfo.addFrame(CurrentLine); return InlineInfo; } diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBExtras.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBExtras.cpp index 1be88c16a5..25962e5152 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBExtras.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBExtras.cpp @@ -118,22 +118,22 @@ raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_DataKind &Data) { raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const llvm::codeview::CPURegister &CpuReg) { - if (CpuReg.Cpu == llvm::codeview::CPUType::ARMNT) { + if (CpuReg.Cpu == llvm::codeview::CPUType::ARMNT) { + switch (CpuReg.Reg) { +#define CV_REGISTERS_ARM +#define CV_REGISTER(name, val) \ + case codeview::RegisterId::name: \ + OS << #name; \ + return OS; +#include "llvm/DebugInfo/CodeView/CodeViewRegisters.def" +#undef CV_REGISTER +#undef CV_REGISTERS_ARM + + default: + break; + } + } else if (CpuReg.Cpu == llvm::codeview::CPUType::ARM64) { switch (CpuReg.Reg) { -#define CV_REGISTERS_ARM -#define CV_REGISTER(name, val) \ - case codeview::RegisterId::name: \ - OS << #name; \ - return OS; -#include "llvm/DebugInfo/CodeView/CodeViewRegisters.def" -#undef CV_REGISTER -#undef CV_REGISTERS_ARM - - default: - break; - } - } else if (CpuReg.Cpu == llvm::codeview::CPUType::ARM64) { - switch (CpuReg.Reg) { #define CV_REGISTERS_ARM64 #define CV_REGISTER(name, val) \ case codeview::RegisterId::name: \ diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp index 325e937dac..d51091d809 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp @@ -1,4 +1,4 @@ -//===- PDBInterfaceAnchors.h - defines class anchor functions ---*- C++ -*-===// +//===- PDBInterfaceAnchors.h - defines class anchor functions ---*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// // Class anchors are necessary per the LLVM Coding style guide, to ensure that // the vtable is only generated in this object file, and not in every object -// file that includes the corresponding header. +// file that includes the corresponding header. //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/PDB/IPDBDataStream.h" diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBSymbol.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBSymbol.cpp index c60065b9cc..d6bc7ee9c9 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBSymbol.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/PDBSymbol.cpp @@ -161,27 +161,27 @@ PDBSymbol::findChildrenByRVA(PDB_SymType Type, StringRef Name, } std::unique_ptr<IPDBEnumSymbols> -PDBSymbol::findInlineFramesByVA(uint64_t VA) const { - return RawSymbol->findInlineFramesByVA(VA); -} - -std::unique_ptr<IPDBEnumSymbols> +PDBSymbol::findInlineFramesByVA(uint64_t VA) const { + return RawSymbol->findInlineFramesByVA(VA); +} + +std::unique_ptr<IPDBEnumSymbols> PDBSymbol::findInlineFramesByRVA(uint32_t RVA) const { return RawSymbol->findInlineFramesByRVA(RVA); } -std::unique_ptr<IPDBEnumLineNumbers> -PDBSymbol::findInlineeLinesByVA(uint64_t VA, uint32_t Length) const { - return RawSymbol->findInlineeLinesByVA(VA, Length); -} - -std::unique_ptr<IPDBEnumLineNumbers> -PDBSymbol::findInlineeLinesByRVA(uint32_t RVA, uint32_t Length) const { - return RawSymbol->findInlineeLinesByRVA(RVA, Length); -} - -std::string PDBSymbol::getName() const { return RawSymbol->getName(); } - +std::unique_ptr<IPDBEnumLineNumbers> +PDBSymbol::findInlineeLinesByVA(uint64_t VA, uint32_t Length) const { + return RawSymbol->findInlineeLinesByVA(VA, Length); +} + +std::unique_ptr<IPDBEnumLineNumbers> +PDBSymbol::findInlineeLinesByRVA(uint32_t RVA, uint32_t Length) const { + return RawSymbol->findInlineeLinesByRVA(RVA, Length); +} + +std::string PDBSymbol::getName() const { return RawSymbol->getName(); } + std::unique_ptr<IPDBEnumSymbols> PDBSymbol::getChildStats(TagStats &Stats) const { std::unique_ptr<IPDBEnumSymbols> Result(findAllChildren()); diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/UDTLayout.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/UDTLayout.cpp index b6e5fe2612..55854bb498 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/UDTLayout.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/UDTLayout.cpp @@ -289,10 +289,10 @@ void UDTLayoutBase::addChildToLayout(std::unique_ptr<LayoutItemBase> Child) { UsedBytes |= ChildBytes; if (ChildBytes.count() > 0) { - auto Loc = llvm::upper_bound( - LayoutItems, Begin, [](uint32_t Off, const LayoutItemBase *Item) { - return (Off < Item->getOffsetInParent()); - }); + auto Loc = llvm::upper_bound( + LayoutItems, Begin, [](uint32_t Off, const LayoutItemBase *Item) { + return (Off < Item->getOffsetInParent()); + }); LayoutItems.insert(Loc, Child.get()); } diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/ya.make b/contrib/libs/llvm12/lib/DebugInfo/PDB/ya.make index 6a5df3009b..daa2f8ed3a 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/ya.make +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/ya.make @@ -12,12 +12,12 @@ 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/DebugInfo/CodeView - contrib/libs/llvm12/lib/DebugInfo/MSF - contrib/libs/llvm12/lib/Object - contrib/libs/llvm12/lib/Support + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support ) ADDINCL( @@ -51,11 +51,11 @@ SRCS( Native/NativeEnumInjectedSources.cpp Native/NativeEnumLineNumbers.cpp Native/NativeEnumModules.cpp - Native/NativeEnumSymbols.cpp + Native/NativeEnumSymbols.cpp Native/NativeEnumTypes.cpp Native/NativeExeSymbol.cpp Native/NativeFunctionSymbol.cpp - Native/NativeInlineSiteSymbol.cpp + Native/NativeInlineSiteSymbol.cpp Native/NativeLineNumber.cpp Native/NativePublicSymbol.cpp Native/NativeRawSymbol.cpp diff --git a/contrib/libs/llvm12/lib/DebugInfo/Symbolize/DIPrinter.cpp b/contrib/libs/llvm12/lib/DebugInfo/Symbolize/DIPrinter.cpp index fdcaa702c7..01dc31d849 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/Symbolize/DIPrinter.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/Symbolize/DIPrinter.cpp @@ -84,10 +84,10 @@ void DIPrinter::print(const DILineInfo &Info, bool Inlined) { return; } OS << " Filename: " << Filename << "\n"; - if (Info.StartLine) { - OS << " Function start filename: " << Info.StartFileName << "\n"; - OS << " Function start line: " << Info.StartLine << "\n"; - } + if (Info.StartLine) { + OS << " Function start filename: " << Info.StartFileName << "\n"; + OS << " Function start line: " << Info.StartLine << "\n"; + } OS << " Line: " << Info.Line << "\n"; OS << " Column: " << Info.Column << "\n"; if (Info.Discriminator) diff --git a/contrib/libs/llvm12/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h b/contrib/libs/llvm12/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h index a04ff84ac9..be3c66df05 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h +++ b/contrib/libs/llvm12/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h @@ -15,12 +15,12 @@ #include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/Symbolize/SymbolizableModule.h" -#include "llvm/Support/Error.h" +#include "llvm/Support/Error.h" #include <cstdint> #include <memory> #include <string> -#include <utility> -#include <vector> +#include <utility> +#include <vector> namespace llvm { diff --git a/contrib/libs/llvm12/lib/DebugInfo/Symbolize/Symbolize.cpp b/contrib/libs/llvm12/lib/DebugInfo/Symbolize/Symbolize.cpp index 4168f8118c..da157a5a25 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/Symbolize/Symbolize.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/Symbolize/Symbolize.cpp @@ -16,7 +16,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/BinaryFormat/COFF.h" -#include "llvm/Config/config.h" +#include "llvm/Config/config.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/PDB/PDB.h" #include "llvm/DebugInfo/PDB/PDBContext.h" @@ -287,8 +287,8 @@ bool darwinDsymMatchesBinary(const MachOObjectFile *DbgObj, } template <typename ELFT> -Optional<ArrayRef<uint8_t>> getBuildID(const ELFFile<ELFT> &Obj) { - auto PhdrsOrErr = Obj.program_headers(); +Optional<ArrayRef<uint8_t>> getBuildID(const ELFFile<ELFT> &Obj) { + auto PhdrsOrErr = Obj.program_headers(); if (!PhdrsOrErr) { consumeError(PhdrsOrErr.takeError()); return {}; @@ -297,7 +297,7 @@ Optional<ArrayRef<uint8_t>> getBuildID(const ELFFile<ELFT> &Obj) { if (P.p_type != ELF::PT_NOTE) continue; Error Err = Error::success(); - for (auto N : Obj.notes(P, Err)) + for (auto N : Obj.notes(P, Err)) if (N.getType() == ELF::NT_GNU_BUILD_ID && N.getName() == ELF::ELF_NOTE_GNU) return N.getDesc(); consumeError(std::move(Err)); @@ -554,9 +554,9 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) { if (!EC && DebugInfo != nullptr && !PDBFileName.empty()) { using namespace pdb; std::unique_ptr<IPDBSession> Session; - - PDB_ReaderType ReaderType = - Opts.UseDIA ? PDB_ReaderType::DIA : PDB_ReaderType::Native; + + PDB_ReaderType ReaderType = + Opts.UseDIA ? PDB_ReaderType::DIA : PDB_ReaderType::Native; if (auto Err = loadDataForEXE(ReaderType, Objects.first->getFileName(), Session)) { Modules.emplace(ModuleName, std::unique_ptr<SymbolizableModule>()); @@ -589,7 +589,7 @@ StringRef demanglePE32ExternCFunc(StringRef SymbolName) { if (Front != '?') { size_t AtPos = SymbolName.rfind('@'); if (AtPos != StringRef::npos && - all_of(drop_begin(SymbolName, AtPos + 1), isDigit)) + all_of(drop_begin(SymbolName, AtPos + 1), isDigit)) SymbolName = SymbolName.substr(0, AtPos); } diff --git a/contrib/libs/llvm12/lib/DebugInfo/Symbolize/ya.make b/contrib/libs/llvm12/lib/DebugInfo/Symbolize/ya.make index 487d1503c8..b627533f82 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/Symbolize/ya.make +++ b/contrib/libs/llvm12/lib/DebugInfo/Symbolize/ya.make @@ -12,12 +12,12 @@ LICENSE(Apache-2.0 WITH LLVM-exception) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) PEERDIR( - contrib/libs/llvm12 - contrib/libs/llvm12/lib/DebugInfo/DWARF - contrib/libs/llvm12/lib/DebugInfo/PDB - contrib/libs/llvm12/lib/Demangle - contrib/libs/llvm12/lib/Object - contrib/libs/llvm12/lib/Support + contrib/libs/llvm12 + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/PDB + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support ) ADDINCL( |