#ifndef LLVM_DWP_DWP_H
#define LLVM_DWP_DWP_H
#include "DWPStringPool.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Error.h"
#include <deque>
#include <vector>
namespace llvm {
struct UnitIndexEntry {
DWARFUnitIndex::Entry::SectionContribution Contributions[8];
std::string Name;
std::string DWOName;
StringRef DWPName;
};
struct InfoSectionUnitHeader {
uint64_t Length = 0;
uint16_t Version = 0;
uint8_t UnitType = 0;
uint8_t AddrSize = 0;
uint64_t DebugAbbrevOffset = 0;
Optional<uint64_t> Signature = None;
dwarf::DwarfFormat Format = dwarf::DwarfFormat::DWARF32;
uint8_t HeaderSize = 0;
};
struct CompileUnitIdentifiers {
uint64_t Signature = 0;
const char *Name = "";
const char *DWOName = "";
};
Error write(MCStreamer &Out, ArrayRef<std::string> Inputs);
unsigned getContributionIndex(DWARFSectionKind Kind, uint32_t IndexVersion);
Error handleSection(
const StringMap<std::pair<MCSection *, DWARFSectionKind>> &KnownSections,
const MCSection *StrSection, const MCSection *StrOffsetSection,
const MCSection *TypesSection, const MCSection *CUIndexSection,
const MCSection *TUIndexSection, const MCSection *InfoSection,
const object::SectionRef &Section, MCStreamer &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,
std::vector<std::pair<DWARFSectionKind, uint32_t>> &SectionLength);
Expected<InfoSectionUnitHeader> parseInfoSectionUnitHeader(StringRef Info);
void writeStringsAndOffsets(MCStreamer &Out, DWPStringPool &Strings,
MCSection *StrOffsetSection,
StringRef CurStrSection,
StringRef CurStrOffsetSection, uint16_t Version);
Error buildDuplicateError(const std::pair<uint64_t, UnitIndexEntry> &PrevE,
const CompileUnitIdentifiers &ID, StringRef DWPName);
void writeIndex(MCStreamer &Out, MCSection *Section,
ArrayRef<unsigned> ContributionOffsets,
const MapVector<uint64_t, UnitIndexEntry> &IndexEntries,
uint32_t IndexVersion);
} #endif