34 if (DwarfVersion <= 4)
44 bool IsLittleEndian) {
61 std::optional<int64_t> ImplicitConst;
66 " not found in abbrev section");
72 if (Form == dwarf::DW_FORM_string)
73 return InfoData.
getCStr(&InfoOffset);
76 case dwarf::DW_FORM_strx1:
77 StrIndex = InfoData.
getU8(&InfoOffset);
79 case dwarf::DW_FORM_strx2:
80 StrIndex = InfoData.
getU16(&InfoOffset);
82 case dwarf::DW_FORM_strx3:
83 StrIndex = InfoData.
getU24(&InfoOffset);
85 case dwarf::DW_FORM_strx4:
86 StrIndex = InfoData.
getU32(&InfoOffset);
88 case dwarf::DW_FORM_strx:
89 case dwarf::DW_FORM_GNU_str_index:
94 "string field must be encoded with one of the following: "
95 "DW_FORM_string, DW_FORM_strx, DW_FORM_strx1, DW_FORM_strx2, "
96 "DW_FORM_strx3, DW_FORM_strx4, or DW_FORM_GNU_str_index.");
99 uint64_t StrOffsetsOffset = 4 * StrIndex;
104 return StrData.
getCStr(&StrOffset);
110 bool IsLittleEndian) {
113 if (Header.Version >= 5 && Header.UnitType != dwarf::DW_UT_split_compile)
115 std::string(
"unit type DW_UT_split_compile type not found in "
116 "debug_info header. Unexpected unit type 0x" +
117 utostr(Header.UnitType) +
" found"));
125 if (!AbbrevOffsetOrErr)
127 uint64_t AbbrevOffset = *AbbrevOffsetOrErr;
129 if (Tag != dwarf::DW_TAG_compile_unit)
132 AbbrevData.
getU8(&AbbrevOffset);
135 std::optional<int64_t> ImplicitConst;
139 case dwarf::DW_AT_name: {
141 Form, InfoData,
Offset, StrOffsets, Str, Header.Version);
147 case dwarf::DW_AT_GNU_dwo_name:
148 case dwarf::DW_AT_dwo_name: {
150 Form, InfoData,
Offset, StrOffsets, Str, Header.Version);
156 case dwarf::DW_AT_GNU_dwo_id:
157 Header.Signature = ImplicitConst ?
static_cast<uint64_t>(*ImplicitConst)
166 if (!Header.Signature)
168 ID.Signature = *Header.Signature;
187 return Index + DW_SECT_INFO;
193 const auto *Off = Entry.getContribution(
Kind);
196 return Section.substr(Off->getOffset(), Off->getLength());
203 bool &AnySectionOverflow) {
206 Twine(
" Section Contribution Offset overflow 4G. Previous Offset ") +
207 Twine(PrevOffset) +
Twine(
", After overflow offset ") +
214 AnySectionOverflow =
true;
226 bool &AnySectionOverflow) {
229 auto *
I =
E.getContributions();
232 auto P = TypeIndexEntries.
insert(std::make_pair(
E.getSignature(), TUEntry));
235 auto &Entry =
P.first->second;
237 Entry.Contributions[0] = {};
243 C.setOffset(
C.getOffset() +
I->getOffset());
244 C.setLength(
I->getLength());
247 auto &
C = Entry.Contributions[TypesContributionIndex];
252 C.setOffset(TypesOffset);
254 static_assert(
sizeof(OldOffset) ==
sizeof(TypesOffset));
255 TypesOffset +=
C.getLength();
256 if (OldOffset > TypesOffset) {
258 "Types", OverflowOptValue,
261 if (AnySectionOverflow) {
262 TypesOffset = OldOffset;
272 DWPSectionId OutputSection,
const std::vector<StringRef> &TypesSections,
275 bool IsLittleEndian) {
285 C.setOffset(TypesOffset);
294 Offset = PrevOffset +
C.getLength32();
296 auto P = TypeIndexEntries.
insert(std::make_pair(Signature, Entry));
300 Out.
emitBytes(Types.substr(PrevOffset,
C.getLength32()));
302 TypesOffset +=
C.getLength32();
303 if (OldOffset > TypesOffset) {
305 "Types", OverflowOptValue,
308 if (AnySectionOverflow) {
309 TypesOffset = OldOffset;
320 std::string
Text =
"\'";
323 bool HasDWO = !DWOName.
empty();
324 bool HasDWP = !DWPName.
empty();
325 if (HasDWO || HasDWP) {
332 if (HasDWO && HasDWP)
334 if (!DWPName.
empty()) {
346 (
"failure while decompressing compressed section: '" + Name +
"', " +
366 UncompressedSections.emplace_back();
367 if (
Error E = Dec->resizeAndDecompress(UncompressedSections.back()))
370 Contents = UncompressedSections.
back();
378 std::string(
"duplicate DWO ID (") +
utohexstr(PrevE.first) +
") in " +
380 PrevE.second.DWOName) +
393 const uint64_t NewOffset = OffsetRemapping[OldOffset];
396 Out.
emitIntValue(NewOffset & NewOffsetMask, NewOffsetSize);
408 std::tie(Header.Length, Header.Format) =
416 "compile unit exceeds .debug_info section range: " +
425 uint64_t MinHeaderLength;
426 if (Header.Version >= 5) {
429 MinHeaderLength = 16;
434 if (Header.Length < MinHeaderLength) {
436 utostr(MinHeaderLength) +
" got " +
437 utostr(Header.Length) +
".");
439 if (Header.Version >= 5) {
444 if (Header.UnitType == dwarf::DW_UT_split_type) {
446 MinHeaderLength += 4;
447 if (Header.Length < MinHeaderLength)
458 Header.HeaderSize =
Offset;
467 bool SingleInput,
bool IsLittleEndian) {
470 if (CurStrSection.
empty() || CurStrOffsetSection.
empty())
485 OffsetRemapping.
reserve(CurStrSection.
size() / 20);
488 uint64_t LocalOffset = 0;
489 uint64_t PrevOffset = 0;
499 while (
const char *S =
Data.getCStr(&LocalOffset)) {
500 uint64_t NewOffset = Strings.
getOffset(S, LocalOffset - PrevOffset);
501 OffsetRemapping[PrevOffset] = NewOffset;
504 NewOffset > UINT32_MAX) {
507 PrevOffset = LocalOffset;
515 uint64_t
Size = CurStrOffsetSection.
size();
520 "StrOffsetSection size is less than its header");
522 uint64_t ContributionEnd = 0;
523 uint64_t ContributionSize = 0;
524 uint64_t HeaderLengthOffset =
Offset;
525 if (HeaderSize == 8) {
526 ContributionSize =
Data.getU32(&HeaderLengthOffset);
527 }
else if (HeaderSize == 16) {
529 HeaderLengthOffset += 4;
530 ContributionSize =
Data.getU64(&HeaderLengthOffset);
532 ContributionEnd = ContributionSize + HeaderLengthOffset;
535 if (OldOffsetSize == 4 && NewOffsetSize == 8) {
543 const uint64_t VersionPadSize = 4;
544 const uint64_t NewLength =
545 (ContributionSize - VersionPadSize) * 2 + VersionPadSize;
556 for (
auto &Pair : SectionLength) {
557 if (Pair.first == DW_SECT_STR_OFFSETS) {
558 Pair.second = NewLength + 12;
567 OldOffsetSize, NewOffsetSize);
571 assert(OldOffsetSize == NewOffsetSize);
583 for (
const auto &E : IndexEntries)
584 for (
size_t I = 0;
I != std::size(E.second.Contributions); ++
I)
585 if (ContributionOffsets[
I])
587 ? E.second.Contributions[
I].getOffset32()
588 : E.second.Contributions[
I].getLength32()),
596 if (IndexEntries.
empty())
599 unsigned Columns = 0;
600 for (
auto &
C : ContributionOffsets)
605 uint64_t Mask = Buckets.size() - 1;
607 for (
const auto &
P : IndexEntries) {
610 auto HP = ((S >> 32) & Mask) | 1;
612 assert(S != IndexEntries.
begin()[Buckets[
H] - 1].first &&
622 if (IndexVersion >= 5) {
633 for (
const auto &
I : Buckets)
637 for (
const auto &
I : Buckets)
641 for (
size_t I = 0;
I != ContributionOffsets.
size(); ++
I)
642 if (ContributionOffsets[
I])
656 {
"debug_info.dwo", {
DS_Info, DW_SECT_INFO}},
658 {
"debug_str_offsets.dwo", {
DS_StrOffsets, DW_SECT_STR_OFFSETS}},
661 {
"debug_line.dwo", {
DS_Line, DW_SECT_LINE}},
662 {
"debug_macro.dwo", {
DS_Macro, DW_SECT_MACRO}},
663 {
"debug_abbrev.dwo", {
DS_Abbrev, DW_SECT_ABBREV}},
664 {
"debug_loclists.dwo", {
DS_Loclists, DW_SECT_LOCLISTS}},
665 {
"debug_rnglists.dwo", {
DS_Rnglists, DW_SECT_RNGLISTS}},
673 const StringMap<std::pair<DWPSectionId, DWARFSectionKind>> &KnownSections,
678 std::vector<StringRef> &CurTypesSection,
679 std::vector<StringRef> &CurInfoSection,
StringRef &AbbrevSection,
685 if (Section.isVirtual())
702 Name = Name.substr(Name.find_first_not_of(
"._"));
704 auto SectionPair = KnownSections.find(Name);
705 if (SectionPair == KnownSections.end())
713 SectionLength.push_back(std::make_pair(
Kind, Contents.
size()));
714 if (
Kind == DW_SECT_ABBREV)
715 AbbrevSection = Contents;
720 CurStrOffsetSection = Contents;
723 CurStrSection = Contents;
726 CurTypesSection.push_back(Contents);
729 CurCUIndexSection = Contents;
732 CurTUIndexSection = Contents;
735 CurInfoSection.push_back(Contents);
755 uint32_t ContributionOffsets[8] = {};
759 bool AnySectionOverflow =
false;
766 std::deque<SmallString<32>> UncompressedSections;
768 bool MachineSet =
false;
770 for (
const auto &
Input : Inputs) {
774 [&](std::unique_ptr<ECError> EC) ->
Error {
775 return createFileError(Input, Error(std::move(EC)));
779 auto &Obj = *ErrOrObj->getBinary();
786 Out.
setOSABI(ELFObj->getEIdentOSABI());
787 }
else if (Obj.isWasm()) {
798 std::vector<StringRef> CurTypesSection;
799 std::vector<StringRef> CurInfoSection;
809 for (
const auto &Section : Obj.sections())
811 KnownSections, Section, Out, UncompressedSections,
812 ContributionOffsets, CurEntry, CurStrSection, CurStrOffsetSection,
813 CurTypesSection, CurInfoSection, AbbrevSection, CurCUIndexSection,
814 CurTUIndexSection, SectionLength))
817 if (CurInfoSection.empty())
821 CurInfoSection.front(), Obj.isLittleEndian());
828 IndexVersion =
Version < 5 ? 2 : 5;
830 }
else if (
Version != Header.Version) {
832 "incompatible DWARF compile unit version: " +
Input +
" (version " +
833 utostr(Header.Version) +
") and " + FirstInput.
str() +
" (version " +
838 Header.Version, SectionLength, StrOffsetsOptValue,
839 Inputs.
size() == 1, Obj.isLittleEndian());
841 for (
auto Pair : SectionLength) {
845 uint32_t OldOffset = ContributionOffsets[Index];
847 if (OldOffset > ContributionOffsets[Index]) {
849 for (
auto &Section : Obj.sections()) {
850 if (SectionIndex == Index) {
852 OldOffset, ContributionOffsets[Index], *Section.getName(),
853 OverflowOptValue, AnySectionOverflow))
858 if (AnySectionOverflow)
865 if (CurCUIndexSection.
empty()) {
866 bool FoundCUUnit =
false;
869 uint64_t UnitOffset = 0;
870 while (Info.size() > UnitOffset) {
873 Obj.isLittleEndian());
881 C.setOffset(InfoSectionOffset);
882 C.setLength(Header.Length + 4);
884 if (std::numeric_limits<uint32_t>::max() - InfoSectionOffset <
887 InfoSectionOffset, InfoSectionOffset +
C.getLength32(),
888 "debug_info", OverflowOptValue, AnySectionOverflow))
890 if (AnySectionOverflow) {
896 UnitOffset +=
C.getLength32();
897 if (Header.Version < 5 ||
898 Header.UnitType == dwarf::DW_UT_split_compile) {
900 Header, AbbrevSection,
901 Info.
substr(UnitOffset -
C.getLength32(),
C.getLength32()),
902 CurStrOffsetSection, CurStrSection, Obj.isLittleEndian());
906 const auto &ID = *EID;
907 auto P = IndexEntries.
insert(std::make_pair(ID.Signature, Entry));
910 P.first->second.Name = ID.Name;
911 P.first->second.DWOName = ID.DWOName;
914 }
else if (Header.UnitType == dwarf::DW_UT_split_type) {
915 auto P = TypeIndexEntries.
insert(
916 std::make_pair(*Header.Signature, Entry));
921 Info.substr(UnitOffset -
C.getLength32(),
C.getLength32()));
922 InfoSectionOffset +=
C.getLength32();
924 if (AnySectionOverflow)
931 if (IndexVersion == 2) {
934 Out, TypeIndexEntries,
DS_Types, CurTypesSection, CurEntry,
936 OverflowOptValue, AnySectionOverflow, Obj.isLittleEndian()))
939 if (AnySectionOverflow)
944 if (CurInfoSection.size() != 1)
946 "info section in a .dwp file");
947 StringRef DwpSingleInfoSection = CurInfoSection.front();
950 DataExtractor CUIndexData(CurCUIndexSection, Obj.isLittleEndian());
951 if (!CUIndex.
parse(CUIndexData))
956 " and expecting " +
utostr(IndexVersion));
960 auto *
I = E.getContributions();
963 auto P = IndexEntries.
insert(std::make_pair(E.getSignature(), CurEntry));
976 CurStrSection, Obj.isLittleEndian());
979 const auto &ID = *EID;
982 auto &NewEntry =
P.first->second;
983 NewEntry.Name = ID.Name;
984 NewEntry.DWOName = ID.DWOName;
985 NewEntry.DWPName =
Input;
991 C.setOffset(
C.getOffset() +
I->getOffset());
992 C.setLength(
I->getLength());
996 auto &
C = NewEntry.Contributions[Index];
998 C.setOffset(InfoSectionOffset);
999 InfoSectionOffset +=
C.getLength32();
1002 if (!CurTUIndexSection.
empty()) {
1008 TUSectionKind = DW_SECT_INFO;
1010 TypeInputSection = DwpSingleInfoSection;
1013 if (CurTypesSection.size() != 1)
1015 "multiple type unit sections in .dwp file");
1019 TypeInputSection = CurTypesSection.front();
1023 DataExtractor TUIndexData(CurTUIndexSection, Obj.isLittleEndian());
1024 if (!TUIndex.
parse(TUIndexData))
1029 " and expecting " +
utostr(IndexVersion));
1031 unsigned TypesContributionIndex =
1034 Out, TypeIndexEntries, TUIndex, OutSection, TypeInputSection,
1035 CurEntry, ContributionOffsets[TypesContributionIndex],
1036 TypesContributionIndex, OverflowOptValue, AnySectionOverflow))
1039 if (AnySectionOverflow)
1049 ContributionOffsets[0] = 0;
1059 ContributionOffsets[0] = 1;
1067 return Out.
write(*OutputOS);
1081 struct SectionMeta {
1087 static constexpr SectionMeta Meta[] = {
1094 {
DS_Str,
".debug_str.dwo",
1104 struct OutputEntry {
1110 uint64_t FileOffset;
1118 for (
const auto &M : Meta) {
1119 if (Sections[M.Id].empty())
1125 {&Sections[M.Id], M.Name, M.Flags, M.EntSize, NameOff, 0, 0});
1130 Strtab.
append(
".strtab");
1133 Strtab.
append(
".symtab");
1146 constexpr uint64_t SymEntSize = 24;
1148 uint64_t
Offset = EhdrSize;
1149 for (
auto &E : Entries) {
1151 E.Size = E.Data->totalSize();
1155 uint64_t StrtabOffset =
Offset;
1159 Offset = SymtabOffset + SymEntSize;
1165 uint32_t SymtabIdx = StrtabIdx + 1;
1166 uint32_t NumSections = SymtabIdx + 1;
1170 0, SHTOffset, NumSections, StrtabIdx);
1173 for (
auto &E : Entries)
1174 E.Data->writeTo(OS);
1184 uint64_t CurPos = SymtabOffset + SymEntSize;
1188 ELF::writeSectionHeader(Wr,
true, 0,
ELF::SHT_NULL, 0, 0, 0, 0, 0, 0, 0, 0);
1191 for (
const auto &E : Entries)
1193 0, E.FileOffset, E.Size, 0, 0, 1, E.EntSize);
1197 StrtabOffset, Strtab.
size(), 0, 0, 1, 0);
1201 SymtabOffset, SymEntSize, StrtabIdx, 1, 8,
1213 static constexpr struct {
1218 {
DS_Loc,
".debug_loc.dwo"},
1223 {
DS_Str,
".debug_str.dwo"},
1232 OS.
write(
"\0asm", 4);
1237 for (
const auto &M : Meta) {
1238 SectionData &SD = Sections[M.Id];
1242 size_t NameLen = strlen(M.Name);
1243 uint64_t PayloadSize = SD.totalSize();
1247 unsigned NameLenSize =
encodeULEB128(NameLen, NameLenEncoded);
1248 uint64_t SectionPayloadSize = NameLenSize + NameLen + PayloadSize;
1253 unsigned SizeLen =
encodeULEB128(SectionPayloadSize, SizeEncoded);
1254 OS.
write(
reinterpret_cast<const char *
>(SizeEncoded), SizeLen);
1257 OS.
write(
reinterpret_cast<const char *
>(NameLenEncoded), NameLenSize);
1258 OS.
write(M.Name, NameLen);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
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.
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.