Lines Matching +full:unit +full:- +full:address

1 //===- DwarfStreamer.cpp --------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
38 if (Error Err = Streamer->init(TheTriple, "__DWARF")) in createStreamer()
58 MRI.reset(TheTarget->createMCRegInfo(TripleName)); in init()
67 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions)); in init()
72 MSTI.reset(TheTarget->createMCSubtargetInfo(TripleName, "", "")); in init()
80 MOFI.reset(TheTarget->createMCObjectFileInfo(*MC, /*PIC=*/false, false)); in init()
81 MC->setObjectFileInfo(MOFI.get()); in init()
83 MAB = TheTarget->createMCAsmBackend(*MSTI, *MRI, MCOptions); in init()
89 MII.reset(TheTarget->createMCInstrInfo()); in init()
95 MCE = TheTarget->createMCCodeEmitter(*MII, *MC); in init()
103 MIP = TheTarget->createMCInstPrinter(TheTriple, MAI->getAssemblerDialect(), in init()
105 MS = TheTarget->createAsmStreamer( in init()
112 MS = TheTarget->createMCObjectStreamer( in init()
114 MAB->createObjectWriter(OutFile), std::unique_ptr<MCCodeEmitter>(MCE), in init()
126 TM.reset(TheTarget->createTargetMachine(TripleName, "", "", TargetOptions(), in init()
133 Asm.reset(TheTarget->createAsmPrinter(*TM, std::unique_ptr<MCStreamer>(MS))); in init()
138 Asm->setDwarfUsesRelocationsAcrossSections(false); in init()
153 void DwarfStreamer::finish() { MS->finish(); } in finish()
156 MS->switchSection(MOFI->getDwarfInfoSection()); in switchToDebugInfoSection()
157 MC->setDwarfVersion(DwarfVersion); in switchToDebugInfoSection()
160 /// Emit the compilation unit header for \p Unit in the debug_info section.
163 /// uint32_t Unit length (omitting this field)
166 /// uint8_t Address size
170 /// uint32_t Unit length (omitting this field)
172 /// uint8_t Unit type
173 /// uint8_t Address size
176 void DwarfStreamer::emitCompileUnitHeader(CompileUnit &Unit, in emitCompileUnitHeader() argument
180 /// The start of the unit within its section. in emitCompileUnitHeader()
181 Unit.setLabelBegin(Asm->createTempSymbol("cu_begin")); in emitCompileUnitHeader()
182 Asm->OutStreamer->emitLabel(Unit.getLabelBegin()); in emitCompileUnitHeader()
187 Asm->emitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset() - 4); in emitCompileUnitHeader()
188 Asm->emitInt16(DwarfVersion); in emitCompileUnitHeader()
191 Asm->emitInt8(dwarf::DW_UT_compile); in emitCompileUnitHeader()
192 Asm->emitInt8(Unit.getOrigUnit().getAddressByteSize()); in emitCompileUnitHeader()
195 Asm->emitInt32(0); in emitCompileUnitHeader()
200 Asm->emitInt32(0); in emitCompileUnitHeader()
201 Asm->emitInt8(Unit.getOrigUnit().getAddressByteSize()); in emitCompileUnitHeader()
206 EmittedUnits.push_back({Unit.getUniqueID(), Unit.getLabelBegin()}); in emitCompileUnitHeader()
214 MS->switchSection(MOFI->getDwarfAbbrevSection()); in emitAbbrevs()
215 MC->setDwarfVersion(DwarfVersion); in emitAbbrevs()
216 Asm->emitDwarfAbbrevs(Abbrevs); in emitAbbrevs()
221 MS->switchSection(MOFI->getDwarfInfoSection()); in emitDIE()
222 Asm->emitDwarfDIE(Die); in emitDIE()
233 MS->switchSection(Section); in emitSectionContents()
235 MS->emitBytes(SecData); in emitSectionContents()
242 return MC->getObjectFileInfo()->getDwarfInfoSection(); in getMCSection()
244 return MC->getObjectFileInfo()->getDwarfLineSection(); in getMCSection()
246 return MC->getObjectFileInfo()->getDwarfFrameSection(); in getMCSection()
248 return MC->getObjectFileInfo()->getDwarfRangesSection(); in getMCSection()
250 return MC->getObjectFileInfo()->getDwarfRnglistsSection(); in getMCSection()
252 return MC->getObjectFileInfo()->getDwarfLocSection(); in getMCSection()
254 return MC->getObjectFileInfo()->getDwarfLoclistsSection(); in getMCSection()
256 return MC->getObjectFileInfo()->getDwarfARangesSection(); in getMCSection()
258 return MC->getObjectFileInfo()->getDwarfAbbrevSection(); in getMCSection()
260 return MC->getObjectFileInfo()->getDwarfMacinfoSection(); in getMCSection()
262 return MC->getObjectFileInfo()->getDwarfMacroSection(); in getMCSection()
264 return MC->getObjectFileInfo()->getDwarfAddrSection(); in getMCSection()
266 return MC->getObjectFileInfo()->getDwarfStrSection(); in getMCSection()
268 return MC->getObjectFileInfo()->getDwarfLineStrSection(); in getMCSection()
270 return MC->getObjectFileInfo()->getDwarfStrOffSection(); in getMCSection()
272 return MC->getObjectFileInfo()->getDwarfPubNamesSection(); in getMCSection()
274 return MC->getObjectFileInfo()->getDwarfPubTypesSection(); in getMCSection()
276 return MC->getObjectFileInfo()->getDwarfDebugNamesSection(); in getMCSection()
278 return MC->getObjectFileInfo()->getDwarfAccelNamesSection(); in getMCSection()
280 return MC->getObjectFileInfo()->getDwarfAccelNamespaceSection(); in getMCSection()
282 return MC->getObjectFileInfo()->getDwarfAccelObjCSection(); in getMCSection()
284 return MC->getObjectFileInfo()->getDwarfAccelTypesSection(); in getMCSection()
295 Asm->OutStreamer->switchSection(MOFI->getDwarfStrSection()); in emitStrings()
299 Asm->OutStreamer->emitBytes(Entry.getString()); in emitStrings()
301 Asm->emitInt8(0); in emitStrings()
313 Asm->OutStreamer->switchSection(MOFI->getDwarfStrOffSection()); in emitStringOffsets()
315 MCSymbol *BeginLabel = Asm->createTempSymbol("Bdebugstroff"); in emitStringOffsets()
316 MCSymbol *EndLabel = Asm->createTempSymbol("Edebugstroff"); in emitStringOffsets()
319 Asm->emitLabelDifference(EndLabel, BeginLabel, sizeof(uint32_t)); in emitStringOffsets()
320 Asm->OutStreamer->emitLabel(BeginLabel); in emitStringOffsets()
324 MS->emitInt16(5); in emitStringOffsets()
328 MS->emitInt16(0); in emitStringOffsets()
332 Asm->OutStreamer->emitInt32(Off); in emitStringOffsets()
335 Asm->OutStreamer->emitLabel(EndLabel); in emitStringOffsets()
340 Asm->OutStreamer->switchSection(MOFI->getDwarfLineStrSection()); in emitLineStrings()
344 Asm->OutStreamer->emitBytes(Entry.getString()); in emitLineStrings()
346 Asm->emitInt8(0); in emitLineStrings()
364 Asm->OutStreamer->switchSection(MOFI->getDwarfDebugNamesSection()); in emitDebugNames()
366 (uint64_t)UniqueIdToCuMap.size() - 1); in emitDebugNames()
367 /// llvm-dwarfutil doesn't support type units + .debug_names right now. in emitDebugNames()
373 -> std::optional<DWARF5AccelTable::UnitIndexAndEncoding> { in emitDebugNames()
383 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelNamespaceSection()); in emitAppleNamespaces()
384 auto *SectionBegin = Asm->createTempSymbol("namespac_begin"); in emitAppleNamespaces()
385 Asm->OutStreamer->emitLabel(SectionBegin); in emitAppleNamespaces()
391 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelNamesSection()); in emitAppleNames()
392 auto *SectionBegin = Asm->createTempSymbol("names_begin"); in emitAppleNames()
393 Asm->OutStreamer->emitLabel(SectionBegin); in emitAppleNames()
399 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelObjCSection()); in emitAppleObjc()
400 auto *SectionBegin = Asm->createTempSymbol("objc_begin"); in emitAppleObjc()
401 Asm->OutStreamer->emitLabel(SectionBegin); in emitAppleObjc()
407 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelTypesSection()); in emitAppleTypes()
408 auto *SectionBegin = Asm->createTempSymbol("types_begin"); in emitAppleTypes()
409 Asm->OutStreamer->emitLabel(SectionBegin); in emitAppleTypes()
415 MCSection *SwiftASTSection = MOFI->getDwarfSwiftASTSection(); in emitSwiftAST()
416 SwiftASTSection->setAlignment(Align(32)); in emitSwiftAST()
417 MS->switchSection(SwiftASTSection); in emitSwiftAST()
418 MS->emitBytes(Buffer); in emitSwiftAST()
425 MOFI->getSwift5ReflectionSection(ReflSectionKind); in emitSwiftReflectionSection()
428 ReflectionSection->setAlignment(Align(Alignment)); in emitSwiftReflectionSection()
429 MS->switchSection(ReflectionSection); in emitSwiftReflectionSection()
430 MS->emitBytes(Buffer); in emitSwiftReflectionSection()
434 const CompileUnit &Unit, const AddressRanges &LinkedRanges) { in emitDwarfDebugArangesTable() argument
435 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize(); in emitDwarfDebugArangesTable()
438 MS->switchSection(MC->getObjectFileInfo()->getDwarfARangesSection()); in emitDwarfDebugArangesTable()
441 MCSymbol *BeginLabel = Asm->createTempSymbol("Barange"); in emitDwarfDebugArangesTable()
442 MCSymbol *EndLabel = Asm->createTempSymbol("Earange"); in emitDwarfDebugArangesTable()
454 Asm->emitLabelDifference(EndLabel, BeginLabel, 4); // Arange length in emitDwarfDebugArangesTable()
455 Asm->OutStreamer->emitLabel(BeginLabel); in emitDwarfDebugArangesTable()
456 Asm->emitInt16(dwarf::DW_ARANGES_VERSION); // Version number in emitDwarfDebugArangesTable()
457 Asm->emitInt32(Unit.getStartOffset()); // Corresponding unit's offset in emitDwarfDebugArangesTable()
458 Asm->emitInt8(AddressSize); // Address size in emitDwarfDebugArangesTable()
459 Asm->emitInt8(0); // Segment size in emitDwarfDebugArangesTable()
461 Asm->OutStreamer->emitFill(Padding, 0x0); in emitDwarfDebugArangesTable()
465 MS->emitIntValue(Range.start(), AddressSize); in emitDwarfDebugArangesTable()
466 MS->emitIntValue(Range.end() - Range.start(), AddressSize); in emitDwarfDebugArangesTable()
470 Asm->OutStreamer->emitIntValue(0, AddressSize); in emitDwarfDebugArangesTable()
471 Asm->OutStreamer->emitIntValue(0, AddressSize); in emitDwarfDebugArangesTable()
472 Asm->OutStreamer->emitLabel(EndLabel); in emitDwarfDebugArangesTable()
476 const CompileUnit &Unit, const AddressRanges &LinkedRanges, in emitDwarfDebugRangesTableFragment() argument
481 MS->switchSection(MC->getObjectFileInfo()->getDwarfRangesSection()); in emitDwarfDebugRangesTableFragment()
482 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize(); in emitDwarfDebugRangesTableFragment()
486 if (std::optional<uint64_t> LowPC = Unit.getLowPc()) in emitDwarfDebugRangesTableFragment()
490 MS->emitIntValue(Range.start() - BaseAddress, AddressSize); in emitDwarfDebugRangesTableFragment()
491 MS->emitIntValue(Range.end() - BaseAddress, AddressSize); in emitDwarfDebugRangesTableFragment()
498 MS->emitIntValue(0, AddressSize); in emitDwarfDebugRangesTableFragment()
499 MS->emitIntValue(0, AddressSize); in emitDwarfDebugRangesTableFragment()
506 DwarfStreamer::emitDwarfDebugRangeListHeader(const CompileUnit &Unit) { in emitDwarfDebugRangeListHeader() argument
507 if (Unit.getOrigUnit().getVersion() < 5) in emitDwarfDebugRangeListHeader()
511 MS->switchSection(MC->getObjectFileInfo()->getDwarfRnglistsSection()); in emitDwarfDebugRangeListHeader()
513 MCSymbol *BeginLabel = Asm->createTempSymbol("Brnglists"); in emitDwarfDebugRangeListHeader()
514 MCSymbol *EndLabel = Asm->createTempSymbol("Ernglists"); in emitDwarfDebugRangeListHeader()
515 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize(); in emitDwarfDebugRangeListHeader()
518 Asm->emitLabelDifference(EndLabel, BeginLabel, sizeof(uint32_t)); in emitDwarfDebugRangeListHeader()
519 Asm->OutStreamer->emitLabel(BeginLabel); in emitDwarfDebugRangeListHeader()
523 MS->emitInt16(5); in emitDwarfDebugRangeListHeader()
526 // Address size. in emitDwarfDebugRangeListHeader()
527 MS->emitInt8(AddressSize); in emitDwarfDebugRangeListHeader()
531 MS->emitInt8(0); in emitDwarfDebugRangeListHeader()
535 MS->emitInt32(0); in emitDwarfDebugRangeListHeader()
542 const CompileUnit &Unit, const AddressRanges &LinkedRanges, in emitDwarfDebugRangeListFragment() argument
544 if (Unit.getOrigUnit().getVersion() < 5) { in emitDwarfDebugRangeListFragment()
545 emitDwarfDebugRangesTableFragment(Unit, LinkedRanges, Patch); in emitDwarfDebugRangeListFragment()
549 emitDwarfDebugRngListsTableFragment(Unit, LinkedRanges, Patch, AddrPool); in emitDwarfDebugRangeListFragment()
552 void DwarfStreamer::emitDwarfDebugRangeListFooter(const CompileUnit &Unit, in emitDwarfDebugRangeListFooter() argument
554 if (Unit.getOrigUnit().getVersion() < 5) in emitDwarfDebugRangeListFooter()
558 MS->switchSection(MC->getObjectFileInfo()->getDwarfRnglistsSection()); in emitDwarfDebugRangeListFooter()
561 Asm->OutStreamer->emitLabel(EndLabel); in emitDwarfDebugRangeListFooter()
565 const CompileUnit &Unit, const AddressRanges &LinkedRanges, in emitDwarfDebugRngListsTableFragment() argument
570 MS->switchSection(MC->getObjectFileInfo()->getDwarfRnglistsSection()); in emitDwarfDebugRngListsTableFragment()
578 // Emit base address. in emitDwarfDebugRngListsTableFragment()
579 MS->emitInt8(dwarf::DW_RLE_base_addressx); in emitDwarfDebugRngListsTableFragment()
582 MS->emitULEB128IntValue(AddrPool.getValueIndex(*BaseAddress)); in emitDwarfDebugRngListsTableFragment()
586 MS->emitInt8(dwarf::DW_RLE_offset_pair); in emitDwarfDebugRngListsTableFragment()
589 // Emit start offset relative to base address. in emitDwarfDebugRngListsTableFragment()
591 MS->emitULEB128IntValue(Range.start() - *BaseAddress); in emitDwarfDebugRngListsTableFragment()
593 // Emit end offset relative to base address. in emitDwarfDebugRngListsTableFragment()
594 RngListsSectionSize += MS->emitULEB128IntValue(Range.end() - *BaseAddress); in emitDwarfDebugRngListsTableFragment()
598 MS->emitInt8(dwarf::DW_RLE_end_of_list); in emitDwarfDebugRngListsTableFragment()
603 MCSymbol *DwarfStreamer::emitDwarfDebugLocListHeader(const CompileUnit &Unit) { in emitDwarfDebugLocListHeader() argument
604 if (Unit.getOrigUnit().getVersion() < 5) in emitDwarfDebugLocListHeader()
608 MS->switchSection(MC->getObjectFileInfo()->getDwarfLoclistsSection()); in emitDwarfDebugLocListHeader()
610 MCSymbol *BeginLabel = Asm->createTempSymbol("Bloclists"); in emitDwarfDebugLocListHeader()
611 MCSymbol *EndLabel = Asm->createTempSymbol("Eloclists"); in emitDwarfDebugLocListHeader()
612 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize(); in emitDwarfDebugLocListHeader()
615 Asm->emitLabelDifference(EndLabel, BeginLabel, sizeof(uint32_t)); in emitDwarfDebugLocListHeader()
616 Asm->OutStreamer->emitLabel(BeginLabel); in emitDwarfDebugLocListHeader()
620 MS->emitInt16(5); in emitDwarfDebugLocListHeader()
623 // Address size. in emitDwarfDebugLocListHeader()
624 MS->emitInt8(AddressSize); in emitDwarfDebugLocListHeader()
628 MS->emitInt8(0); in emitDwarfDebugLocListHeader()
632 MS->emitInt32(0); in emitDwarfDebugLocListHeader()
640 const CompileUnit &Unit, in emitDwarfDebugLocListFragment() argument
643 if (Unit.getOrigUnit().getVersion() < 5) { in emitDwarfDebugLocListFragment()
644 emitDwarfDebugLocTableFragment(Unit, LinkedLocationExpression, Patch); in emitDwarfDebugLocListFragment()
648 emitDwarfDebugLocListsTableFragment(Unit, LinkedLocationExpression, Patch, in emitDwarfDebugLocListFragment()
653 void DwarfStreamer::emitDwarfDebugLocListFooter(const CompileUnit &Unit, in emitDwarfDebugLocListFooter() argument
655 if (Unit.getOrigUnit().getVersion() < 5) in emitDwarfDebugLocListFooter()
659 MS->switchSection(MC->getObjectFileInfo()->getDwarfLoclistsSection()); in emitDwarfDebugLocListFooter()
662 Asm->OutStreamer->emitLabel(EndLabel); in emitDwarfDebugLocListFooter()
667 const CompileUnit &Unit, in emitDwarfDebugLocTableFragment() argument
673 MS->switchSection(MC->getObjectFileInfo()->getDwarfLocSection()); in emitDwarfDebugLocTableFragment()
674 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize(); in emitDwarfDebugLocTableFragment()
678 if (std::optional<uint64_t> LowPC = Unit.getLowPc()) in emitDwarfDebugLocTableFragment()
684 MS->emitIntValue(LocExpression.Range->LowPC - BaseAddress, AddressSize); in emitDwarfDebugLocTableFragment()
685 MS->emitIntValue(LocExpression.Range->HighPC - BaseAddress, AddressSize); in emitDwarfDebugLocTableFragment()
691 Asm->OutStreamer->emitIntValue(LocExpression.Expr.size(), 2); in emitDwarfDebugLocTableFragment()
692 Asm->OutStreamer->emitBytes(StringRef( in emitDwarfDebugLocTableFragment()
698 MS->emitIntValue(0, AddressSize); in emitDwarfDebugLocTableFragment()
699 MS->emitIntValue(0, AddressSize); in emitDwarfDebugLocTableFragment()
706 MCSymbol *DwarfStreamer::emitDwarfDebugAddrsHeader(const CompileUnit &Unit) { in emitDwarfDebugAddrsHeader() argument
709 MS->switchSection(MC->getObjectFileInfo()->getDwarfAddrSection()); in emitDwarfDebugAddrsHeader()
711 MCSymbol *BeginLabel = Asm->createTempSymbol("Bdebugaddr"); in emitDwarfDebugAddrsHeader()
712 MCSymbol *EndLabel = Asm->createTempSymbol("Edebugaddr"); in emitDwarfDebugAddrsHeader()
713 unsigned AddrSize = Unit.getOrigUnit().getAddressByteSize(); in emitDwarfDebugAddrsHeader()
716 Asm->emitLabelDifference(EndLabel, BeginLabel, sizeof(uint32_t)); in emitDwarfDebugAddrsHeader()
717 Asm->OutStreamer->emitLabel(BeginLabel); in emitDwarfDebugAddrsHeader()
721 Asm->emitInt16(5); in emitDwarfDebugAddrsHeader()
724 // Emit address size. in emitDwarfDebugAddrsHeader()
725 Asm->emitInt8(AddrSize); in emitDwarfDebugAddrsHeader()
729 Asm->emitInt8(0); in emitDwarfDebugAddrsHeader()
738 Asm->OutStreamer->switchSection(MOFI->getDwarfAddrSection()); in emitDwarfDebugAddrs()
740 Asm->OutStreamer->emitIntValue(Addr, AddrSize); in emitDwarfDebugAddrs()
746 void DwarfStreamer::emitDwarfDebugAddrsFooter(const CompileUnit &Unit, in emitDwarfDebugAddrsFooter() argument
750 MS->switchSection(MC->getObjectFileInfo()->getDwarfAddrSection()); in emitDwarfDebugAddrsFooter()
753 Asm->OutStreamer->emitLabel(EndLabel); in emitDwarfDebugAddrsFooter()
758 const CompileUnit &Unit, in emitDwarfDebugLocListsTableFragment() argument
764 MS->switchSection(MC->getObjectFileInfo()->getDwarfLoclistsSection()); in emitDwarfDebugLocListsTableFragment()
773 BaseAddress = LocExpression.Range->LowPC; in emitDwarfDebugLocListsTableFragment()
775 // Emit base address. in emitDwarfDebugLocListsTableFragment()
776 MS->emitInt8(dwarf::DW_LLE_base_addressx); in emitDwarfDebugLocListsTableFragment()
779 MS->emitULEB128IntValue(AddrPool.getValueIndex(*BaseAddress)); in emitDwarfDebugLocListsTableFragment()
783 MS->emitInt8(dwarf::DW_LLE_offset_pair); in emitDwarfDebugLocListsTableFragment()
786 // Emit start offset relative to base address. in emitDwarfDebugLocListsTableFragment()
788 MS->emitULEB128IntValue(LocExpression.Range->LowPC - *BaseAddress); in emitDwarfDebugLocListsTableFragment()
790 // Emit end offset relative to base address. in emitDwarfDebugLocListsTableFragment()
792 MS->emitULEB128IntValue(LocExpression.Range->HighPC - *BaseAddress); in emitDwarfDebugLocListsTableFragment()
795 MS->emitInt8(dwarf::DW_LLE_default_location); in emitDwarfDebugLocListsTableFragment()
799 LocListsSectionSize += MS->emitULEB128IntValue(LocExpression.Expr.size()); in emitDwarfDebugLocListsTableFragment()
800 Asm->OutStreamer->emitBytes(StringRef( in emitDwarfDebugLocListsTableFragment()
806 MS->emitInt8(dwarf::DW_LLE_end_of_list); in emitDwarfDebugLocListsTableFragment()
811 const DWARFDebugLine::LineTable &LineTable, const CompileUnit &Unit, in emitLineTableForUnit() argument
814 MS->switchSection(MC->getObjectFileInfo()->getDwarfLineSection()); in emitLineTableForUnit()
816 MCSymbol *LineStartSym = MC->createTempSymbol(); in emitLineTableForUnit()
817 MCSymbol *LineEndSym = MC->createTempSymbol(); in emitLineTableForUnit()
821 MS->emitInt32(dwarf::DW_LENGTH_DWARF64); in emitLineTableForUnit()
826 Asm->OutStreamer->emitLabel(LineStartSym); in emitLineTableForUnit()
833 Unit.getOrigUnit().getAddressByteSize()); in emitLineTableForUnit()
839 MCSymbol *PrologueStartSym = MC->createTempSymbol(); in emitLineTablePrologue()
840 MCSymbol *PrologueEndSym = MC->createTempSymbol(); in emitLineTablePrologue()
843 MS->emitInt16(P.getVersion()); in emitLineTablePrologue()
847 MS->emitInt8(P.getAddressSize()); in emitLineTablePrologue()
851 MS->emitInt8(P.SegSelectorSize); in emitLineTablePrologue()
859 Asm->OutStreamer->emitLabel(PrologueStartSym); in emitLineTablePrologue()
861 Asm->OutStreamer->emitLabel(PrologueEndSym); in emitLineTablePrologue()
871 MS->emitInt8(0); in emitLineTablePrologueV2IncludeAndFileTable()
876 // A null-terminated string containing the full or relative path name of a in emitLineTablePrologueV2IncludeAndFileTable()
881 LineSectionSize += MS->emitULEB128IntValue(File.DirIdx); in emitLineTablePrologueV2IncludeAndFileTable()
882 // An unsigned LEB128 number representing the (implementation-defined) time in emitLineTablePrologueV2IncludeAndFileTable()
884 LineSectionSize += MS->emitULEB128IntValue(File.ModTime); in emitLineTablePrologueV2IncludeAndFileTable()
887 LineSectionSize += MS->emitULEB128IntValue(File.Length); in emitLineTablePrologueV2IncludeAndFileTable()
890 MS->emitInt8(0); in emitLineTablePrologueV2IncludeAndFileTable()
899 MS->emitInt8(0); in emitLineTablePrologueV5IncludeAndFileTable()
903 MS->emitInt8(1); in emitLineTablePrologueV5IncludeAndFileTable()
907 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_LNCT_path); in emitLineTablePrologueV5IncludeAndFileTable()
909 MS->emitULEB128IntValue(P.IncludeDirectories[0].getForm()); in emitLineTablePrologueV5IncludeAndFileTable()
913 LineSectionSize += MS->emitULEB128IntValue(P.IncludeDirectories.size()); in emitLineTablePrologueV5IncludeAndFileTable()
923 MS->emitInt8(0); in emitLineTablePrologueV5IncludeAndFileTable()
927 MS->emitInt8(2 + (HasChecksums ? 1 : 0) + (HasInlineSources ? 1 : 0)); in emitLineTablePrologueV5IncludeAndFileTable()
932 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_LNCT_path); in emitLineTablePrologueV5IncludeAndFileTable()
933 LineSectionSize += MS->emitULEB128IntValue(StrForm); in emitLineTablePrologueV5IncludeAndFileTable()
935 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_LNCT_directory_index); in emitLineTablePrologueV5IncludeAndFileTable()
936 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_FORM_data1); in emitLineTablePrologueV5IncludeAndFileTable()
939 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_LNCT_MD5); in emitLineTablePrologueV5IncludeAndFileTable()
940 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_FORM_data16); in emitLineTablePrologueV5IncludeAndFileTable()
944 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_LNCT_LLVM_source); in emitLineTablePrologueV5IncludeAndFileTable()
945 LineSectionSize += MS->emitULEB128IntValue(StrForm); in emitLineTablePrologueV5IncludeAndFileTable()
950 LineSectionSize += MS->emitULEB128IntValue(P.FileNames.size()); in emitLineTablePrologueV5IncludeAndFileTable()
955 MS->emitInt8(File.DirIdx); in emitLineTablePrologueV5IncludeAndFileTable()
958 MS->emitBinaryData( in emitLineTablePrologueV5IncludeAndFileTable()
981 Asm->OutStreamer->emitBytes(Str.data()); in emitLineTableString()
982 Asm->emitInt8(0); in emitLineTableString()
1004 MS->emitInt8(P.MinInstLength); in emitLineTableProloguePayload()
1008 MS->emitInt8(P.MaxOpsPerInst); in emitLineTableProloguePayload()
1012 MS->emitInt8(P.DefaultIsStmt); in emitLineTableProloguePayload()
1015 MS->emitInt8(P.LineBase); in emitLineTableProloguePayload()
1018 MS->emitInt8(P.LineRange); in emitLineTableProloguePayload()
1021 MS->emitInt8(P.OpcodeBase); in emitLineTableProloguePayload()
1026 MS->emitInt8(Length); in emitLineTableProloguePayload()
1051 // address in that case. in emitLineTableRows()
1054 MS->emitBytes(EncodingBuffer); in emitLineTableRows()
1056 MS->emitLabel(LineEndSym); in emitLineTableRows()
1067 uint64_t Address = -1ULL; in emitLineTableRows() local
1073 if (Address == -1ULL) { in emitLineTableRows()
1074 MS->emitIntValue(dwarf::DW_LNS_extended_op, 1); in emitLineTableRows()
1075 MS->emitULEB128IntValue(AddressByteSize + 1); in emitLineTableRows()
1076 MS->emitIntValue(dwarf::DW_LNE_set_address, 1); in emitLineTableRows()
1077 MS->emitIntValue(Row.Address.Address, AddressByteSize); in emitLineTableRows()
1083 (Row.Address.Address - Address) / LineTable.Prologue.MinInstLength; in emitLineTableRows()
1093 MS->emitIntValue(dwarf::DW_LNS_set_file, 1); in emitLineTableRows()
1094 MS->emitULEB128IntValue(FileNum); in emitLineTableRows()
1099 MS->emitIntValue(dwarf::DW_LNS_set_column, 1); in emitLineTableRows()
1100 MS->emitULEB128IntValue(Column); in emitLineTableRows()
1104 MS->getContext().getDwarfVersion() >= 4) { in emitLineTableRows()
1107 MS->emitIntValue(dwarf::DW_LNS_extended_op, 1); in emitLineTableRows()
1108 MS->emitULEB128IntValue(Size + 1); in emitLineTableRows()
1109 MS->emitIntValue(dwarf::DW_LNE_set_discriminator, 1); in emitLineTableRows()
1110 MS->emitULEB128IntValue(Discriminator); in emitLineTableRows()
1118 MS->emitIntValue(dwarf::DW_LNS_set_isa, 1); in emitLineTableRows()
1119 MS->emitULEB128IntValue(Isa); in emitLineTableRows()
1124 MS->emitIntValue(dwarf::DW_LNS_negate_stmt, 1); in emitLineTableRows()
1128 MS->emitIntValue(dwarf::DW_LNS_set_basic_block, 1); in emitLineTableRows()
1133 MS->emitIntValue(dwarf::DW_LNS_set_prologue_end, 1); in emitLineTableRows()
1138 MS->emitIntValue(dwarf::DW_LNS_set_epilogue_begin, 1); in emitLineTableRows()
1142 int64_t LineDelta = int64_t(Row.Line) - LastLine; in emitLineTableRows()
1146 MS->emitBytes(EncodingBuffer); in emitLineTableRows()
1149 Address = Row.Address.Address; in emitLineTableRows()
1154 MS->emitIntValue(dwarf::DW_LNS_advance_line, 1); in emitLineTableRows()
1155 MS->emitSLEB128IntValue(LineDelta); in emitLineTableRows()
1159 MS->emitIntValue(dwarf::DW_LNS_advance_pc, 1); in emitLineTableRows()
1160 MS->emitULEB128IntValue(AddressDelta); in emitLineTableRows()
1165 MS->emitBytes(EncodingBuffer); in emitLineTableRows()
1168 Address = -1ULL; in emitLineTableRows()
1177 MS->emitBytes(EncodingBuffer); in emitLineTableRows()
1182 MS->emitLabel(LineEndSym); in emitLineTableRows()
1188 MS->emitIntValue(Offset, Size); in emitIntOffset()
1196 Asm->emitLabelDifference(Hi, Lo, Size); in emitLabelDifference()
1201 /// Unit into \p Sec. The data is provided in \p Names.
1203 MCSection *Sec, StringRef SecName, const CompileUnit &Unit, in emitPubSectionForUnit() argument
1209 Asm->OutStreamer->switchSection(Sec); in emitPubSectionForUnit()
1210 MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + SecName + "_begin"); in emitPubSectionForUnit()
1211 MCSymbol *EndLabel = Asm->createTempSymbol("pub" + SecName + "_end"); in emitPubSectionForUnit()
1214 // Emit the pubnames for this compilation unit. in emitPubSectionForUnit()
1221 Asm->emitLabelDifference(EndLabel, BeginLabel, 4); // Length in emitPubSectionForUnit()
1222 Asm->OutStreamer->emitLabel(BeginLabel); in emitPubSectionForUnit()
1223 Asm->emitInt16(dwarf::DW_PUBNAMES_VERSION); // Version in emitPubSectionForUnit()
1224 Asm->emitInt32(Unit.getStartOffset()); // Unit offset in emitPubSectionForUnit()
1225 Asm->emitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset()); // Size in emitPubSectionForUnit()
1228 Asm->emitInt32(Name.Die->getOffset()); in emitPubSectionForUnit()
1231 Asm->OutStreamer->emitBytes(Name.Name.getString()); in emitPubSectionForUnit()
1233 Asm->emitInt8(0); in emitPubSectionForUnit()
1238 Asm->emitInt32(0); // End marker. in emitPubSectionForUnit()
1239 Asm->OutStreamer->emitLabel(EndLabel); in emitPubSectionForUnit()
1242 /// Emit .debug_pubnames for \p Unit.
1243 void DwarfStreamer::emitPubNamesForUnit(const CompileUnit &Unit) { in emitPubNamesForUnit() argument
1244 emitPubSectionForUnit(MC->getObjectFileInfo()->getDwarfPubNamesSection(), in emitPubNamesForUnit()
1245 "names", Unit, Unit.getPubnames()); in emitPubNamesForUnit()
1248 /// Emit .debug_pubtypes for \p Unit.
1249 void DwarfStreamer::emitPubTypesForUnit(const CompileUnit &Unit) { in emitPubTypesForUnit() argument
1250 emitPubSectionForUnit(MC->getObjectFileInfo()->getDwarfPubTypesSection(), in emitPubTypesForUnit()
1251 "types", Unit, Unit.getPubtypes()); in emitPubTypesForUnit()
1256 MS->switchSection(MC->getObjectFileInfo()->getDwarfFrameSection()); in emitCIE()
1258 MS->emitBytes(CIEBytes); in emitCIE()
1263 /// contains the FDE data without the length, CIE offset and address
1266 uint64_t Address, StringRef FDEBytes) { in emitFDE() argument
1267 MS->switchSection(MC->getObjectFileInfo()->getDwarfFrameSection()); in emitFDE()
1269 MS->emitIntValue(FDEBytes.size() + 4 + AddrSize, 4); in emitFDE()
1270 MS->emitIntValue(CIEOffset, 4); in emitFDE()
1271 MS->emitIntValue(Address, AddrSize); in emitFDE()
1272 MS->emitBytes(FDEBytes); in emitFDE()
1282 if (const DWARFDebugMacro *Table = Context->getDebugMacinfo()) { in emitMacroTables()
1283 MS->switchSection(MC->getObjectFileInfo()->getDwarfMacinfoSection()); in emitMacroTables()
1288 if (const DWARFDebugMacro *Table = Context->getDebugMacro()) { in emitMacroTables()
1289 MS->switchSection(MC->getObjectFileInfo()->getDwarfMacroSection()); in emitMacroTables()
1301 for (const DWARFDebugMacro::MacroList &List : MacroTable->MacroLists) { in emitMacroTableImpl()
1305 "couldn`t find compile unit for the macro table with offset = {0:x}", in emitMacroTableImpl()
1310 // Skip macro table if the unit was not cloned. in emitMacroTableImpl()
1311 DIE *OutputUnitDIE = UnitIt->second->getOutputUnitDIE(); in emitMacroTableImpl()
1315 // Update macro attribute of cloned compile unit with the proper offset to in emitMacroTableImpl()
1318 for (auto &V : OutputUnitDIE->values()) { in emitMacroTableImpl()
1332 MS->emitIntValue(List.Header.Version, sizeof(List.Header.Version)); in emitMacroTableImpl()
1347 // Get offset to the line table from the cloned compile unit. in emitMacroTableImpl()
1348 for (auto &V : OutputUnitDIE->values()) { in emitMacroTableImpl()
1362 MS->emitIntValue(Flags, sizeof(Flags)); in emitMacroTableImpl()
1367 MS->emitIntValue(*StmtListOffset, List.Header.getOffsetByteSize()); in emitMacroTableImpl()
1375 OutOffset += MS->emitULEB128IntValue(MacroEntry.Type); in emitMacroTableImpl()
1389 MS->emitIntValue(MacroType, 1); in emitMacroTableImpl()
1393 OutOffset += MS->emitULEB128IntValue(MacroEntry.ExtConstant); in emitMacroTableImpl()
1397 MS->emitBytes(String); in emitMacroTableImpl()
1398 MS->emitIntValue(0, 1); in emitMacroTableImpl()
1412 MS->emitIntValue(MacroType, 1); in emitMacroTableImpl()
1416 OutOffset += MS->emitULEB128IntValue(MacroEntry.Line); in emitMacroTableImpl()
1420 MS->emitBytes(String); in emitMacroTableImpl()
1421 MS->emitIntValue(0, 1); in emitMacroTableImpl()
1428 assert(UnitIt->second->getOrigUnit().getVersion() >= 5); in emitMacroTableImpl()
1455 MS->emitIntValue(MacroType, 1); in emitMacroTableImpl()
1459 OutOffset += MS->emitULEB128IntValue(MacroEntry.Line); in emitMacroTableImpl()
1464 MS->emitIntValue(EntryRef.getOffset(), List.Header.getOffsetByteSize()); in emitMacroTableImpl()
1470 MS->emitIntValue(MacroType, 1); in emitMacroTableImpl()
1473 OutOffset += MS->emitULEB128IntValue(MacroEntry.Line); in emitMacroTableImpl()
1475 OutOffset += MS->emitULEB128IntValue(MacroEntry.File); in emitMacroTableImpl()
1479 MS->emitIntValue(MacroType, 1); in emitMacroTableImpl()