34 #define DEBUG_TYPE "dwarfdebug"
47 if (Form == dwarf::DW_FORM_implicit_const)
62 for (
unsigned i = 0,
N = Data.size(); i <
N; ++i)
76 for (
unsigned i = 0,
N = Data.size(); i <
N; ++i) {
98 if (AttrData.
getForm() == dwarf::DW_FORM_implicit_const)
109 O <<
"Abbreviation @"
117 for (
unsigned i = 0,
N = Data.size(); i <
N; ++i) {
123 if (Data[i].getForm() == dwarf::DW_FORM_implicit_const)
124 O <<
" " << Data[i].getValue();
130 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
142 Abbrev->~DIEAbbrev();
153 AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) {
160 Abbreviations.push_back(New);
165 AbbreviationsSet.InsertNode(New, InsertPos);
170 if (!Abbreviations.empty()) {
182 return Owner.dyn_cast<
DIE*>();
188 if (V.getForm() == dwarf::DW_FORM_implicit_const)
190 V.getDIEInteger().getValue());
198 assert(Unit &&
"DIE must be owned by a DIEUnit to get its absolute offset");
205 if (p->
getTag() == dwarf::DW_TAG_compile_unit ||
206 p->
getTag() == dwarf::DW_TAG_type_unit)
216 return UnitDie->Owner.dyn_cast<
DIEUnit*>();
223 for (
const auto &V :
values())
232 O << Type <<
": Size: " << Size <<
"\n";
235 const std::string Indent(IndentCount,
' ');
236 for (
const auto &V : Values.
values()) {
238 O <<
"Blk[" << I++ <<
"]";
247 const std::string Indent(IndentCount,
' ');
249 <<
", Offset: " << Offset <<
", Size: " << Size <<
"\n";
255 for (
const auto &V :
values()) {
264 for (
const auto &Child :
children())
265 Child.print(O, IndentCount + 4);
270 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
290 for (
const auto &V :
values())
291 CUOffset += V.SizeOf(AP);
299 CUOffset = Child.computeOffsetsAndAbbrevs(AP, AbbrevSet, CUOffset);
302 CUOffset +=
sizeof(int8_t);
320 assert((UnitTag == dwarf::DW_TAG_compile_unit ||
321 UnitTag == dwarf::DW_TAG_type_unit ||
322 UnitTag == dwarf::DW_TAG_partial_unit) &&
"expected a unit TAG");
329 #define HANDLE_DIEVALUE(T) \
331 getDIE##T().EmitValue(AP, Form); \
333 #include "llvm/CodeGen/DIEValue.def"
341 #define HANDLE_DIEVALUE(T) \
343 return getDIE##T().SizeOf(AP, Form);
344 #include "llvm/CodeGen/DIEValue.def"
354 #define HANDLE_DIEVALUE(T) \
356 getDIE##T().print(O); \
358 #include "llvm/CodeGen/DIEValue.def"
362 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
376 case dwarf::DW_FORM_implicit_const:
377 case dwarf::DW_FORM_flag_present:
382 case dwarf::DW_FORM_flag:
383 case dwarf::DW_FORM_ref1:
384 case dwarf::DW_FORM_data1:
385 case dwarf::DW_FORM_strx1:
386 case dwarf::DW_FORM_addrx1:
387 case dwarf::DW_FORM_ref2:
388 case dwarf::DW_FORM_data2:
389 case dwarf::DW_FORM_strx2:
390 case dwarf::DW_FORM_addrx2:
391 case dwarf::DW_FORM_strp:
392 case dwarf::DW_FORM_ref4:
393 case dwarf::DW_FORM_data4:
394 case dwarf::DW_FORM_ref_sup4:
395 case dwarf::DW_FORM_strx4:
396 case dwarf::DW_FORM_addrx4:
397 case dwarf::DW_FORM_ref8:
398 case dwarf::DW_FORM_ref_sig8:
399 case dwarf::DW_FORM_data8:
400 case dwarf::DW_FORM_ref_sup8:
401 case dwarf::DW_FORM_GNU_ref_alt:
402 case dwarf::DW_FORM_GNU_strp_alt:
403 case dwarf::DW_FORM_line_strp:
404 case dwarf::DW_FORM_sec_offset:
405 case dwarf::DW_FORM_strp_sup:
406 case dwarf::DW_FORM_addr:
407 case dwarf::DW_FORM_ref_addr:
410 case dwarf::DW_FORM_GNU_str_index:
411 case dwarf::DW_FORM_GNU_addr_index:
412 case dwarf::DW_FORM_ref_udata:
413 case dwarf::DW_FORM_udata:
416 case dwarf::DW_FORM_sdata:
427 case dwarf::DW_FORM_implicit_const:
428 case dwarf::DW_FORM_flag_present:
430 case dwarf::DW_FORM_flag:
431 case dwarf::DW_FORM_ref1:
432 case dwarf::DW_FORM_data1:
433 case dwarf::DW_FORM_strx1:
434 case dwarf::DW_FORM_addrx1:
435 return sizeof(int8_t);
436 case dwarf::DW_FORM_ref2:
437 case dwarf::DW_FORM_data2:
438 case dwarf::DW_FORM_strx2:
439 case dwarf::DW_FORM_addrx2:
440 return sizeof(int16_t);
441 case dwarf::DW_FORM_ref4:
442 case dwarf::DW_FORM_data4:
443 case dwarf::DW_FORM_ref_sup4:
444 case dwarf::DW_FORM_strx4:
445 case dwarf::DW_FORM_addrx4:
446 return sizeof(int32_t);
447 case dwarf::DW_FORM_ref8:
448 case dwarf::DW_FORM_ref_sig8:
449 case dwarf::DW_FORM_data8:
450 case dwarf::DW_FORM_ref_sup8:
451 return sizeof(int64_t);
452 case dwarf::DW_FORM_ref_addr:
456 case dwarf::DW_FORM_strp:
457 case dwarf::DW_FORM_GNU_ref_alt:
458 case dwarf::DW_FORM_GNU_strp_alt:
459 case dwarf::DW_FORM_line_strp:
460 case dwarf::DW_FORM_sec_offset:
461 case dwarf::DW_FORM_strp_sup:
462 switch (AP->
OutStreamer->getContext().getDwarfFormat()) {
469 case dwarf::DW_FORM_GNU_str_index:
470 case dwarf::DW_FORM_GNU_addr_index:
471 case dwarf::DW_FORM_ref_udata:
472 case dwarf::DW_FORM_udata:
474 case dwarf::DW_FORM_sdata:
476 case dwarf::DW_FORM_addr:
484 O <<
"Int: " << (int64_t)Integer <<
" 0x";
501 if (Form == dwarf::DW_FORM_data4)
return 4;
502 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
503 if (Form == dwarf::DW_FORM_strp)
return 4;
518 Form == dwarf::DW_FORM_strp ||
519 Form == dwarf::DW_FORM_sec_offset ||
520 Form == dwarf::DW_FORM_ref_addr ||
521 Form == dwarf::DW_FORM_data4);
527 if (Form == dwarf::DW_FORM_data4)
return 4;
528 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
529 if (Form == dwarf::DW_FORM_strp)
return 4;
549 if (Form == dwarf::DW_FORM_data4)
return 4;
550 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
551 if (Form == dwarf::DW_FORM_strp)
return 4;
568 (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
569 "Expected valid string form");
572 if (Form == dwarf::DW_FORM_GNU_str_index) {
578 assert(Form == dwarf::DW_FORM_strp);
592 (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
593 "Expected valid string form");
596 if (Form == dwarf::DW_FORM_GNU_str_index)
616 if (Form == dwarf::DW_FORM_string) {
632 O <<
"InlineString: " << S;
644 case dwarf::DW_FORM_ref1:
645 case dwarf::DW_FORM_ref2:
646 case dwarf::DW_FORM_ref4:
647 case dwarf::DW_FORM_ref8:
651 case dwarf::DW_FORM_ref_udata:
655 case dwarf::DW_FORM_ref_addr: {
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...
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
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.
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
virtual void EmitDebugThreadLocal(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
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.
void print(raw_ostream &O) const
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
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)
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.
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.
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
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)
bool isValidFormForVersion(Form F, unsigned Version, bool ExtensionsOk=true)
Tells whether the specified form is defined in the specified version, or is an extension if extension...
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
LLVM Value Representation.
#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
bool doesDwarfUseRelocationsAcrossSections() const
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.