LLVM  15.0.0git
DWP.h
Go to the documentation of this file.
1 #ifndef LLVM_DWP_DWP_H
2 #define LLVM_DWP_DWP_H
3 
4 #include "DWPStringPool.h"
5 #include "llvm/ADT/ArrayRef.h"
6 #include "llvm/ADT/MapVector.h"
7 #include "llvm/ADT/StringRef.h"
10 #include "llvm/MC/MCSection.h"
11 #include "llvm/MC/MCStreamer.h"
12 #include "llvm/Object/ObjectFile.h"
13 #include "llvm/Support/Error.h"
14 #include <deque>
15 #include <vector>
16 
17 namespace llvm {
20  std::string Name;
21  std::string DWOName;
23 };
24 
25 // Holds data for Skeleton, Split Compilation, and Type Unit Headers (only in
26 // v5) as defined in Dwarf 5 specification, 7.5.1.2, 7.5.1.3 and Dwarf 4
27 // specification 7.5.1.1.
29  // unit_length field. Note that the type is uint64_t even in 32-bit dwarf.
31 
32  // version field.
34 
35  // unit_type field. Initialized only if Version >= 5.
36  uint8_t UnitType = 0;
37 
38  // address_size field.
39  uint8_t AddrSize = 0;
40 
41  // debug_abbrev_offset field. Note that the type is uint64_t even in 32-bit
42  // dwarf. It is assumed to be 0.
44 
45  // dwo_id field. This resides in the header only if Version >= 5.
46  // In earlier versions, it is read from DW_AT_GNU_dwo_id.
48 
49  // Derived from the length of Length field.
51 
52  // The size of the Header in bytes. This is derived while parsing the header,
53  // and is stored as a convenience.
54  uint8_t HeaderSize = 0;
55 };
56 
59  const char *Name = "";
60  const char *DWOName = "";
61 };
62 
64 
65 unsigned getContributionIndex(DWARFSectionKind Kind, uint32_t IndexVersion);
66 
68  const StringMap<std::pair<MCSection *, DWARFSectionKind>> &KnownSections,
69  const MCSection *StrSection, const MCSection *StrOffsetSection,
70  const MCSection *TypesSection, const MCSection *CUIndexSection,
71  const MCSection *TUIndexSection, const MCSection *InfoSection,
72  const object::SectionRef &Section, MCStreamer &Out,
73  std::deque<SmallString<32>> &UncompressedSections,
74  uint32_t (&ContributionOffsets)[8], UnitIndexEntry &CurEntry,
75  StringRef &CurStrSection, StringRef &CurStrOffsetSection,
76  std::vector<StringRef> &CurTypesSection,
77  std::vector<StringRef> &CurInfoSection, StringRef &AbbrevSection,
78  StringRef &CurCUIndexSection, StringRef &CurTUIndexSection,
79  std::vector<std::pair<DWARFSectionKind, uint32_t>> &SectionLength);
80 
82 
84  MCSection *StrOffsetSection,
85  StringRef CurStrSection,
86  StringRef CurStrOffsetSection, uint16_t Version);
87 
88 Error buildDuplicateError(const std::pair<uint64_t, UnitIndexEntry> &PrevE,
89  const CompileUnitIdentifiers &ID, StringRef DWPName);
90 
91 void writeIndex(MCStreamer &Out, MCSection *Section,
92  ArrayRef<unsigned> ContributionOffsets,
93  const MapVector<uint64_t, UnitIndexEntry> &IndexEntries,
94  uint32_t IndexVersion);
95 
96 } // namespace llvm
97 #endif // LLVM_DWP_DWP_H
llvm::InfoSectionUnitHeader::UnitType
uint8_t UnitType
Definition: DWP.h:36
llvm::InfoSectionUnitHeader::Version
uint16_t Version
Definition: DWP.h:33
DWPStringPool.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::handleSection
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)
Definition: DWP.cpp:468
StringRef.h
llvm::write
Error write(MCStreamer &Out, ArrayRef< std::string > Inputs)
Definition: DWP.cpp:536
llvm::CompileUnitIdentifiers::Name
const char * Name
Definition: DWP.h:59
llvm::DWARFUnitIndex::Entry::SectionContribution
Definition: DWARFUnitIndex.h:113
llvm::DWPStringPool
Definition: DWPStringPool.h:10
MapVector.h
DWARFContext.h
Error.h
llvm::UnitIndexEntry::DWPName
StringRef DWPName
Definition: DWP.h:22
llvm::Optional< uint64_t >
llvm::MapVector
This class implements a map that also provides access to all stored values in a deterministic order.
Definition: MapVector.h:37
llvm::InfoSectionUnitHeader::AddrSize
uint8_t AddrSize
Definition: DWP.h:39
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::InfoSectionUnitHeader::Signature
Optional< uint64_t > Signature
Definition: DWP.h:47
llvm::CompileUnitIdentifiers::DWOName
const char * DWOName
Definition: DWP.h:60
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:201
llvm::DWARFSectionKind
DWARFSectionKind
The enum of section identifiers to be used in internal interfaces.
Definition: DWARFUnitIndex.h:56
llvm::writeIndex
void writeIndex(MCStreamer &Out, MCSection *Section, ArrayRef< unsigned > ContributionOffsets, const MapVector< uint64_t, UnitIndexEntry > &IndexEntries, uint32_t IndexVersion)
Definition: DWP.cpp:403
llvm::InfoSectionUnitHeader::HeaderSize
uint8_t HeaderSize
Definition: DWP.h:54
llvm::InfoSectionUnitHeader::DebugAbbrevOffset
uint64_t DebugAbbrevOffset
Definition: DWP.h:43
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::dwarf::DwarfFormat
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition: Dwarf.h:93
llvm::None
const NoneType None
Definition: None.h:24
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:110
llvm::SmallString< 32 >
llvm::InfoSectionUnitHeader::Format
dwarf::DwarfFormat Format
Definition: DWP.h:50
llvm::object::SectionRef
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:80
llvm::UnitIndexEntry::Contributions
DWARFUnitIndex::Entry::SectionContribution Contributions[8]
Definition: DWP.h:19
uint64_t
llvm::UnitIndexEntry::Name
std::string Name
Definition: DWP.h:20
llvm::getContributionIndex
unsigned getContributionIndex(DWARFSectionKind Kind, uint32_t IndexVersion)
Definition: DWP.cpp:158
llvm::InfoSectionUnitHeader
Definition: DWP.h:28
ArrayRef.h
ObjectFile.h
llvm::InfoSectionUnitHeader::Length
uint64_t Length
Definition: DWP.h:30
MCSection.h
llvm::parseInfoSectionUnitHeader
Expected< InfoSectionUnitHeader > parseInfoSectionUnitHeader(StringRef Info)
Definition: DWP.cpp:296
llvm::ArrayRef< std::string >
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
uint32_t
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
uint16_t
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
DWARFUnitIndex.h
Version
uint64_t Version
Definition: RawMemProfReader.cpp:41
llvm::UnitIndexEntry::DWOName
std::string DWOName
Definition: DWP.h:21
MCStreamer.h
llvm::writeStringsAndOffsets
void writeStringsAndOffsets(MCStreamer &Out, DWPStringPool &Strings, MCSection *StrOffsetSection, StringRef CurStrSection, StringRef CurStrOffsetSection, uint16_t Version)
Definition: DWP.cpp:355
llvm::UnitIndexEntry
Definition: DWP.h:18
llvm::CompileUnitIdentifiers::Signature
uint64_t Signature
Definition: DWP.h:58
llvm::CompileUnitIdentifiers
Definition: DWP.h:57
llvm::dwarf::DWARF32
@ DWARF32
Definition: Dwarf.h:93
llvm::buildDuplicateError
Error buildDuplicateError(const std::pair< uint64_t, UnitIndexEntry > &PrevE, const CompileUnitIdentifiers &ID, StringRef DWPName)
Definition: DWP.cpp:459