58 for (
unsigned i = 0,
N = Data.size();
i <
N; ++
i)
72 for (
unsigned i = 0,
N = Data.size();
i <
N; ++
i) {
84 if (AttrData.
getForm() == dwarf::DW_FORM_implicit_const) {
86 "DW_FORM_implicit_const is supported starting from DWARFv5");
106 for (
unsigned i = 0,
N = Data.size();
i <
N; ++
i) {
124 Abbrev->~DIEAbbrev();
135 AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) {
142 Abbreviations.push_back(New);
147 AbbreviationsSet.InsertNode(New, InsertPos);
152 if (!Abbreviations.empty()) {
164 return Owner.dyn_cast<
DIE*>();
170 if (V.getForm() == dwarf::DW_FORM_implicit_const)
172 V.getDIEInteger().getValue());
180 assert(Unit &&
"DIE must be owned by a DIEUnit to get its absolute offset");
187 if (p->
getTag() == dwarf::DW_TAG_compile_unit ||
188 p->
getTag() == dwarf::DW_TAG_type_unit)
198 return UnitDie->Owner.dyn_cast<
DIEUnit*>();
205 for (
const auto &V :
values())
214 O << Type <<
": Size: " << Size <<
"\n";
217 const std::string Indent(IndentCount,
' ');
218 for (
const auto &V : Values.
values()) {
220 O <<
"Blk[" << I++ <<
"]";
229 const std::string Indent(IndentCount,
' ');
231 <<
", Offset: " << Offset <<
", Size: " << Size <<
"\n";
237 for (
const auto &V :
values()) {
246 for (
const auto &Child :
children())
247 Child.print(O, IndentCount + 4);
271 for (
const auto &V :
values())
272 CUOffset += V.SizeOf(AP);
280 CUOffset = Child.computeOffsetsAndAbbrevs(AP, AbbrevSet, CUOffset);
283 CUOffset +=
sizeof(int8_t);
301 assert((UnitTag == dwarf::DW_TAG_compile_unit ||
302 UnitTag == dwarf::DW_TAG_type_unit ||
303 UnitTag == dwarf::DW_TAG_partial_unit) &&
"expected a unit TAG");
310 #define HANDLE_DIEVALUE(T) \
312 getDIE##T().EmitValue(AP, Form); \
314 #include "llvm/CodeGen/DIEValue.def"
322 #define HANDLE_DIEVALUE(T) \
324 return getDIE##T().SizeOf(AP, Form);
325 #include "llvm/CodeGen/DIEValue.def"
335 #define HANDLE_DIEVALUE(T) \
337 getDIE##T().print(O); \
339 #include "llvm/CodeGen/DIEValue.def"
356 case dwarf::DW_FORM_implicit_const:
358 case dwarf::DW_FORM_flag_present:
363 case dwarf::DW_FORM_flag:
365 case dwarf::DW_FORM_ref1:
367 case dwarf::DW_FORM_data1:
369 case dwarf::DW_FORM_ref2:
371 case dwarf::DW_FORM_data2:
373 case dwarf::DW_FORM_strp:
375 case dwarf::DW_FORM_ref4:
377 case dwarf::DW_FORM_data4:
379 case dwarf::DW_FORM_ref8:
381 case dwarf::DW_FORM_ref_sig8:
383 case dwarf::DW_FORM_data8:
385 case dwarf::DW_FORM_GNU_ref_alt:
387 case dwarf::DW_FORM_GNU_strp_alt:
389 case dwarf::DW_FORM_line_strp:
391 case dwarf::DW_FORM_sec_offset:
393 case dwarf::DW_FORM_strp_sup:
395 case dwarf::DW_FORM_ref_sup:
397 case dwarf::DW_FORM_addr:
399 case dwarf::DW_FORM_ref_addr:
402 case dwarf::DW_FORM_GNU_str_index:
404 case dwarf::DW_FORM_GNU_addr_index:
406 case dwarf::DW_FORM_ref_udata:
408 case dwarf::DW_FORM_udata:
411 case dwarf::DW_FORM_sdata:
423 case dwarf::DW_FORM_flag_present:
return 0;
426 case dwarf::DW_FORM_data1:
return sizeof(int8_t);
428 case dwarf::DW_FORM_data2:
return sizeof(int16_t);
430 case dwarf::DW_FORM_data4:
return sizeof(int32_t);
433 case dwarf::DW_FORM_data8:
return sizeof(int64_t);
434 case dwarf::DW_FORM_ref_addr:
438 case dwarf::DW_FORM_strp:
440 case dwarf::DW_FORM_GNU_ref_alt:
442 case dwarf::DW_FORM_GNU_strp_alt:
444 case dwarf::DW_FORM_line_strp:
446 case dwarf::DW_FORM_sec_offset:
448 case dwarf::DW_FORM_strp_sup:
450 case dwarf::DW_FORM_ref_sup:
451 switch (AP->
OutStreamer->getContext().getDwarfFormat()) {
458 case dwarf::DW_FORM_GNU_str_index:
460 case dwarf::DW_FORM_GNU_addr_index:
462 case dwarf::DW_FORM_ref_udata:
464 case dwarf::DW_FORM_udata:
466 case dwarf::DW_FORM_sdata:
468 case dwarf::DW_FORM_addr:
476 O <<
"Int: " << (int64_t)Integer <<
" 0x";
493 if (Form == dwarf::DW_FORM_data4)
return 4;
494 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
495 if (Form == dwarf::DW_FORM_strp)
return 4;
510 Form == dwarf::DW_FORM_strp ||
511 Form == dwarf::DW_FORM_sec_offset ||
512 Form == dwarf::DW_FORM_ref_addr ||
513 Form == dwarf::DW_FORM_data4);
519 if (Form == dwarf::DW_FORM_data4)
return 4;
520 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
521 if (Form == dwarf::DW_FORM_strp)
return 4;
541 if (Form == dwarf::DW_FORM_data4)
return 4;
542 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
543 if (Form == dwarf::DW_FORM_strp)
return 4;
560 (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
561 "Expected valid string form");
564 if (Form == dwarf::DW_FORM_GNU_str_index) {
570 assert(Form == dwarf::DW_FORM_strp);
584 (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
585 "Expected valid string form");
588 if (Form == dwarf::DW_FORM_GNU_str_index)
608 if (Form == dwarf::DW_FORM_string) {
624 O <<
"InlineString: " << S;
636 case dwarf::DW_FORM_ref1:
637 case dwarf::DW_FORM_ref2:
638 case dwarf::DW_FORM_ref4:
639 case dwarf::DW_FORM_ref8:
643 case dwarf::DW_FORM_ref_udata:
647 case dwarf::DW_FORM_ref_addr: {
654 "TODO: dwo files can't have relocations.");
656 assert(Unit &&
"CUDie should belong to a CU.");
674 case dwarf::DW_FORM_ref1:
676 case dwarf::DW_FORM_ref2:
678 case dwarf::DW_FORM_ref4:
680 case dwarf::DW_FORM_ref8:
682 case dwarf::DW_FORM_ref_udata:
684 case dwarf::DW_FORM_ref_addr:
687 switch (AP->
OutStreamer->getContext().getDwarfFormat()) {
713 for (
const auto &V :
values())
714 Size += V.SizeOf(AP);
725 case dwarf::DW_FORM_block1: Asm->
EmitInt8(Size);
break;
726 case dwarf::DW_FORM_block2: Asm->
EmitInt16(Size);
break;
727 case dwarf::DW_FORM_block4: Asm->
EmitInt32(Size);
break;
728 case dwarf::DW_FORM_block:
729 case dwarf::DW_FORM_exprloc:
733 for (
const auto &V :
values())
741 case dwarf::DW_FORM_block1:
return Size +
sizeof(int8_t);
742 case dwarf::DW_FORM_block2:
return Size +
sizeof(int16_t);
743 case dwarf::DW_FORM_block4:
return Size +
sizeof(int32_t);
744 case dwarf::DW_FORM_block:
745 case dwarf::DW_FORM_exprloc:
764 for (
const auto &V :
values())
765 Size += V.SizeOf(AP);
776 case dwarf::DW_FORM_block1: Asm->
EmitInt8(Size);
break;
777 case dwarf::DW_FORM_block2: Asm->
EmitInt16(Size);
break;
778 case dwarf::DW_FORM_block4: Asm->
EmitInt32(Size);
break;
779 case dwarf::DW_FORM_block: Asm->
EmitULEB128(Size);
break;
782 for (
const auto &V :
values())
790 case dwarf::DW_FORM_block1:
return Size +
sizeof(int8_t);
791 case dwarf::DW_FORM_block2:
return Size +
sizeof(int16_t);
792 case dwarf::DW_FORM_block4:
return Size +
sizeof(int32_t);
808 if (Form == dwarf::DW_FORM_data4)
810 if (Form == dwarf::DW_FORM_sec_offset)
DIEAbbrev generateAbbrev() const
Generate the abbreviation for this DIE.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit block data.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit debug information entry offset.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit string value.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void EmitInt8(int Value) const
Emit a byte directive and value.
void EmitValue(const AsmPrinter *AP) const
Emit value via the Dwarf writer.
void print(raw_ostream &O) const
void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label+Offset" where the size in bytes of the directive is specified by Siz...
void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
Emit something like ".long Hi-Lo" where the size in bytes of the directive is specified by Size and H...
Collects and handles dwarf debug information.
virtual void EmitDebugValue(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
void EmitInt32(int Value) const
Emit a long directive and value.
void EmitLabelReference(const MCSymbol *Label, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label" where the size in bytes of the directive is specified by Size and L...
void print(raw_ostream &O) const
void AddAttribute(dwarf::Attribute Attribute, dwarf::Form Form)
Adds another set of attribute information to the abbreviation.
void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to...
Dwarf abbreviation data, describes one attribute of a Dwarf abbreviation.
void print(raw_ostream &O, unsigned IndentCount=0) const
dwarf::Form getForm() const
void AddImplicitConstAttribute(dwarf::Attribute Attribute, int64_t Value)
Adds attribute with DW_FORM_implicit_const value.
StringRef FormEncodingString(unsigned Encoding)
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.
void AddInteger(signed I)
uint16_t getDwarfVersion() const
const List & getList(size_t LI) const
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit location data.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
StringRef AttributeString(unsigned Attribute)
void setNumber(unsigned N)
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
void EmitInt16(int Value) const
Emit a short directive and value.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
unsigned getIndex() const
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit expression value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
dwarf::Tag getTag() const
void print(raw_ostream &O) const
Helps unique DIEAbbrev objects and assigns abbreviation numbers.
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of label value in bytes.
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support...
unsigned getDebugSectionOffset() const
Get the absolute offset within the .debug_info or .debug_types section for this DIE.
const MCAsmInfo * MAI
Target Asm Printer information.
The instances of the Type class are immutable: once they are created, they are never changed...
unsigned getAbbrevNumber() const
DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
void EmitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
A structured debug information entry.
void print(raw_ostream &O) const
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit delta value.
void Emit(const AsmPrinter *AP, MCSection *Section) const
Print all abbreviations using the specified asm printer.
This class is intended to be used as a driving class for all asm writers.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of integer value in bytes.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of block data in bytes.
void print(raw_ostream &O) const
static LLVM_DUMP_METHOD void printValues(raw_ostream &O, const DIEValueList &Values, StringRef Type, unsigned Size, unsigned IndentCount)
DwarfDebug * getDwarfDebug()
void print(raw_ostream &O) const
unsigned getOffset() const
void print(raw_ostream &O)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned computeOffsetsAndAbbrevs(const AsmPrinter *AP, DIEAbbrevSet &AbbrevSet, unsigned CUOffset)
Compute the offset of this DIE and all its children.
void print(raw_ostream &O) const
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
dwarf::Attribute getAttribute() const
Accessors.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of expression value in bytes.
const DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to...
unsigned getDebugSectionOffset() const
DIEUnit(uint16_t Version, uint8_t AddrSize, dwarf::Tag UnitTag)
The size in bytes of an address for this unit.
const DebugLocStream & getDebugLocs() const
Returns the entries for the .debug_loc section.
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
Represents a compile or type unit.
void emitDwarfAbbrevs(const T &Abbrevs) const
Emit Dwarf abbreviation table.
MCSymbol * getBeginSymbol()
StringRef getString() const
void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned SizeOf(const AsmPrinter *AP) const
Return the size of a value in bytes.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of location data in bytes.
DIEAbbrev & uniqueAbbreviation(DIE &Die)
Generate the abbreviation declaration for a DIE and return a pointer to the generated abbreviation...
Dwarf abbreviation, describes the organization of a debug information object.
StringRef TagString(unsigned Tag)
StringRef getName() const
getName - Get the symbol name.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit integer of appropriate size.
void EmitSLEB128(int64_t Value, const char *Desc=nullptr) const
Emit the specified signed leb128 value.
void setOffset(unsigned O)
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
void print(raw_ostream &O) const
unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
StringRef ChildrenString(unsigned Children)
std::vector< uint8_t > Unit
void print(raw_ostream &O) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned ComputeSize(const AsmPrinter *AP) const
ComputeSize - Calculate the size of the location expression.
MCSymbol * getSymbol() const
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
void setAbbrevNumber(unsigned I)
Set the abbreviation number for this DIE.
This class implements an extremely fast bulk output stream that can only output to a stream...
unsigned ComputeSize(const AsmPrinter *AP) const
ComputeSize - Calculate the size of the location expression.
void Emit(const AsmPrinter *AP) const
Print the abbreviation using the specified asm printer.
StringRef - Represent a constant reference to a string, i.e.
void print(raw_ostream &O) const
void print(raw_ostream &O) const
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
bool doesDwarfUseRelocationsAcrossSections() const
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.