35 if (DwarfVersion <= 4)
45 bool IsLittleEndian) {
62 std::optional<int64_t> ImplicitConst;
67 " not found in abbrev section");
73 if (Form == dwarf::DW_FORM_string)
74 return InfoData.
getCStr(&InfoOffset);
77 case dwarf::DW_FORM_strx1:
78 StrIndex = InfoData.
getU8(&InfoOffset);
80 case dwarf::DW_FORM_strx2:
81 StrIndex = InfoData.
getU16(&InfoOffset);
83 case dwarf::DW_FORM_strx3:
84 StrIndex = InfoData.
getU24(&InfoOffset);
86 case dwarf::DW_FORM_strx4:
87 StrIndex = InfoData.
getU32(&InfoOffset);
89 case dwarf::DW_FORM_strx:
90 case dwarf::DW_FORM_GNU_str_index:
95 "string field must be encoded with one of the following: "
96 "DW_FORM_string, DW_FORM_strx, DW_FORM_strx1, DW_FORM_strx2, "
97 "DW_FORM_strx3, DW_FORM_strx4, or DW_FORM_GNU_str_index.");
100 uint64_t StrOffsetsOffset = 4 * StrIndex;
105 return StrData.
getCStr(&StrOffset);
111 bool IsLittleEndian) {
114 if (Header.Version >= 5 && Header.UnitType != dwarf::DW_UT_split_compile)
116 std::string(
"unit type DW_UT_split_compile type not found in "
117 "debug_info header. Unexpected unit type 0x" +
118 utostr(Header.UnitType) +
" found"));
126 if (!AbbrevOffsetOrErr)
128 uint64_t AbbrevOffset = *AbbrevOffsetOrErr;
130 if (Tag != dwarf::DW_TAG_compile_unit)
133 AbbrevData.
getU8(&AbbrevOffset);
136 std::optional<int64_t> ImplicitConst;
140 case dwarf::DW_AT_name: {
142 Form, InfoData,
Offset, StrOffsets, Str, Header.Version);
148 case dwarf::DW_AT_GNU_dwo_name:
149 case dwarf::DW_AT_dwo_name: {
151 Form, InfoData,
Offset, StrOffsets, Str, Header.Version);
157 case dwarf::DW_AT_GNU_dwo_id:
158 Header.Signature = ImplicitConst ?
static_cast<uint64_t>(*ImplicitConst)
167 if (!Header.Signature)
169 ID.Signature = *Header.Signature;
188 return Index + DW_SECT_INFO;
194 const auto *Off = Entry.getContribution(
Kind);
197 return Section.substr(Off->getOffset(), Off->getLength());
204 bool &AnySectionOverflow) {
207 Twine(
" Section Contribution Offset overflow 4G. Previous Offset ") +
208 Twine(PrevOffset) +
Twine(
", After overflow offset ") +
215 AnySectionOverflow =
true;
227 bool &AnySectionOverflow) {
230 auto *
I =
E.getContributions();
233 auto P = TypeIndexEntries.
insert(std::make_pair(
E.getSignature(), TUEntry));
236 auto &Entry =
P.first->second;
238 Entry.Contributions[0] = {};
244 C.setOffset(
C.getOffset() +
I->getOffset());
245 C.setLength(
I->getLength());
248 auto &
C = Entry.Contributions[TypesContributionIndex];
253 C.setOffset(TypesOffset);
255 static_assert(
sizeof(OldOffset) ==
sizeof(TypesOffset));
256 TypesOffset +=
C.getLength();
257 if (OldOffset > TypesOffset) {
259 "Types", OverflowOptValue,
262 if (AnySectionOverflow) {
263 TypesOffset = OldOffset;
273 DWPSectionId OutputSection,
const std::vector<StringRef> &TypesSections,
276 bool IsLittleEndian) {
286 C.setOffset(TypesOffset);
295 Offset = PrevOffset +
C.getLength32();
297 auto P = TypeIndexEntries.
insert(std::make_pair(Signature, Entry));
301 Out.
emitBytes(Types.substr(PrevOffset,
C.getLength32()));
303 TypesOffset +=
C.getLength32();
304 if (OldOffset > TypesOffset) {
306 "Types", OverflowOptValue,
309 if (AnySectionOverflow) {
310 TypesOffset = OldOffset;
321 std::string
Text =
"\'";
324 bool HasDWO = !DWOName.
empty();
325 bool HasDWP = !DWPName.
empty();
326 if (HasDWO || HasDWP) {
333 if (HasDWO && HasDWP)
335 if (!DWPName.
empty()) {
347 (
"failure while decompressing compressed section: '" + Name +
"', " +
367 UncompressedSections.emplace_back();
368 if (
Error E = Dec->resizeAndDecompress(UncompressedSections.back()))
371 Contents = UncompressedSections.
back();
379 std::string(
"duplicate DWO ID (") +
utohexstr(PrevE.first) +
") in " +
381 PrevE.second.DWOName) +
394 const uint64_t NewOffset = OffsetRemapping[OldOffset];
397 Out.
emitIntValue(NewOffset & NewOffsetMask, NewOffsetSize);
409 std::tie(Header.Length, Header.Format) =
417 "compile unit exceeds .debug_info section range: " +
427 if (Header.Version >= 5) {
430 MinHeaderLength = 16;
435 if (Header.Length < MinHeaderLength) {
437 utostr(MinHeaderLength) +
" got " +
438 utostr(Header.Length) +
".");
440 if (Header.Version >= 5) {
445 if (Header.UnitType == dwarf::DW_UT_split_type) {
447 MinHeaderLength += 4;
448 if (Header.Length < MinHeaderLength)
459 Header.HeaderSize =
Offset;
468 bool SingleInput,
bool IsLittleEndian) {
471 if (CurStrSection.
empty() || CurStrOffsetSection.
empty())
486 OffsetRemapping.
reserve(CurStrSection.
size() / 20);
500 while (
const char *S =
Data.getCStr(&LocalOffset)) {
502 OffsetRemapping[PrevOffset] = NewOffset;
505 NewOffset > UINT32_MAX) {
508 PrevOffset = LocalOffset;
521 "StrOffsetSection size is less than its header");
526 if (HeaderSize == 8) {
527 ContributionSize =
Data.getU32(&HeaderLengthOffset);
528 }
else if (HeaderSize == 16) {
530 HeaderLengthOffset += 4;
531 ContributionSize =
Data.getU64(&HeaderLengthOffset);
533 ContributionEnd = ContributionSize + HeaderLengthOffset;
536 if (OldOffsetSize == 4 && NewOffsetSize == 8) {
546 (ContributionSize - VersionPadSize) * 2 + VersionPadSize;
557 for (
auto &Pair : SectionLength) {
558 if (Pair.first == DW_SECT_STR_OFFSETS) {
559 Pair.second = NewLength + 12;
568 OldOffsetSize, NewOffsetSize);
572 assert(OldOffsetSize == NewOffsetSize);
584 for (
const auto &E : IndexEntries)
585 for (
size_t I = 0;
I != std::size(E.second.Contributions); ++
I)
586 if (ContributionOffsets[
I])
588 ? E.second.Contributions[
I].getOffset32()
589 : E.second.Contributions[
I].getLength32()),
597 if (IndexEntries.
empty())
600 unsigned Columns = 0;
601 for (
auto &
C : ContributionOffsets)
608 for (
const auto &
P : IndexEntries) {
611 auto HP = ((S >> 32) & Mask) | 1;
613 assert(S != IndexEntries.
begin()[Buckets[
H] - 1].first &&
623 if (IndexVersion >= 5) {
634 for (
const auto &
I : Buckets)
638 for (
const auto &
I : Buckets)
642 for (
size_t I = 0;
I != ContributionOffsets.
size(); ++
I)
643 if (ContributionOffsets[
I])
657 {
"debug_info.dwo", {
DS_Info, DW_SECT_INFO}},
659 {
"debug_str_offsets.dwo", {
DS_StrOffsets, DW_SECT_STR_OFFSETS}},
662 {
"debug_line.dwo", {
DS_Line, DW_SECT_LINE}},
663 {
"debug_macro.dwo", {
DS_Macro, DW_SECT_MACRO}},
664 {
"debug_abbrev.dwo", {
DS_Abbrev, DW_SECT_ABBREV}},
665 {
"debug_loclists.dwo", {
DS_Loclists, DW_SECT_LOCLISTS}},
666 {
"debug_rnglists.dwo", {
DS_Rnglists, DW_SECT_RNGLISTS}},
674 const StringMap<std::pair<DWPSectionId, DWARFSectionKind>> &KnownSections,
679 std::vector<StringRef> &CurTypesSection,
680 std::vector<StringRef> &CurInfoSection,
StringRef &AbbrevSection,
686 if (Section.isVirtual())
703 Name = Name.substr(Name.find_first_not_of(
"._"));
705 auto SectionPair = KnownSections.find(Name);
706 if (SectionPair == KnownSections.end())
714 SectionLength.push_back(std::make_pair(
Kind, Contents.
size()));
715 if (
Kind == DW_SECT_ABBREV)
716 AbbrevSection = Contents;
721 CurStrOffsetSection = Contents;
724 CurStrSection = Contents;
727 CurTypesSection.push_back(Contents);
730 CurCUIndexSection = Contents;
733 CurTUIndexSection = Contents;
736 CurInfoSection.push_back(Contents);
756 uint32_t ContributionOffsets[8] = {};
760 bool AnySectionOverflow =
false;
767 std::deque<SmallString<32>> UncompressedSections;
769 bool MachineSet =
false;
771 for (
const auto &
Input : Inputs) {
775 [&](std::unique_ptr<ECError> EC) ->
Error {
776 return createFileError(Input, Error(std::move(EC)));
780 auto &Obj = *ErrOrObj->getBinary();
787 Out.
setOSABI(ELFObj->getEIdentOSABI());
788 }
else if (Obj.isWasm()) {
799 std::vector<StringRef> CurTypesSection;
800 std::vector<StringRef> CurInfoSection;
810 for (
const auto &Section : Obj.sections())
812 KnownSections, Section, Out, UncompressedSections,
813 ContributionOffsets, CurEntry, CurStrSection, CurStrOffsetSection,
814 CurTypesSection, CurInfoSection, AbbrevSection, CurCUIndexSection,
815 CurTUIndexSection, SectionLength))
818 if (CurInfoSection.empty())
822 CurInfoSection.front(), Obj.isLittleEndian());
829 IndexVersion =
Version < 5 ? 2 : 5;
831 }
else if (
Version != Header.Version) {
833 "incompatible DWARF compile unit version: " +
Input +
" (version " +
834 utostr(Header.Version) +
") and " + FirstInput.
str() +
" (version " +
839 Header.Version, SectionLength, StrOffsetsOptValue,
840 Inputs.
size() == 1, Obj.isLittleEndian());
842 for (
auto Pair : SectionLength) {
846 uint32_t OldOffset = ContributionOffsets[Index];
848 if (OldOffset > ContributionOffsets[Index]) {
850 for (
auto &Section : Obj.sections()) {
851 if (SectionIndex == Index) {
853 OldOffset, ContributionOffsets[Index], *Section.getName(),
854 OverflowOptValue, AnySectionOverflow))
859 if (AnySectionOverflow)
866 if (CurCUIndexSection.
empty()) {
867 bool FoundCUUnit =
false;
871 while (Info.size() > UnitOffset) {
874 Obj.isLittleEndian());
882 C.setOffset(InfoSectionOffset);
883 C.setLength(Header.Length + 4);
885 if (std::numeric_limits<uint32_t>::max() - InfoSectionOffset <
888 InfoSectionOffset, InfoSectionOffset +
C.getLength32(),
889 "debug_info", OverflowOptValue, AnySectionOverflow))
891 if (AnySectionOverflow) {
897 UnitOffset +=
C.getLength32();
898 if (Header.Version < 5 ||
899 Header.UnitType == dwarf::DW_UT_split_compile) {
901 Header, AbbrevSection,
902 Info.
substr(UnitOffset -
C.getLength32(),
C.getLength32()),
903 CurStrOffsetSection, CurStrSection, Obj.isLittleEndian());
907 const auto &
ID = *EID;
908 auto P = IndexEntries.
insert(std::make_pair(
ID.Signature, Entry));
911 P.first->second.Name =
ID.Name;
912 P.first->second.DWOName =
ID.DWOName;
915 }
else if (Header.UnitType == dwarf::DW_UT_split_type) {
916 auto P = TypeIndexEntries.
insert(
917 std::make_pair(*Header.Signature, Entry));
922 Info.substr(UnitOffset -
C.getLength32(),
C.getLength32()));
923 InfoSectionOffset +=
C.getLength32();
925 if (AnySectionOverflow)
932 if (IndexVersion == 2) {
935 Out, TypeIndexEntries,
DS_Types, CurTypesSection, CurEntry,
937 OverflowOptValue, AnySectionOverflow, Obj.isLittleEndian()))
940 if (AnySectionOverflow)
945 if (CurInfoSection.size() != 1)
947 "info section in a .dwp file");
948 StringRef DwpSingleInfoSection = CurInfoSection.front();
951 DataExtractor CUIndexData(CurCUIndexSection, Obj.isLittleEndian());
952 if (!CUIndex.
parse(CUIndexData))
957 " and expecting " +
utostr(IndexVersion));
961 auto *
I = E.getContributions();
964 auto P = IndexEntries.
insert(std::make_pair(E.getSignature(), CurEntry));
977 CurStrSection, Obj.isLittleEndian());
980 const auto &
ID = *EID;
983 auto &NewEntry =
P.first->second;
984 NewEntry.Name =
ID.Name;
985 NewEntry.DWOName =
ID.DWOName;
986 NewEntry.DWPName =
Input;
992 C.setOffset(
C.getOffset() +
I->getOffset());
993 C.setLength(
I->getLength());
997 auto &
C = NewEntry.Contributions[Index];
999 C.setOffset(InfoSectionOffset);
1000 InfoSectionOffset +=
C.getLength32();
1003 if (!CurTUIndexSection.
empty()) {
1009 TUSectionKind = DW_SECT_INFO;
1011 TypeInputSection = DwpSingleInfoSection;
1014 if (CurTypesSection.size() != 1)
1016 "multiple type unit sections in .dwp file");
1020 TypeInputSection = CurTypesSection.front();
1024 DataExtractor TUIndexData(CurTUIndexSection, Obj.isLittleEndian());
1025 if (!TUIndex.
parse(TUIndexData))
1030 " and expecting " +
utostr(IndexVersion));
1032 unsigned TypesContributionIndex =
1035 Out, TypeIndexEntries, TUIndex, OutSection, TypeInputSection,
1036 CurEntry, ContributionOffsets[TypesContributionIndex],
1037 TypesContributionIndex, OverflowOptValue, AnySectionOverflow))
1040 if (AnySectionOverflow)
1048 ContributionOffsets[0] = 0;
1058 ContributionOffsets[0] = 1;
1066 return Out.
write(*OutputOS);
1080 struct SectionMeta {
1086 static constexpr SectionMeta Meta[] = {
1093 {
DS_Str,
".debug_str.dwo",
1103 struct OutputEntry {
1104 const SectionData *
Data;
1116 for (
const auto &M : Meta) {
1117 if (Sections[M.Id].empty())
1123 {&Sections[M.Id], M.Name, M.Flags, M.EntSize, NameOff, 0});
1128 Strtab.
append(
".strtab");
1131 Strtab.
append(
".symtab");
1144 constexpr uint64_t SymEntSize = 24;
1147 for (
auto &E : Entries) {
1149 Offset += E.Data->totalSize();
1156 Offset = SymtabOffset + SymEntSize;
1162 uint32_t SymtabIdx = StrtabIdx + 1;
1163 uint32_t NumSections = SymtabIdx + 1;
1167 0, SHTOffset, NumSections, StrtabIdx);
1170 for (
const auto &E : Entries)
1171 E.Data->writeTo(OS);
1181 uint64_t CurPos = SymtabOffset + SymEntSize;
1185 ELF::writeSectionHeader(Wr,
true, 0,
ELF::SHT_NULL, 0, 0, 0, 0, 0, 0, 0, 0);
1188 for (
const auto &E : Entries)
1190 0, E.FileOffset, E.Data->totalSize(), 0, 0, 1,
1195 StrtabOffset, Strtab.
size(), 0, 0, 1, 0);
1199 SymtabOffset, SymEntSize, StrtabIdx, 1, 8,
1211 static constexpr struct {
1216 {
DS_Loc,
".debug_loc.dwo"},
1221 {
DS_Str,
".debug_str.dwo"},
1230 OS.
write(
"\0asm", 4);
1235 for (
const auto &M : Meta) {
1236 const SectionData &SD = Sections[M.Id];
1240 size_t NameLen = strlen(M.Name);
1241 uint64_t PayloadSize = SD.totalSize();
1245 unsigned NameLenSize =
encodeULEB128(NameLen, NameLenEncoded);
1246 uint64_t SectionPayloadSize = NameLenSize + NameLen + PayloadSize;
1251 unsigned SizeLen =
encodeULEB128(SectionPayloadSize, SizeEncoded);
1252 OS.
write(
reinterpret_cast<const char *
>(SizeEncoded), SizeLen);
1255 OS.
write(
reinterpret_cast<const char *
>(NameLenEncoded), NameLenSize);
1256 OS.
write(M.Name, NameLen);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static unsigned getContributionIndex(DWARFSectionKind Kind, uint32_t IndexVersion)
static Error addAllTypesFromTypesSection(DWPWriter &Out, MapVector< uint64_t, UnitIndexEntry > &TypeIndexEntries, DWPSectionId OutputSection, const std::vector< StringRef > &TypesSections, const UnitIndexEntry &CUEntry, uint32_t &TypesOffset, OnCuIndexOverflow OverflowOptValue, bool &AnySectionOverflow, bool IsLittleEndian)
static Error handleCompressedSection(std::deque< SmallString< 32 > > &UncompressedSections, SectionRef Sec, StringRef Name, StringRef &Contents)
static std::string buildDWODescription(StringRef Name, StringRef DWPName, StringRef DWOName)
static void writeNewOffsetsTo(DWPWriter &Out, DataExtractor &Data, DenseMap< uint64_t, uint64_t > &OffsetRemapping, uint64_t &Offset, const uint64_t Size, uint32_t OldOffsetSize, uint32_t NewOffsetSize)
static uint64_t debugStrOffsetsHeaderSize(DataExtractor StrOffsetsData, uint16_t DwarfVersion)
static Expected< const char * > getIndexedString(dwarf::Form Form, DataExtractor InfoData, uint64_t &InfoOffset, StringRef StrOffsets, StringRef Str, uint16_t Version)
static unsigned getOnDiskSectionId(unsigned Index)
static Error sectionOverflowErrorOrWarning(uint32_t PrevOffset, uint32_t OverflowedOffset, StringRef SectionName, OnCuIndexOverflow OverflowOptValue, bool &AnySectionOverflow)
static Expected< uint64_t > getCUAbbrev(StringRef Abbrev, uint64_t AbbrCode, bool IsLittleEndian)
static Expected< CompileUnitIdentifiers > getCUIdentifiers(InfoSectionUnitHeader &Header, StringRef Abbrev, StringRef Info, StringRef StrOffsets, StringRef Str, bool IsLittleEndian)
static Error addAllTypesFromDWP(DWPWriter &Out, MapVector< uint64_t, UnitIndexEntry > &TypeIndexEntries, const DWARFUnitIndex &TUIndex, DWPSectionId OutputSection, StringRef Types, const UnitIndexEntry &TUEntry, uint32_t &TypesOffset, unsigned TypesContributionIndex, OnCuIndexOverflow OverflowOptValue, bool &AnySectionOverflow)
static StringRef getSubsection(StringRef Section, const DWARFUnitIndex::Entry &Entry, DWARFSectionKind Kind)
static bool isSupportedSectionKind(DWARFSectionKind Kind)
static Error buildDuplicateError(const std::pair< uint64_t, UnitIndexEntry > &PrevE, const CompileUnitIdentifiers &ID, StringRef DWPName)
OptimizedStructLayoutField Field
This file defines the SmallVector class.
static uint32_t getFlags(const Symbol *Sym)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
void setOffset(uint64_t Value)
void setLength(uint64_t Value)
uint32_t getLength32() const
uint64_t getOffset() const
uint32_t getVersion() const
LLVM_ABI bool parse(DataExtractor IndexData)
ArrayRef< DWARFSectionKind > getColumnKinds() const
ArrayRef< Entry > getRows() const
uint64_t getOffset(const char *Str, unsigned Length)
Direct ELF writer for DWP output.
void switchSection(DWPSectionId Id)
Error write(raw_pwrite_stream &OS)
Error writeWASM(raw_pwrite_stream &OS)
void setIsLittleEndian(bool V)
void setMachine(uint16_t Machine)
Error writeELF(raw_pwrite_stream &OS)
void setOSABI(uint8_t OSABI)
void emitBytes(StringRef Data)
Zero-copy: stores a reference to the input data without copying.
void emitIntValue(uint64_t Value, unsigned Size)
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
This class implements a map that also provides access to all stored values in a deterministic order.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void append(StringRef RHS)
Append from a StringRef.
void reserve(size_type N)
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr bool empty() const
Check if the string is empty.
char back() const
Get the last character in the string.
constexpr size_t size() const
Get the string size.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static LLVM_ABI void defaultWarningHandler(Error Warning)
Implement default handling for Warning.
static LLVM_ABI Expected< Decompressor > create(StringRef Name, StringRef Data, bool IsLE, bool Is64Bit)
Create decompressor object.
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
This is a value type class that represents a single section in the list of sections in the object fil...
const ObjectFile * getObject() const
raw_ostream & write_zeros(unsigned NumZeros)
write_zeros - Insert 'NumZeros' nulls.
raw_ostream & write(unsigned char C)
An abstract base class for streams implementations that also support a pwrite operation.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI void writeHeader(support::endian::Writer &W, bool Is64Bit, uint8_t OSABI, uint8_t ABIVersion, uint16_t EMachine, uint32_t EFlags, uint64_t SHOff, uint16_t SHNum, uint16_t SHStrNdx)
Write an ELF file header (Elf32_Ehdr or Elf64_Ehdr) for an ET_REL object.
LLVM_ABI void writeSectionHeader(support::endian::Writer &W, bool Is64Bit, uint32_t Name, uint32_t Type, uint64_t Flags, uint64_t Address, uint64_t Offset, uint64_t Size, uint32_t Link, uint32_t Info, uint64_t Alignment, uint64_t EntrySize)
Write a single ELF section header entry (Elf32_Shdr or Elf64_Shdr).
@ DW_LENGTH_DWARF64
Indicator of 64-bit DWARF format.
Error createError(const Twine &Err)
This is an optimization pass for GlobalISel generic memory operations.
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Error handleErrors(Error E, HandlerTs &&... Hs)
Pass the ErrorInfo(s) contained in E to their respective handlers.
std::string utohexstr(uint64_t X, bool LowerCase=false, unsigned Width=0)
std::string utostr(uint64_t X, bool isNeg=false)
std::vector< std::pair< DWARFSectionKind, uint32_t > > SectionLengths
static void writeIndexTable(DWPWriter &Out, ArrayRef< unsigned > ContributionOffsets, const MapVector< uint64_t, UnitIndexEntry > &IndexEntries, const AccessField &Field)
DWARFSectionKind
The enum of section identifiers to be used in internal interfaces.
@ DW_SECT_EXT_unknown
Denotes a value read from an index section that does not correspond to any of the supported standards...
static Error handleSection(const StringMap< std::pair< DWPSectionId, DWARFSectionKind > > &KnownSections, const SectionRef &Section, DWPWriter &Out, std::deque< SmallString< 32 > > &UncompressedSections, uint32_t(&ContributionOffsets)[8], UnitIndexEntry &CurEntry, StringRef &CurStrSection, StringRef &CurStrOffsetSection, std::vector< StringRef > &CurTypesSection, std::vector< StringRef > &CurInfoSection, StringRef &AbbrevSection, StringRef &CurCUIndexSection, StringRef &CurTUIndexSection, SectionLengths &SectionLength)
LLVM_ABI uint32_t serializeSectionKind(DWARFSectionKind Kind, unsigned IndexVersion)
Convert the internal value for a section kind to an on-disk value.
LLVM_ABI bool readAbbrevAttribute(const DataExtractor &AbbrevData, uint64_t *Offset, dwarf::Attribute &Name, dwarf::Form &Form, std::optional< int64_t > &ImplicitConst)
Read the next (attribute, form) specification from an abbreviation declaration at Offset,...
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
static void writeStringsAndOffsets(DWPWriter &Out, DWPStringPool &Strings, StringRef CurStrSection, StringRef CurStrOffsetSection, uint16_t Version, SectionLengths &SectionLength, const Dwarf64StrOffsetsPromotion StrOffsetsOptValue, bool SingleInput, bool IsLittleEndian)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
static void writeIndex(DWPWriter &Out, DWPSectionId Section, ArrayRef< unsigned > ContributionOffsets, const MapVector< uint64_t, UnitIndexEntry > &IndexEntries, uint32_t IndexVersion)
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
LLVM_ABI Expected< InfoSectionUnitHeader > parseInfoSectionUnitHeader(StringRef Info, bool IsLittleEndian)
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
DWPSectionId
Section identifiers for DWP output.
static const StringMap< std::pair< DWPSectionId, DWARFSectionKind > > & getKnownSections()
Map input ELF section names to DWP section IDs and DWARF section kinds.
Dwarf64StrOffsetsPromotion
@ Always
Always emit .debug_str_offsets talbes as DWARF64 for testing.
@ Disabled
Don't do any conversion of .debug_str_offsets tables.
LLVM_ABI Error write(DWPWriter &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue, Dwarf64StrOffsetsPromotion StrOffsetsOptValue, raw_pwrite_stream *OS=nullptr)
constexpr uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
DWARFUnitIndex::Entry::SectionContribution Contributions[8]
Adapter to write values to a stream in a particular byte order.