19 #include "llvm/Config/llvm-config.h" 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) {
99 if (AttrData.
getForm() == dwarf::DW_FORM_implicit_const)
110 O <<
"Abbreviation @" 118 for (
unsigned i = 0,
N =
Data.size(); i <
N; ++i) {
124 if (
Data[i].
getForm() == dwarf::DW_FORM_implicit_const)
125 O <<
" " <<
Data[i].getValue();
131 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 143 Abbrev->~DIEAbbrev();
154 AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) {
161 Abbreviations.push_back(New);
166 AbbreviationsSet.InsertNode(New, InsertPos);
171 if (!Abbreviations.empty()) {
183 return Owner.dyn_cast<
DIE*>();
189 if (V.getForm() == dwarf::DW_FORM_implicit_const)
191 V.getDIEInteger().getValue());
198 const DIEUnit *Unit = getUnit();
199 assert(Unit &&
"DIE must be owned by a DIEUnit to get its absolute offset");
206 if (p->
getTag() == dwarf::DW_TAG_compile_unit ||
207 p->
getTag() == dwarf::DW_TAG_type_unit)
215 const DIE *UnitDie = getUnitDie();
217 return UnitDie->Owner.dyn_cast<
DIEUnit*>();
224 for (
const auto &V :
values())
225 if (V.getAttribute() == Attribute)
233 O << Type <<
": Size: " << Size <<
"\n";
236 const std::string Indent(IndentCount,
' ');
237 for (
const auto &V : Values.
values()) {
239 O <<
"Blk[" << I++ <<
"]";
248 const std::string Indent(IndentCount,
' ');
250 <<
", Offset: " <<
Offset <<
", Size: " <<
Size <<
"\n";
256 for (
const auto &V :
values()) {
265 for (
const auto &Child :
children())
266 Child.print(O, IndentCount + 4);
271 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 291 for (
const auto &V :
values())
292 CUOffset += V.SizeOf(AP);
300 CUOffset = Child.computeOffsetsAndAbbrevs(AP, AbbrevSet, CUOffset);
303 CUOffset +=
sizeof(int8_t);
321 assert((UnitTag == dwarf::DW_TAG_compile_unit ||
322 UnitTag == dwarf::DW_TAG_skeleton_unit ||
323 UnitTag == dwarf::DW_TAG_type_unit ||
324 UnitTag == dwarf::DW_TAG_partial_unit) &&
325 "expected a unit TAG");
332 #define HANDLE_DIEVALUE(T) \ 334 getDIE##T().EmitValue(AP, Form); \ 336 #include "llvm/CodeGen/DIEValue.def" 344 #define HANDLE_DIEVALUE(T) \ 346 return getDIE##T().SizeOf(AP, Form); 347 #include "llvm/CodeGen/DIEValue.def" 357 #define HANDLE_DIEVALUE(T) \ 359 getDIE##T().print(O); \ 361 #include "llvm/CodeGen/DIEValue.def" 365 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 379 case dwarf::DW_FORM_implicit_const:
380 case dwarf::DW_FORM_flag_present:
385 case dwarf::DW_FORM_flag:
386 case dwarf::DW_FORM_ref1:
387 case dwarf::DW_FORM_data1:
388 case dwarf::DW_FORM_strx1:
389 case dwarf::DW_FORM_addrx1:
390 case dwarf::DW_FORM_ref2:
391 case dwarf::DW_FORM_data2:
392 case dwarf::DW_FORM_strx2:
393 case dwarf::DW_FORM_addrx2:
394 case dwarf::DW_FORM_strx3:
395 case dwarf::DW_FORM_strp:
396 case dwarf::DW_FORM_ref4:
397 case dwarf::DW_FORM_data4:
398 case dwarf::DW_FORM_ref_sup4:
399 case dwarf::DW_FORM_strx4:
400 case dwarf::DW_FORM_addrx4:
401 case dwarf::DW_FORM_ref8:
402 case dwarf::DW_FORM_ref_sig8:
403 case dwarf::DW_FORM_data8:
404 case dwarf::DW_FORM_ref_sup8:
405 case dwarf::DW_FORM_GNU_ref_alt:
406 case dwarf::DW_FORM_GNU_strp_alt:
407 case dwarf::DW_FORM_line_strp:
408 case dwarf::DW_FORM_sec_offset:
409 case dwarf::DW_FORM_strp_sup:
410 case dwarf::DW_FORM_addr:
411 case dwarf::DW_FORM_ref_addr:
414 case dwarf::DW_FORM_GNU_str_index:
415 case dwarf::DW_FORM_GNU_addr_index:
416 case dwarf::DW_FORM_ref_udata:
417 case dwarf::DW_FORM_strx:
418 case dwarf::DW_FORM_addrx:
419 case dwarf::DW_FORM_rnglistx:
420 case dwarf::DW_FORM_udata:
423 case dwarf::DW_FORM_sdata:
442 case dwarf::DW_FORM_GNU_str_index:
443 case dwarf::DW_FORM_GNU_addr_index:
444 case dwarf::DW_FORM_ref_udata:
445 case dwarf::DW_FORM_strx:
446 case dwarf::DW_FORM_addrx:
447 case dwarf::DW_FORM_rnglistx:
448 case dwarf::DW_FORM_udata:
450 case dwarf::DW_FORM_sdata:
458 O <<
"Int: " << (int64_t)
Integer <<
" 0x";
475 if (Form == dwarf::DW_FORM_data4)
return 4;
476 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
477 if (Form == dwarf::DW_FORM_strp)
return 4;
492 Form == dwarf::DW_FORM_strp ||
493 Form == dwarf::DW_FORM_sec_offset ||
494 Form == dwarf::DW_FORM_ref_addr ||
495 Form == dwarf::DW_FORM_data4);
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;
515 uint64_t Offset =
CU->ExprRefedBaseTypes[
Index].Die->getOffset();
540 if (Form == dwarf::DW_FORM_data4)
return 4;
541 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
542 if (Form == dwarf::DW_FORM_strp)
return 4;
548 O <<
"Del: " << LabelHi->getName() <<
"-" << LabelLo->getName();
560 case dwarf::DW_FORM_GNU_str_index:
561 case dwarf::DW_FORM_strx:
562 case dwarf::DW_FORM_strx1:
563 case dwarf::DW_FORM_strx2:
564 case dwarf::DW_FORM_strx3:
565 case dwarf::DW_FORM_strx4:
568 case dwarf::DW_FORM_strp:
570 DIELabel(S.getSymbol()).EmitValue(AP, Form);
572 DIEInteger(S.getOffset()).EmitValue(AP, Form);
584 case dwarf::DW_FORM_GNU_str_index:
585 case dwarf::DW_FORM_strx:
586 case dwarf::DW_FORM_strx1:
587 case dwarf::DW_FORM_strx2:
588 case dwarf::DW_FORM_strx3:
589 case dwarf::DW_FORM_strx4:
590 return DIEInteger(S.getIndex()).SizeOf(AP, Form);
591 case dwarf::DW_FORM_strp:
593 return DIELabel(S.getSymbol()).SizeOf(AP, Form);
594 return DIEInteger(S.getOffset()).SizeOf(AP, Form);
602 O <<
"String: " << S.getString();
609 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: {
649 unsigned Addr =
Entry->getDebugSectionOffset();
651 Entry->getUnit()->getCrossSectionRelativeBaseAddress()) {
656 AP->
OutStreamer->EmitIntValue(Addr, SizeOf(AP, Form));
666 case dwarf::DW_FORM_ref1:
668 case dwarf::DW_FORM_ref2:
670 case dwarf::DW_FORM_ref4:
672 case dwarf::DW_FORM_ref8:
674 case dwarf::DW_FORM_ref_udata:
676 case dwarf::DW_FORM_ref_addr:
679 switch (AP->
OutStreamer->getContext().getDwarfFormat()) {
705 for (
const auto &V :
values())
706 Size += V.SizeOf(AP);
720 case dwarf::DW_FORM_block:
721 case dwarf::DW_FORM_exprloc:
725 for (
const auto &V :
values())
733 case dwarf::DW_FORM_block1:
return Size +
sizeof(int8_t);
734 case dwarf::DW_FORM_block2:
return Size +
sizeof(int16_t);
735 case dwarf::DW_FORM_block4:
return Size +
sizeof(int32_t);
736 case dwarf::DW_FORM_block:
737 case dwarf::DW_FORM_exprloc:
756 for (
const auto &V :
values())
757 Size += V.SizeOf(AP);
772 case dwarf::DW_FORM_string:
break;
773 case dwarf::DW_FORM_data16:
break;
776 for (
const auto &V :
values())
784 case dwarf::DW_FORM_block1:
return Size +
sizeof(int8_t);
785 case dwarf::DW_FORM_block2:
return Size +
sizeof(int16_t);
786 case dwarf::DW_FORM_block4:
return Size +
sizeof(int32_t);
788 case dwarf::DW_FORM_data16:
return 16;
803 if (Form == dwarf::DW_FORM_loclistx)
805 if (Form == dwarf::DW_FORM_data4)
807 if (Form == dwarf::DW_FORM_sec_offset)
815 if (Form == dwarf::DW_FORM_loclistx) {
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit debug information entry offset.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit block data.
iterator_range< typename GraphTraits< GraphType >::ChildIteratorType > children(const typename GraphTraits< GraphType >::NodeRef &G)
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of location data in bytes.
void print(raw_ostream &O) const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
void EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit location data.
This class represents lattice values for constants.
#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 ...
const DebugLocStream & getDebugLocs() const
Returns the entries for the .debug_loc section.
uint16_t getDwarfVersion() const
Collects and handles dwarf debug information.
void EmitValue(const AsmPrinter *AP) const
Emit value via the Dwarf writer.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
unsigned getDebugSectionOffset() const
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
void AddAttribute(dwarf::Attribute Attribute, dwarf::Form Form)
Adds another set of attribute information to the abbreviation.
void print(raw_ostream &O) const
virtual void EmitDebugValue(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
void print(raw_ostream &O) const
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support...
Dwarf abbreviation data, describes one attribute of a Dwarf abbreviation.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.
void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
void print(raw_ostream &O) const
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of the base type reference in bytes.
void AddImplicitConstAttribute(dwarf::Attribute Attribute, int64_t Value)
Adds attribute with DW_FORM_implicit_const value.
const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to...
StringRef FormEncodingString(unsigned Encoding)
void print(raw_ostream &O) const
dwarf::Form getForm() const
void AddInteger(signed I)
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
DIEAbbrev generateAbbrev() const
Generate the abbreviation for this DIE.
void print(raw_ostream &O) const
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
StringRef AttributeString(unsigned Attribute)
void setNumber(unsigned N)
bool doesDwarfUseRelocationsAcrossSections() const
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of block data in bytes.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
Helps unique DIEAbbrev objects and assigns abbreviation numbers.
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 Emit(const AsmPrinter *AP) const
Print the abbreviation using the specified asm printer.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit delta value.
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...
void print(raw_ostream &O) const
void EmitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
A structured debug information entry.
void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to...
This class is intended to be used as a driving class for all asm writers.
void print(raw_ostream &O) const
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit string value.
dwarf::Attribute getAttribute() const
Accessors.
static LLVM_DUMP_METHOD void printValues(raw_ostream &O, const DIEValueList &Values, StringRef Type, unsigned Size, unsigned IndentCount)
DwarfDebug * getDwarfDebug()
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...
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
void print(raw_ostream &O) const
#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.
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
unsigned SizeOf(const AsmPrinter *AP) const
Return the size of a value in bytes.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of expression value in bytes.
void EmitSLEB128(int64_t Value, const char *Desc=nullptr) const
Emit the specified signed leb128 value.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of label value in bytes.
DIEUnit(uint16_t Version, uint8_t AddrSize, dwarf::Tag UnitTag)
Represents a compile or type unit.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit base type reference.
void print(raw_ostream &O) const
static Optional< unsigned > getTag(const TargetRegisterInfo *TRI, const MachineInstr &MI, const LoadInfo &LI)
void emitInt32(int Value) const
Emit a long directive and value.
const List & getList(size_t LI) const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void emitDwarfAbbrevs(const T &Abbrevs) const
Emit Dwarf abbreviation table.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.
dwarf::Tag getTag() const
static constexpr unsigned ULEB128PadSize
Optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
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.
void print(raw_ostream &O, unsigned IndentCount=0) const
StringRef TagString(unsigned Tag)
void print(raw_ostream &O) const
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...
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.
StringRef ChildrenString(unsigned Children)
DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
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...
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit expression value.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void emitInt8(int Value) const
Emit a byte directive and value.
LLVM Value Representation.
unsigned ComputeSize(const AsmPrinter *AP) const
ComputeSize - Calculate the size of the location expression.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of integer value in bytes.
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 SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
unsigned getDebugSectionOffset() const
Get the absolute offset within the .debug_info or .debug_types section for this DIE.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
StringRef - Represent a constant reference to a string, i.e.
void Emit(const AsmPrinter *AP, MCSection *Section) const
Print all abbreviations using the specified asm printer.
unsigned ComputeSize(const AsmPrinter *AP) const
ComputeSize - Calculate the size of the location expression.
void EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit integer of appropriate size.
void print(raw_ostream &O) const
void emitInt16(int Value) const
Emit a short directive and value.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.