20 #include "llvm/Config/llvm-config.h" 35 #define DEBUG_TYPE "dwarfdebug" 48 if (Form == dwarf::DW_FORM_implicit_const)
63 for (
unsigned i = 0,
N =
Data.size(); i <
N; ++i)
77 for (
unsigned i = 0,
N =
Data.size(); i <
N; ++i) {
100 if (AttrData.
getForm() == dwarf::DW_FORM_implicit_const)
111 O <<
"Abbreviation @" 119 for (
unsigned i = 0,
N =
Data.size(); i <
N; ++i) {
125 if (
Data[i].
getForm() == dwarf::DW_FORM_implicit_const)
126 O <<
" " <<
Data[i].getValue();
132 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 144 Abbrev->~DIEAbbrev();
155 AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) {
162 Abbreviations.push_back(New);
167 AbbreviationsSet.InsertNode(New, InsertPos);
172 if (!Abbreviations.empty()) {
184 return Owner.dyn_cast<
DIE*>();
190 if (V.getForm() == dwarf::DW_FORM_implicit_const)
192 V.getDIEInteger().getValue());
199 const DIEUnit *Unit = getUnit();
200 assert(Unit &&
"DIE must be owned by a DIEUnit to get its absolute offset");
207 if (p->
getTag() == dwarf::DW_TAG_compile_unit ||
208 p->
getTag() == dwarf::DW_TAG_type_unit)
216 const DIE *UnitDie = getUnitDie();
218 return UnitDie->Owner.dyn_cast<
DIEUnit*>();
225 for (
const auto &V :
values())
226 if (V.getAttribute() == Attribute)
234 O << Type <<
": Size: " << Size <<
"\n";
237 const std::string
Indent(IndentCount,
' ');
238 for (
const auto &V : Values.
values()) {
240 O <<
"Blk[" << I++ <<
"]";
249 const std::string
Indent(IndentCount,
' ');
251 <<
", Offset: " <<
Offset <<
", Size: " <<
Size <<
"\n";
257 for (
const auto &V :
values()) {
266 for (
const auto &Child :
children())
267 Child.print(O, IndentCount + 4);
272 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 292 for (
const auto &V :
values())
293 CUOffset += V.SizeOf(AP);
301 CUOffset = Child.computeOffsetsAndAbbrevs(AP, AbbrevSet, CUOffset);
304 CUOffset +=
sizeof(int8_t);
322 assert((UnitTag == dwarf::DW_TAG_compile_unit ||
323 UnitTag == dwarf::DW_TAG_type_unit ||
324 UnitTag == dwarf::DW_TAG_partial_unit) &&
"expected a unit TAG");
331 #define HANDLE_DIEVALUE(T) \ 333 getDIE##T().EmitValue(AP, Form); \ 335 #include "llvm/CodeGen/DIEValue.def" 343 #define HANDLE_DIEVALUE(T) \ 345 return getDIE##T().SizeOf(AP, Form); 346 #include "llvm/CodeGen/DIEValue.def" 356 #define HANDLE_DIEVALUE(T) \ 358 getDIE##T().print(O); \ 360 #include "llvm/CodeGen/DIEValue.def" 364 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 378 case dwarf::DW_FORM_implicit_const:
379 case dwarf::DW_FORM_flag_present:
384 case dwarf::DW_FORM_flag:
385 case dwarf::DW_FORM_ref1:
386 case dwarf::DW_FORM_data1:
387 case dwarf::DW_FORM_strx1:
388 case dwarf::DW_FORM_addrx1:
389 case dwarf::DW_FORM_ref2:
390 case dwarf::DW_FORM_data2:
391 case dwarf::DW_FORM_strx2:
392 case dwarf::DW_FORM_addrx2:
393 case dwarf::DW_FORM_strx3:
394 case dwarf::DW_FORM_strp:
395 case dwarf::DW_FORM_ref4:
396 case dwarf::DW_FORM_data4:
397 case dwarf::DW_FORM_ref_sup4:
398 case dwarf::DW_FORM_strx4:
399 case dwarf::DW_FORM_addrx4:
400 case dwarf::DW_FORM_ref8:
401 case dwarf::DW_FORM_ref_sig8:
402 case dwarf::DW_FORM_data8:
403 case dwarf::DW_FORM_ref_sup8:
404 case dwarf::DW_FORM_GNU_ref_alt:
405 case dwarf::DW_FORM_GNU_strp_alt:
406 case dwarf::DW_FORM_line_strp:
407 case dwarf::DW_FORM_sec_offset:
408 case dwarf::DW_FORM_strp_sup:
409 case dwarf::DW_FORM_addr:
410 case dwarf::DW_FORM_ref_addr:
413 case dwarf::DW_FORM_GNU_str_index:
414 case dwarf::DW_FORM_GNU_addr_index:
415 case dwarf::DW_FORM_ref_udata:
416 case dwarf::DW_FORM_strx:
417 case dwarf::DW_FORM_udata:
420 case dwarf::DW_FORM_sdata:
439 case dwarf::DW_FORM_GNU_str_index:
440 case dwarf::DW_FORM_GNU_addr_index:
441 case dwarf::DW_FORM_ref_udata:
442 case dwarf::DW_FORM_strx:
443 case dwarf::DW_FORM_udata:
445 case dwarf::DW_FORM_sdata:
453 O <<
"Int: " << (int64_t)
Integer <<
" 0x";
470 if (Form == dwarf::DW_FORM_data4)
return 4;
471 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
472 if (Form == dwarf::DW_FORM_strp)
return 4;
487 Form == dwarf::DW_FORM_strp ||
488 Form == dwarf::DW_FORM_sec_offset ||
489 Form == dwarf::DW_FORM_ref_addr ||
490 Form == dwarf::DW_FORM_data4);
496 if (Form == dwarf::DW_FORM_data4)
return 4;
497 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
498 if (Form == dwarf::DW_FORM_strp)
return 4;
518 if (Form == dwarf::DW_FORM_data4)
return 4;
519 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
520 if (Form == dwarf::DW_FORM_strp)
return 4;
526 O <<
"Del: " << LabelHi->getName() <<
"-" << LabelLo->getName();
538 case dwarf::DW_FORM_GNU_str_index:
539 case dwarf::DW_FORM_strx:
540 case dwarf::DW_FORM_strx1:
541 case dwarf::DW_FORM_strx2:
542 case dwarf::DW_FORM_strx3:
543 case dwarf::DW_FORM_strx4:
546 case dwarf::DW_FORM_strp:
548 DIELabel(S.getSymbol()).EmitValue(AP, Form);
550 DIEInteger(S.getOffset()).EmitValue(AP, Form);
562 case dwarf::DW_FORM_GNU_str_index:
563 case dwarf::DW_FORM_strx:
564 case dwarf::DW_FORM_strx1:
565 case dwarf::DW_FORM_strx2:
566 case dwarf::DW_FORM_strx3:
567 case dwarf::DW_FORM_strx4:
568 return DIEInteger(S.getIndex()).SizeOf(AP, Form);
569 case dwarf::DW_FORM_strp:
571 return DIELabel(S.getSymbol()).SizeOf(AP, Form);
572 return DIEInteger(S.getOffset()).SizeOf(AP, Form);
580 O <<
"String: " << S.getString();
587 if (Form == dwarf::DW_FORM_string) {
603 O <<
"InlineString: " << S;
615 case dwarf::DW_FORM_ref1:
616 case dwarf::DW_FORM_ref2:
617 case dwarf::DW_FORM_ref4:
618 case dwarf::DW_FORM_ref8:
619 AP->
OutStreamer->EmitIntValue(Entry->getOffset(), SizeOf(AP, Form));
622 case dwarf::DW_FORM_ref_udata:
626 case dwarf::DW_FORM_ref_addr: {
628 unsigned Addr = Entry->getDebugSectionOffset();
630 Entry->getUnit()->getCrossSectionRelativeBaseAddress()) {
635 AP->
OutStreamer->EmitIntValue(Addr, SizeOf(AP, Form));
645 case dwarf::DW_FORM_ref1:
647 case dwarf::DW_FORM_ref2:
649 case dwarf::DW_FORM_ref4:
651 case dwarf::DW_FORM_ref8:
653 case dwarf::DW_FORM_ref_udata:
655 case dwarf::DW_FORM_ref_addr:
658 switch (AP->
OutStreamer->getContext().getDwarfFormat()) {
684 for (
const auto &V :
values())
685 Size += V.SizeOf(AP);
699 case dwarf::DW_FORM_block:
700 case dwarf::DW_FORM_exprloc:
704 for (
const auto &V :
values())
712 case dwarf::DW_FORM_block1:
return Size +
sizeof(int8_t);
713 case dwarf::DW_FORM_block2:
return Size +
sizeof(int16_t);
714 case dwarf::DW_FORM_block4:
return Size +
sizeof(int32_t);
715 case dwarf::DW_FORM_block:
716 case dwarf::DW_FORM_exprloc:
735 for (
const auto &V :
values())
736 Size += V.SizeOf(AP);
751 case dwarf::DW_FORM_string:
break;
752 case dwarf::DW_FORM_data16:
break;
755 for (
const auto &V :
values())
763 case dwarf::DW_FORM_block1:
return Size +
sizeof(int8_t);
764 case dwarf::DW_FORM_block2:
return Size +
sizeof(int16_t);
765 case dwarf::DW_FORM_block4:
return Size +
sizeof(int32_t);
767 case dwarf::DW_FORM_data16:
return 16;
782 if (Form == dwarf::DW_FORM_data4)
784 if (Form == dwarf::DW_FORM_sec_offset)
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.
Compute iterated dominance frontiers using a linear time algorithm.
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.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
void AddAttribute(dwarf::Attribute Attribute, dwarf::Form Form)
Adds another set of attribute information to the abbreviation.
void print(raw_ostream &O) const
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.
virtual void EmitDebugThreadLocal(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
void print(raw_ostream &O) const
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.
const DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to...
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
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.
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 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
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 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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
unsigned ComputeSize(const AsmPrinter *AP) const
ComputeSize - Calculate the size of the location expression.
void EmitULEB128(uint64_t Value, const char *Desc=nullptr) const
Emit the specified unsigned leb128 value.
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.