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());
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_addrx:
418 case dwarf::DW_FORM_rnglistx:
419 case dwarf::DW_FORM_udata:
422 case dwarf::DW_FORM_sdata:
441 case dwarf::DW_FORM_GNU_str_index:
442 case dwarf::DW_FORM_GNU_addr_index:
443 case dwarf::DW_FORM_ref_udata:
444 case dwarf::DW_FORM_strx:
445 case dwarf::DW_FORM_addrx:
446 case dwarf::DW_FORM_rnglistx:
447 case dwarf::DW_FORM_udata:
449 case dwarf::DW_FORM_sdata:
457 O <<
"Int: " << (int64_t)
Integer <<
" 0x";
474 if (Form == dwarf::DW_FORM_data4)
return 4;
475 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
476 if (Form == dwarf::DW_FORM_strp)
return 4;
491 Form == dwarf::DW_FORM_strp ||
492 Form == dwarf::DW_FORM_sec_offset ||
493 Form == dwarf::DW_FORM_ref_addr ||
494 Form == dwarf::DW_FORM_data4);
500 if (Form == dwarf::DW_FORM_data4)
return 4;
501 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
502 if (Form == dwarf::DW_FORM_strp)
return 4;
522 if (Form == dwarf::DW_FORM_data4)
return 4;
523 if (Form == dwarf::DW_FORM_sec_offset)
return 4;
524 if (Form == dwarf::DW_FORM_strp)
return 4;
530 O <<
"Del: " << LabelHi->getName() <<
"-" << LabelLo->getName();
542 case dwarf::DW_FORM_GNU_str_index:
543 case dwarf::DW_FORM_strx:
544 case dwarf::DW_FORM_strx1:
545 case dwarf::DW_FORM_strx2:
546 case dwarf::DW_FORM_strx3:
547 case dwarf::DW_FORM_strx4:
550 case dwarf::DW_FORM_strp:
552 DIELabel(S.getSymbol()).EmitValue(AP, Form);
554 DIEInteger(S.getOffset()).EmitValue(AP, Form);
566 case dwarf::DW_FORM_GNU_str_index:
567 case dwarf::DW_FORM_strx:
568 case dwarf::DW_FORM_strx1:
569 case dwarf::DW_FORM_strx2:
570 case dwarf::DW_FORM_strx3:
571 case dwarf::DW_FORM_strx4:
572 return DIEInteger(S.getIndex()).SizeOf(AP, Form);
573 case dwarf::DW_FORM_strp:
575 return DIELabel(S.getSymbol()).SizeOf(AP, Form);
576 return DIEInteger(S.getOffset()).SizeOf(AP, Form);
584 O <<
"String: " << S.getString();
591 if (Form == dwarf::DW_FORM_string) {
606 O <<
"InlineString: " << S;
618 case dwarf::DW_FORM_ref1:
619 case dwarf::DW_FORM_ref2:
620 case dwarf::DW_FORM_ref4:
621 case dwarf::DW_FORM_ref8:
622 AP->
OutStreamer->EmitIntValue(Entry->getOffset(), SizeOf(AP, Form));
625 case dwarf::DW_FORM_ref_udata:
629 case dwarf::DW_FORM_ref_addr: {
631 unsigned Addr = Entry->getDebugSectionOffset();
633 Entry->getUnit()->getCrossSectionRelativeBaseAddress()) {
638 AP->
OutStreamer->EmitIntValue(Addr, SizeOf(AP, Form));
648 case dwarf::DW_FORM_ref1:
650 case dwarf::DW_FORM_ref2:
652 case dwarf::DW_FORM_ref4:
654 case dwarf::DW_FORM_ref8:
656 case dwarf::DW_FORM_ref_udata:
658 case dwarf::DW_FORM_ref_addr:
661 switch (AP->
OutStreamer->getContext().getDwarfFormat()) {
687 for (
const auto &V :
values())
688 Size += V.SizeOf(AP);
702 case dwarf::DW_FORM_block:
703 case dwarf::DW_FORM_exprloc:
707 for (
const auto &V :
values())
715 case dwarf::DW_FORM_block1:
return Size +
sizeof(int8_t);
716 case dwarf::DW_FORM_block2:
return Size +
sizeof(int16_t);
717 case dwarf::DW_FORM_block4:
return Size +
sizeof(int32_t);
718 case dwarf::DW_FORM_block:
719 case dwarf::DW_FORM_exprloc:
738 for (
const auto &V :
values())
739 Size += V.SizeOf(AP);
754 case dwarf::DW_FORM_string:
break;
755 case dwarf::DW_FORM_data16:
break;
758 for (
const auto &V :
values())
766 case dwarf::DW_FORM_block1:
return Size +
sizeof(int8_t);
767 case dwarf::DW_FORM_block2:
return Size +
sizeof(int16_t);
768 case dwarf::DW_FORM_block4:
return Size +
sizeof(int32_t);
770 case dwarf::DW_FORM_data16:
return 16;
785 if (Form == dwarf::DW_FORM_data4)
787 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.
This class represents lattice values for constants.
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
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.
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.