1 //===--- lib/CodeGen/DIE.cpp - DWARF Info Entries -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Data structures for DWARF info entries.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/DIE.h"
15 #include "DwarfCompileUnit.h"
16 #include "DwarfDebug.h"
17 #include "DwarfUnit.h"
18 #include "llvm/ADT/Twine.h"
19 #include "llvm/CodeGen/AsmPrinter.h"
20 #include "llvm/Config/llvm-config.h"
21 #include "llvm/IR/DataLayout.h"
22 #include "llvm/MC/MCAsmInfo.h"
23 #include "llvm/MC/MCContext.h"
24 #include "llvm/MC/MCStreamer.h"
25 #include "llvm/MC/MCSymbol.h"
26 #include "llvm/Support/Debug.h"
27 #include "llvm/Support/ErrorHandling.h"
28 #include "llvm/Support/Format.h"
29 #include "llvm/Support/FormattedStream.h"
30 #include "llvm/Support/LEB128.h"
31 #include "llvm/Support/MD5.h"
32 #include "llvm/Support/raw_ostream.h"
35 #define DEBUG_TYPE "dwarfdebug"
37 //===----------------------------------------------------------------------===//
38 // DIEAbbrevData Implementation
39 //===----------------------------------------------------------------------===//
41 /// Profile - Used to gather unique data for the abbreviation folding set.
43 void DIEAbbrevData::Profile(FoldingSetNodeID &ID) const {
44 // Explicitly cast to an integer type for which FoldingSetNodeID has
45 // overloads. Otherwise MSVC 2010 thinks this call is ambiguous.
46 ID.AddInteger(unsigned(Attribute));
47 ID.AddInteger(unsigned(Form));
48 if (Form == dwarf::DW_FORM_implicit_const)
52 //===----------------------------------------------------------------------===//
53 // DIEAbbrev Implementation
54 //===----------------------------------------------------------------------===//
56 /// Profile - Used to gather unique data for the abbreviation folding set.
58 void DIEAbbrev::Profile(FoldingSetNodeID &ID) const {
59 ID.AddInteger(unsigned(Tag));
60 ID.AddInteger(unsigned(Children));
62 // For each attribute description.
63 for (unsigned i = 0, N = Data.size(); i < N; ++i)
67 /// Emit - Print the abbreviation using the specified asm printer.
69 void DIEAbbrev::Emit(const AsmPrinter *AP) const {
70 // Emit its Dwarf tag type.
71 AP->EmitULEB128(Tag, dwarf::TagString(Tag).data());
73 // Emit whether it has children DIEs.
74 AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children).data());
76 // For each attribute description.
77 for (unsigned i = 0, N = Data.size(); i < N; ++i) {
78 const DIEAbbrevData &AttrData = Data[i];
80 // Emit attribute type.
81 AP->EmitULEB128(AttrData.getAttribute(),
82 dwarf::AttributeString(AttrData.getAttribute()).data());
86 // Could be an assertion, but this way we can see the failing form code
87 // easily, which helps track down where it came from.
88 if (!dwarf::isValidFormForVersion(AttrData.getForm(),
89 AP->getDwarfVersion())) {
90 LLVM_DEBUG(dbgs() << "Invalid form " << format("0x%x", AttrData.getForm())
91 << " for DWARF version " << AP->getDwarfVersion()
93 llvm_unreachable("Invalid form for specified DWARF version");
96 AP->EmitULEB128(AttrData.getForm(),
97 dwarf::FormEncodingString(AttrData.getForm()).data());
99 // Emit value for DW_FORM_implicit_const.
100 if (AttrData.getForm() == dwarf::DW_FORM_implicit_const)
101 AP->EmitSLEB128(AttrData.getValue());
104 // Mark end of abbreviation.
105 AP->EmitULEB128(0, "EOM(1)");
106 AP->EmitULEB128(0, "EOM(2)");
110 void DIEAbbrev::print(raw_ostream &O) const {
111 O << "Abbreviation @"
112 << format("0x%lx", (long)(intptr_t)this)
114 << dwarf::TagString(Tag)
116 << dwarf::ChildrenString(Children)
119 for (unsigned i = 0, N = Data.size(); i < N; ++i) {
121 << dwarf::AttributeString(Data[i].getAttribute())
123 << dwarf::FormEncodingString(Data[i].getForm());
125 if (Data[i].getForm() == dwarf::DW_FORM_implicit_const)
126 O << " " << Data[i].getValue();
132 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
133 LLVM_DUMP_METHOD void DIEAbbrev::dump() const {
138 //===----------------------------------------------------------------------===//
139 // DIEAbbrevSet Implementation
140 //===----------------------------------------------------------------------===//
142 DIEAbbrevSet::~DIEAbbrevSet() {
143 for (DIEAbbrev *Abbrev : Abbreviations)
144 Abbrev->~DIEAbbrev();
147 DIEAbbrev &DIEAbbrevSet::uniqueAbbreviation(DIE &Die) {
150 DIEAbbrev Abbrev = Die.generateAbbrev();
154 if (DIEAbbrev *Existing =
155 AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) {
156 Die.setAbbrevNumber(Existing->getNumber());
160 // Move the abbreviation to the heap and assign a number.
161 DIEAbbrev *New = new (Alloc) DIEAbbrev(std::move(Abbrev));
162 Abbreviations.push_back(New);
163 New->setNumber(Abbreviations.size());
164 Die.setAbbrevNumber(Abbreviations.size());
166 // Store it for lookup.
167 AbbreviationsSet.InsertNode(New, InsertPos);
171 void DIEAbbrevSet::Emit(const AsmPrinter *AP, MCSection *Section) const {
172 if (!Abbreviations.empty()) {
173 // Start the debug abbrev section.
174 AP->OutStreamer->SwitchSection(Section);
175 AP->emitDwarfAbbrevs(Abbreviations);
179 //===----------------------------------------------------------------------===//
180 // DIE Implementation
181 //===----------------------------------------------------------------------===//
183 DIE *DIE::getParent() const {
184 return Owner.dyn_cast<DIE*>();
187 DIEAbbrev DIE::generateAbbrev() const {
188 DIEAbbrev Abbrev(Tag, hasChildren());
189 for (const DIEValue &V : values())
190 if (V.getForm() == dwarf::DW_FORM_implicit_const)
191 Abbrev.AddImplicitConstAttribute(V.getAttribute(),
192 V.getDIEInteger().getValue());
194 Abbrev.AddAttribute(V.getAttribute(), V.getForm());
198 unsigned DIE::getDebugSectionOffset() const {
199 const DIEUnit *Unit = getUnit();
200 assert(Unit && "DIE must be owned by a DIEUnit to get its absolute offset");
201 return Unit->getDebugSectionOffset() + getOffset();
204 const DIE *DIE::getUnitDie() const {
207 if (p->getTag() == dwarf::DW_TAG_compile_unit ||
208 p->getTag() == dwarf::DW_TAG_type_unit)
215 const DIEUnit *DIE::getUnit() const {
216 const DIE *UnitDie = getUnitDie();
218 return UnitDie->Owner.dyn_cast<DIEUnit*>();
222 DIEValue DIE::findAttribute(dwarf::Attribute Attribute) const {
223 // Iterate through all the attributes until we find the one we're
224 // looking for, if we can't find it return NULL.
225 for (const auto &V : values())
226 if (V.getAttribute() == Attribute)
232 static void printValues(raw_ostream &O, const DIEValueList &Values,
233 StringRef Type, unsigned Size, unsigned IndentCount) {
234 O << Type << ": Size: " << Size << "\n";
237 const std::string Indent(IndentCount, ' ');
238 for (const auto &V : Values.values()) {
240 O << "Blk[" << I++ << "]";
241 O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
248 void DIE::print(raw_ostream &O, unsigned IndentCount) const {
249 const std::string Indent(IndentCount, ' ');
250 O << Indent << "Die: " << format("0x%lx", (long)(intptr_t) this)
251 << ", Offset: " << Offset << ", Size: " << Size << "\n";
253 O << Indent << dwarf::TagString(getTag()) << " "
254 << dwarf::ChildrenString(hasChildren()) << "\n";
257 for (const auto &V : values()) {
259 O << dwarf::AttributeString(V.getAttribute());
260 O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
266 for (const auto &Child : children())
267 Child.print(O, IndentCount + 4);
272 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
273 LLVM_DUMP_METHOD void DIE::dump() const {
278 unsigned DIE::computeOffsetsAndAbbrevs(const AsmPrinter *AP,
279 DIEAbbrevSet &AbbrevSet,
281 // Unique the abbreviation and fill in the abbreviation number so this DIE
283 const DIEAbbrev &Abbrev = AbbrevSet.uniqueAbbreviation(*this);
285 // Set compile/type unit relative offset of this DIE.
288 // Add the byte size of the abbreviation code.
289 CUOffset += getULEB128Size(getAbbrevNumber());
291 // Add the byte size of all the DIE attribute values.
292 for (const auto &V : values())
293 CUOffset += V.SizeOf(AP);
295 // Let the children compute their offsets and abbreviation numbers.
298 assert(Abbrev.hasChildren() && "Children flag not set");
300 for (auto &Child : children())
301 CUOffset = Child.computeOffsetsAndAbbrevs(AP, AbbrevSet, CUOffset);
303 // Each child chain is terminated with a zero byte, adjust the offset.
304 CUOffset += sizeof(int8_t);
307 // Compute the byte size of this DIE and all of its children correctly. This
308 // is needed so that top level DIE can help the compile unit set its length
310 setSize(CUOffset - getOffset());
314 //===----------------------------------------------------------------------===//
315 // DIEUnit Implementation
316 //===----------------------------------------------------------------------===//
317 DIEUnit::DIEUnit(uint16_t V, uint8_t A, dwarf::Tag UnitTag)
318 : Die(UnitTag), Section(nullptr), Offset(0), Length(0), Version(V),
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");
327 void DIEValue::EmitValue(const AsmPrinter *AP) const {
330 llvm_unreachable("Expected valid DIEValue");
331 #define HANDLE_DIEVALUE(T) \
333 getDIE##T().EmitValue(AP, Form); \
335 #include "llvm/CodeGen/DIEValue.def"
339 unsigned DIEValue::SizeOf(const AsmPrinter *AP) const {
342 llvm_unreachable("Expected valid DIEValue");
343 #define HANDLE_DIEVALUE(T) \
345 return getDIE##T().SizeOf(AP, Form);
346 #include "llvm/CodeGen/DIEValue.def"
348 llvm_unreachable("Unknown DIE kind");
352 void DIEValue::print(raw_ostream &O) const {
355 llvm_unreachable("Expected valid DIEValue");
356 #define HANDLE_DIEVALUE(T) \
358 getDIE##T().print(O); \
360 #include "llvm/CodeGen/DIEValue.def"
364 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
365 LLVM_DUMP_METHOD void DIEValue::dump() const {
370 //===----------------------------------------------------------------------===//
371 // DIEInteger Implementation
372 //===----------------------------------------------------------------------===//
374 /// EmitValue - Emit integer of appropriate size.
376 void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
378 case dwarf::DW_FORM_implicit_const:
379 case dwarf::DW_FORM_flag_present:
380 // Emit something to keep the lines and comments in sync.
381 // FIXME: Is there a better way to do this?
382 Asm->OutStreamer->AddBlankLine();
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:
411 Asm->OutStreamer->EmitIntValue(Integer, SizeOf(Asm, Form));
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:
418 Asm->EmitULEB128(Integer);
420 case dwarf::DW_FORM_sdata:
421 Asm->EmitSLEB128(Integer);
423 default: llvm_unreachable("DIE Value form not supported yet");
427 /// SizeOf - Determine size of integer value in bytes.
429 unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
430 dwarf::FormParams Params = {0, 0, dwarf::DWARF32};
432 Params = {AP->getDwarfVersion(), uint8_t(AP->getPointerSize()),
433 AP->OutStreamer->getContext().getDwarfFormat()};
435 if (Optional<uint8_t> FixedSize = dwarf::getFixedFormByteSize(Form, Params))
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:
444 return getULEB128Size(Integer);
445 case dwarf::DW_FORM_sdata:
446 return getSLEB128Size(Integer);
447 default: llvm_unreachable("DIE Value form not supported yet");
452 void DIEInteger::print(raw_ostream &O) const {
453 O << "Int: " << (int64_t)Integer << " 0x";
454 O.write_hex(Integer);
457 //===----------------------------------------------------------------------===//
458 // DIEExpr Implementation
459 //===----------------------------------------------------------------------===//
461 /// EmitValue - Emit expression value.
463 void DIEExpr::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
464 AP->EmitDebugThreadLocal(Expr, SizeOf(AP, Form));
467 /// SizeOf - Determine size of expression value in bytes.
469 unsigned DIEExpr::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
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;
473 return AP->getPointerSize();
477 void DIEExpr::print(raw_ostream &O) const { O << "Expr: " << *Expr; }
479 //===----------------------------------------------------------------------===//
480 // DIELabel Implementation
481 //===----------------------------------------------------------------------===//
483 /// EmitValue - Emit label value.
485 void DIELabel::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
486 AP->EmitLabelReference(Label, SizeOf(AP, Form),
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);
493 /// SizeOf - Determine size of label value in bytes.
495 unsigned DIELabel::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
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;
499 return AP->MAI->getCodePointerSize();
503 void DIELabel::print(raw_ostream &O) const { O << "Lbl: " << Label->getName(); }
505 //===----------------------------------------------------------------------===//
506 // DIEDelta Implementation
507 //===----------------------------------------------------------------------===//
509 /// EmitValue - Emit delta value.
511 void DIEDelta::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
512 AP->EmitLabelDifference(LabelHi, LabelLo, SizeOf(AP, Form));
515 /// SizeOf - Determine size of delta value in bytes.
517 unsigned DIEDelta::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
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;
521 return AP->MAI->getCodePointerSize();
525 void DIEDelta::print(raw_ostream &O) const {
526 O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName();
529 //===----------------------------------------------------------------------===//
530 // DIEString Implementation
531 //===----------------------------------------------------------------------===//
533 /// EmitValue - Emit string value.
535 void DIEString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
536 // Index of string in symbol table.
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:
544 DIEInteger(S.getIndex()).EmitValue(AP, Form);
546 case dwarf::DW_FORM_strp:
547 if (AP->MAI->doesDwarfUseRelocationsAcrossSections())
548 DIELabel(S.getSymbol()).EmitValue(AP, Form);
550 DIEInteger(S.getOffset()).EmitValue(AP, Form);
553 llvm_unreachable("Expected valid string form");
557 /// SizeOf - Determine size of delta value in bytes.
559 unsigned DIEString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
560 // Index of string in symbol table.
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:
570 if (AP->MAI->doesDwarfUseRelocationsAcrossSections())
571 return DIELabel(S.getSymbol()).SizeOf(AP, Form);
572 return DIEInteger(S.getOffset()).SizeOf(AP, Form);
574 llvm_unreachable("Expected valid string form");
579 void DIEString::print(raw_ostream &O) const {
580 O << "String: " << S.getString();
583 //===----------------------------------------------------------------------===//
584 // DIEInlineString Implementation
585 //===----------------------------------------------------------------------===//
586 void DIEInlineString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
587 if (Form == dwarf::DW_FORM_string) {
593 llvm_unreachable("Expected valid string form");
596 unsigned DIEInlineString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
597 // Emit string bytes + NULL byte.
602 void DIEInlineString::print(raw_ostream &O) const {
603 O << "InlineString: " << S;
606 //===----------------------------------------------------------------------===//
607 // DIEEntry Implementation
608 //===----------------------------------------------------------------------===//
610 /// EmitValue - Emit debug information entry offset.
612 void DIEEntry::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
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:
623 AP->EmitULEB128(Entry->getOffset());
626 case dwarf::DW_FORM_ref_addr: {
627 // Get the absolute offset for this DIE within the debug info/types section.
628 unsigned Addr = Entry->getDebugSectionOffset();
629 if (const MCSymbol *SectionSym =
630 Entry->getUnit()->getCrossSectionRelativeBaseAddress()) {
631 AP->EmitLabelPlusOffset(SectionSym, Addr, SizeOf(AP, Form), true);
635 AP->OutStreamer->EmitIntValue(Addr, SizeOf(AP, Form));
639 llvm_unreachable("Improper form for DIE reference");
643 unsigned DIEEntry::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
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:
654 return getULEB128Size(Entry->getOffset());
655 case dwarf::DW_FORM_ref_addr:
656 if (AP->getDwarfVersion() == 2)
657 return AP->MAI->getCodePointerSize();
658 switch (AP->OutStreamer->getContext().getDwarfFormat()) {
664 llvm_unreachable("Invalid DWARF format");
667 llvm_unreachable("Improper form for DIE reference");
672 void DIEEntry::print(raw_ostream &O) const {
673 O << format("Die: 0x%lx", (long)(intptr_t)&Entry);
676 //===----------------------------------------------------------------------===//
677 // DIELoc Implementation
678 //===----------------------------------------------------------------------===//
680 /// ComputeSize - calculate the size of the location expression.
682 unsigned DIELoc::ComputeSize(const AsmPrinter *AP) const {
684 for (const auto &V : values())
685 Size += V.SizeOf(AP);
691 /// EmitValue - Emit location data.
693 void DIELoc::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
695 default: llvm_unreachable("Improper form for block");
696 case dwarf::DW_FORM_block1: Asm->emitInt8(Size); break;
697 case dwarf::DW_FORM_block2: Asm->emitInt16(Size); break;
698 case dwarf::DW_FORM_block4: Asm->emitInt32(Size); break;
699 case dwarf::DW_FORM_block:
700 case dwarf::DW_FORM_exprloc:
701 Asm->EmitULEB128(Size); break;
704 for (const auto &V : values())
708 /// SizeOf - Determine size of location data in bytes.
710 unsigned DIELoc::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
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:
717 return Size + getULEB128Size(Size);
718 default: llvm_unreachable("Improper form for block");
723 void DIELoc::print(raw_ostream &O) const {
724 printValues(O, *this, "ExprLoc", Size, 5);
727 //===----------------------------------------------------------------------===//
728 // DIEBlock Implementation
729 //===----------------------------------------------------------------------===//
731 /// ComputeSize - calculate the size of the block.
733 unsigned DIEBlock::ComputeSize(const AsmPrinter *AP) const {
735 for (const auto &V : values())
736 Size += V.SizeOf(AP);
742 /// EmitValue - Emit block data.
744 void DIEBlock::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
746 default: llvm_unreachable("Improper form for block");
747 case dwarf::DW_FORM_block1: Asm->emitInt8(Size); break;
748 case dwarf::DW_FORM_block2: Asm->emitInt16(Size); break;
749 case dwarf::DW_FORM_block4: Asm->emitInt32(Size); break;
750 case dwarf::DW_FORM_block: Asm->EmitULEB128(Size); break;
751 case dwarf::DW_FORM_string: break;
752 case dwarf::DW_FORM_data16: break;
755 for (const auto &V : values())
759 /// SizeOf - Determine size of block data in bytes.
761 unsigned DIEBlock::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
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);
766 case dwarf::DW_FORM_block: return Size + getULEB128Size(Size);
767 case dwarf::DW_FORM_data16: return 16;
768 default: llvm_unreachable("Improper form for block");
773 void DIEBlock::print(raw_ostream &O) const {
774 printValues(O, *this, "Blk", Size, 5);
777 //===----------------------------------------------------------------------===//
778 // DIELocList Implementation
779 //===----------------------------------------------------------------------===//
781 unsigned DIELocList::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
782 if (Form == dwarf::DW_FORM_data4)
784 if (Form == dwarf::DW_FORM_sec_offset)
786 return AP->MAI->getCodePointerSize();
789 /// EmitValue - Emit label value.
791 void DIELocList::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
792 DwarfDebug *DD = AP->getDwarfDebug();
793 MCSymbol *Label = DD->getDebugLocs().getList(Index).Label;
794 AP->emitDwarfSymbolReference(Label, /*ForceOffset*/ DD->useSplitDwarf());
798 void DIELocList::print(raw_ostream &O) const { O << "LocList: " << Index; }