LLVM: lib/DWARFLinker/Classic/DWARFStreamer.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
28
29using namespace llvm;
32
36 std::unique_ptr Streamer =
37 std::make_unique(FileType, OutFile, Warning);
38 if (Error Err = Streamer->init(TheTriple, "__DWARF"))
39 return std::move(Err);
40
41 return std::move(Streamer);
42}
43
45 StringRef Swift5ReflectionSegmentName) {
46 std::string ErrorStr;
47 std::string TripleName;
48
49
50 const Target *TheTarget =
52 if (!TheTarget)
53 return createStringError(std::errc::invalid_argument, ErrorStr.c_str());
54
55 TripleName = TheTriple.getTriple();
56
57
59 if (!MRI)
61 "no register info for target %s",
62 TripleName.c_str());
63
67 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TheTriple, MCOptions));
68 if (!MAI)
70 "no asm info for target %s", TripleName.c_str());
71
73 if (!MSTI)
75 "no subtarget info for target %s",
76 TripleName.c_str());
77
78 MC.reset(new MCContext(TheTriple, MAI.get(), MRI.get(), MSTI.get(), nullptr,
79 nullptr, true, Swift5ReflectionSegmentName));
81 MC->setObjectFileInfo(MOFI.get());
82
84 if (!MAB)
86 "no asm backend for target %s",
87 TripleName.c_str());
88
90 if (!MII)
92 "no instr info info for target %s",
93 TripleName.c_str());
94
96 if (!MCE)
98 "no code emitter for target %s",
99 TripleName.c_str());
100
101 switch (OutFileType) {
104 TheTriple, MAI->getAssemblerDialect(), *MAI, *MII, *MRI));
106 *MC, std::make_unique<formatted_raw_ostream>(OutFile), std::move(MIP),
107 std::unique_ptr(MCE),
108 std::unique_ptr(MAB));
109 break;
110 }
113 TheTriple, *MC, std::unique_ptr(MAB),
114 MAB->createObjectWriter(OutFile), std::unique_ptr(MCE),
115 *MSTI);
116 break;
117 }
118 }
119
120 if (!MS)
122 "no object streamer for target %s",
123 TripleName.c_str());
124
125
127 std::nullopt));
128 if (!TM)
130 "no target machine for target %s",
131 TripleName.c_str());
132
133 Asm.reset(TheTarget->createAsmPrinter(*TM, std::unique_ptr(MS)));
134 if (!Asm)
136 "no asm printer for target %s",
137 TripleName.c_str());
138 Asm->setDwarfUsesRelocationsAcrossSections(false);
139
140 RangesSectionSize = 0;
141 RngListsSectionSize = 0;
142 LocSectionSize = 0;
143 LocListsSectionSize = 0;
144 LineSectionSize = 0;
145 FrameSectionSize = 0;
146 DebugInfoSectionSize = 0;
147 MacInfoSectionSize = 0;
148 MacroSectionSize = 0;
149
151}
152
154
156 MS->switchSection(MOFI->getDwarfInfoSection());
157 MC->setDwarfVersion(DwarfVersion);
158}
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
177 unsigned DwarfVersion) {
179
180
181 Unit.setLabelBegin(Asm->createTempSymbol("cu_begin"));
182 Asm->OutStreamer->emitLabel(Unit.getLabelBegin());
183
184
185
186
187 Asm->emitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset() - 4);
188 Asm->emitInt16(DwarfVersion);
189
190 if (DwarfVersion >= 5) {
191 Asm->emitInt8(dwarf::DW_UT_compile);
192 Asm->emitInt8(Unit.getOrigUnit().getAddressByteSize());
193
194
195 Asm->emitInt32(0);
196 DebugInfoSectionSize += 12;
197 } else {
198
199
200 Asm->emitInt32(0);
201 Asm->emitInt8(Unit.getOrigUnit().getAddressByteSize());
202 DebugInfoSectionSize += 11;
203 }
204
205
206 EmittedUnits.push_back({Unit.getUniqueID(), Unit.getLabelBegin()});
207}
208
209
210
212 const std::vector<std::unique_ptr> &Abbrevs,
213 unsigned DwarfVersion) {
214 MS->switchSection(MOFI->getDwarfAbbrevSection());
215 MC->setDwarfVersion(DwarfVersion);
216 Asm->emitDwarfAbbrevs(Abbrevs);
217}
218
219
221 MS->switchSection(MOFI->getDwarfInfoSection());
222 Asm->emitDwarfDIE(Die);
223 DebugInfoSectionSize += Die.getSize();
224}
225
226
229 if (SecData.empty())
230 return;
231
232 if (MCSection *Section = getMCSection(SecKind)) {
233 MS->switchSection(Section);
234
235 MS->emitBytes(SecData);
236 }
237}
238
240 switch (SecKind) {
242 return MC->getObjectFileInfo()->getDwarfInfoSection();
244 return MC->getObjectFileInfo()->getDwarfLineSection();
246 return MC->getObjectFileInfo()->getDwarfFrameSection();
248 return MC->getObjectFileInfo()->getDwarfRangesSection();
250 return MC->getObjectFileInfo()->getDwarfRnglistsSection();
252 return MC->getObjectFileInfo()->getDwarfLocSection();
254 return MC->getObjectFileInfo()->getDwarfLoclistsSection();
256 return MC->getObjectFileInfo()->getDwarfARangesSection();
258 return MC->getObjectFileInfo()->getDwarfAbbrevSection();
260 return MC->getObjectFileInfo()->getDwarfMacinfoSection();
262 return MC->getObjectFileInfo()->getDwarfMacroSection();
264 return MC->getObjectFileInfo()->getDwarfAddrSection();
266 return MC->getObjectFileInfo()->getDwarfStrSection();
268 return MC->getObjectFileInfo()->getDwarfLineStrSection();
270 return MC->getObjectFileInfo()->getDwarfStrOffSection();
272 return MC->getObjectFileInfo()->getDwarfPubNamesSection();
274 return MC->getObjectFileInfo()->getDwarfPubTypesSection();
276 return MC->getObjectFileInfo()->getDwarfDebugNamesSection();
278 return MC->getObjectFileInfo()->getDwarfAccelNamesSection();
280 return MC->getObjectFileInfo()->getDwarfAccelNamespaceSection();
282 return MC->getObjectFileInfo()->getDwarfAccelObjCSection();
284 return MC->getObjectFileInfo()->getDwarfAccelTypesSection();
287 break;
288 }
289
290 return nullptr;
291}
292
293
295 Asm->OutStreamer->switchSection(MOFI->getDwarfStrSection());
297 for (auto Entry : Entries) {
298
299 Asm->OutStreamer->emitBytes(Entry.getString());
300
301 Asm->emitInt8(0);
302 }
303}
304
305
306
309
310 if (TargetDWARFVersion < 5 || StringOffsets.empty())
311 return;
312
313 Asm->OutStreamer->switchSection(MOFI->getDwarfStrOffSection());
314
315 MCSymbol *BeginLabel = Asm->createTempSymbol("Bdebugstroff");
316 MCSymbol *EndLabel = Asm->createTempSymbol("Edebugstroff");
317
318
319 Asm->emitLabelDifference(EndLabel, BeginLabel, sizeof(uint32_t));
320 Asm->OutStreamer->emitLabel(BeginLabel);
321 StrOffsetSectionSize += sizeof(uint32_t);
322
323
324 MS->emitInt16(5);
325 StrOffsetSectionSize += sizeof(uint16_t);
326
327
328 MS->emitInt16(0);
329 StrOffsetSectionSize += sizeof(uint16_t);
330
331 for (auto Off : StringOffsets) {
332 Asm->OutStreamer->emitInt32(Off);
333 StrOffsetSectionSize += sizeof(uint32_t);
334 }
335 Asm->OutStreamer->emitLabel(EndLabel);
336}
337
338
340 Asm->OutStreamer->switchSection(MOFI->getDwarfLineStrSection());
342 for (auto Entry : Entries) {
343
344 Asm->OutStreamer->emitBytes(Entry.getString());
345
346 Asm->emitInt8(0);
347 }
348}
349
351 if (EmittedUnits.empty())
352 return;
353
354
355 std::vector<std::variant<MCSymbol *, uint64_t>> CompUnits;
357 unsigned Id = 0;
358 for (auto &CU : EmittedUnits) {
359 CompUnits.push_back(CU.LabelBegin);
360
361 UniqueIdToCuMap[CU.ID] = Id++;
362 }
363
364 Asm->OutStreamer->switchSection(MOFI->getDwarfDebugNamesSection());
367
368
369
371 Asm.get(), Table, CompUnits,
373 -> std::optionalDWARF5AccelTable::UnitIndexAndEncoding {
374 if (UniqueIdToCuMap.size() > 1)
375 return {{UniqueIdToCuMap[Entry.getUnitID()],
376 {dwarf::DW_IDX_compile_unit, Form}}};
377 return std::nullopt;
378 });
379}
380
383 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelNamespaceSection());
384 auto *SectionBegin = Asm->createTempSymbol("namespac_begin");
385 Asm->OutStreamer->emitLabel(SectionBegin);
387}
388
391 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelNamesSection());
392 auto *SectionBegin = Asm->createTempSymbol("names_begin");
393 Asm->OutStreamer->emitLabel(SectionBegin);
395}
396
399 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelObjCSection());
400 auto *SectionBegin = Asm->createTempSymbol("objc_begin");
401 Asm->OutStreamer->emitLabel(SectionBegin);
403}
404
407 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelTypesSection());
408 auto *SectionBegin = Asm->createTempSymbol("types_begin");
409 Asm->OutStreamer->emitLabel(SectionBegin);
411}
412
413
415 MCSection *SwiftASTSection = MOFI->getDwarfSwiftASTSection();
417 MS->switchSection(SwiftASTSection);
418 MS->emitBytes(Buffer);
419}
420
425 MOFI->getSwift5ReflectionSection(ReflSectionKind);
426 if (ReflectionSection == nullptr)
427 return;
429 MS->switchSection(ReflectionSection);
430 MS->emitBytes(Buffer);
431}
432
435 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
436
437
438 MS->switchSection(MC->getObjectFileInfo()->getDwarfARangesSection());
439
440
441 MCSymbol *BeginLabel = Asm->createTempSymbol("Barange");
442 MCSymbol *EndLabel = Asm->createTempSymbol("Earange");
443
444 unsigned HeaderSize =
445 sizeof(int32_t) +
446 sizeof(int16_t) +
447 sizeof(int32_t) +
448 sizeof(int8_t) +
449 sizeof(int8_t);
450
451 unsigned TupleSize = AddressSize * 2;
453
454 Asm->emitLabelDifference(EndLabel, BeginLabel, 4);
455 Asm->OutStreamer->emitLabel(BeginLabel);
457 Asm->emitInt32(Unit.getStartOffset());
458 Asm->emitInt8(AddressSize);
459 Asm->emitInt8(0);
460
461 Asm->OutStreamer->emitFill(Padding, 0x0);
462
463
465 MS->emitIntValue(Range.start(), AddressSize);
466 MS->emitIntValue(Range.end() - Range.start(), AddressSize);
467 }
468
469
470 Asm->OutStreamer->emitIntValue(0, AddressSize);
471 Asm->OutStreamer->emitIntValue(0, AddressSize);
472 Asm->OutStreamer->emitLabel(EndLabel);
473}
474
475void DwarfStreamer::emitDwarfDebugRangesTableFragment(
478 Patch.set(RangesSectionSize);
479
480
481 MS->switchSection(MC->getObjectFileInfo()->getDwarfRangesSection());
482 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
483
484
486 if (std::optional<uint64_t> LowPC = Unit.getLowPc())
487 BaseAddress = *LowPC;
488
492
493 RangesSectionSize += AddressSize;
494 RangesSectionSize += AddressSize;
495 }
496
497
500
501 RangesSectionSize += AddressSize;
502 RangesSectionSize += AddressSize;
503}
504
507 if (Unit.getOrigUnit().getVersion() < 5)
508 return nullptr;
509
510
511 MS->switchSection(MC->getObjectFileInfo()->getDwarfRnglistsSection());
512
513 MCSymbol *BeginLabel = Asm->createTempSymbol("Brnglists");
514 MCSymbol *EndLabel = Asm->createTempSymbol("Ernglists");
515 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
516
517
518 Asm->emitLabelDifference(EndLabel, BeginLabel, sizeof(uint32_t));
519 Asm->OutStreamer->emitLabel(BeginLabel);
520 RngListsSectionSize += sizeof(uint32_t);
521
522
523 MS->emitInt16(5);
524 RngListsSectionSize += sizeof(uint16_t);
525
526
527 MS->emitInt8(AddressSize);
528 RngListsSectionSize++;
529
530
531 MS->emitInt8(0);
532 RngListsSectionSize++;
533
534
535 MS->emitInt32(0);
536 RngListsSectionSize += sizeof(uint32_t);
537
538 return EndLabel;
539}
540
544 if (Unit.getOrigUnit().getVersion() < 5) {
545 emitDwarfDebugRangesTableFragment(Unit, LinkedRanges, Patch);
546 return;
547 }
548
549 emitDwarfDebugRngListsTableFragment(Unit, LinkedRanges, Patch, AddrPool);
550}
551
554 if (Unit.getOrigUnit().getVersion() < 5)
555 return;
556
557
558 MS->switchSection(MC->getObjectFileInfo()->getDwarfRnglistsSection());
559
560 if (EndLabel != nullptr)
561 Asm->OutStreamer->emitLabel(EndLabel);
562}
563
564void DwarfStreamer::emitDwarfDebugRngListsTableFragment(
567 Patch.set(RngListsSectionSize);
568
569
570 MS->switchSection(MC->getObjectFileInfo()->getDwarfRnglistsSection());
571 std::optional<uint64_t> BaseAddress;
572
574
575 if (!BaseAddress) {
576 BaseAddress = Range.start();
577
578
579 MS->emitInt8(dwarf::DW_RLE_base_addressx);
580 RngListsSectionSize += 1;
581 RngListsSectionSize +=
583 }
584
585
586 MS->emitInt8(dwarf::DW_RLE_offset_pair);
587 RngListsSectionSize += 1;
588
589
590 RngListsSectionSize +=
592
593
595 }
596
597
598 MS->emitInt8(dwarf::DW_RLE_end_of_list);
599 RngListsSectionSize += 1;
600}
601
602
604 if (Unit.getOrigUnit().getVersion() < 5)
605 return nullptr;
606
607
608 MS->switchSection(MC->getObjectFileInfo()->getDwarfLoclistsSection());
609
610 MCSymbol *BeginLabel = Asm->createTempSymbol("Bloclists");
611 MCSymbol *EndLabel = Asm->createTempSymbol("Eloclists");
612 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
613
614
615 Asm->emitLabelDifference(EndLabel, BeginLabel, sizeof(uint32_t));
616 Asm->OutStreamer->emitLabel(BeginLabel);
617 LocListsSectionSize += sizeof(uint32_t);
618
619
620 MS->emitInt16(5);
621 LocListsSectionSize += sizeof(uint16_t);
622
623
624 MS->emitInt8(AddressSize);
625 LocListsSectionSize++;
626
627
628 MS->emitInt8(0);
629 LocListsSectionSize++;
630
631
632 MS->emitInt32(0);
633 LocListsSectionSize += sizeof(uint32_t);
634
635 return EndLabel;
636}
637
638
643 if (Unit.getOrigUnit().getVersion() < 5) {
644 emitDwarfDebugLocTableFragment(Unit, LinkedLocationExpression, Patch);
645 return;
646 }
647
648 emitDwarfDebugLocListsTableFragment(Unit, LinkedLocationExpression, Patch,
649 AddrPool);
650}
651
652
655 if (Unit.getOrigUnit().getVersion() < 5)
656 return;
657
658
659 MS->switchSection(MC->getObjectFileInfo()->getDwarfLoclistsSection());
660
661 if (EndLabel != nullptr)
662 Asm->OutStreamer->emitLabel(EndLabel);
663}
664
665
666void DwarfStreamer::emitDwarfDebugLocTableFragment(
670 Patch.set(LocSectionSize);
671
672
673 MS->switchSection(MC->getObjectFileInfo()->getDwarfLocSection());
674 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
675
676
678 if (std::optional<uint64_t> LowPC = Unit.getLowPc())
679 BaseAddress = *LowPC;
680
682 LinkedLocationExpression) {
683 if (LocExpression.Range) {
684 MS->emitIntValue(LocExpression.Range->LowPC - BaseAddress, AddressSize);
685 MS->emitIntValue(LocExpression.Range->HighPC - BaseAddress, AddressSize);
686
687 LocSectionSize += AddressSize;
688 LocSectionSize += AddressSize;
689 }
690
691 Asm->OutStreamer->emitIntValue(LocExpression.Expr.size(), 2);
692 Asm->OutStreamer->emitBytes(StringRef(
693 (const char *)LocExpression.Expr.data(), LocExpression.Expr.size()));
694 LocSectionSize += LocExpression.Expr.size() + 2;
695 }
696
697
700
701 LocSectionSize += AddressSize;
702 LocSectionSize += AddressSize;
703}
704
705
707
708
709 MS->switchSection(MC->getObjectFileInfo()->getDwarfAddrSection());
710
711 MCSymbol *BeginLabel = Asm->createTempSymbol("Bdebugaddr");
712 MCSymbol *EndLabel = Asm->createTempSymbol("Edebugaddr");
713 unsigned AddrSize = Unit.getOrigUnit().getAddressByteSize();
714
715
716 Asm->emitLabelDifference(EndLabel, BeginLabel, sizeof(uint32_t));
717 Asm->OutStreamer->emitLabel(BeginLabel);
718 AddrSectionSize += sizeof(uint32_t);
719
720
721 Asm->emitInt16(5);
722 AddrSectionSize += 2;
723
724
725 Asm->emitInt8(AddrSize);
726 AddrSectionSize += 1;
727
728
729 Asm->emitInt8(0);
730 AddrSectionSize += 1;
731
732 return EndLabel;
733}
734
735
738 Asm->OutStreamer->switchSection(MOFI->getDwarfAddrSection());
739 for (auto Addr : Addrs) {
740 Asm->OutStreamer->emitIntValue(Addr, AddrSize);
741 AddrSectionSize += AddrSize;
742 }
743}
744
745
748
749
750 MS->switchSection(MC->getObjectFileInfo()->getDwarfAddrSection());
751
752 if (EndLabel != nullptr)
753 Asm->OutStreamer->emitLabel(EndLabel);
754}
755
756
757void DwarfStreamer::emitDwarfDebugLocListsTableFragment(
761 Patch.set(LocListsSectionSize);
762
763
764 MS->switchSection(MC->getObjectFileInfo()->getDwarfLoclistsSection());
765 std::optional<uint64_t> BaseAddress;
766
768 LinkedLocationExpression) {
769 if (LocExpression.Range) {
770
771 if (!BaseAddress) {
772
773 BaseAddress = LocExpression.Range->LowPC;
774
775
776 MS->emitInt8(dwarf::DW_LLE_base_addressx);
777 LocListsSectionSize += 1;
778 LocListsSectionSize +=
780 }
781
782
783 MS->emitInt8(dwarf::DW_LLE_offset_pair);
784 LocListsSectionSize += 1;
785
786
787 LocListsSectionSize +=
789
790
791 LocListsSectionSize +=
793 } else {
794
795 MS->emitInt8(dwarf::DW_LLE_default_location);
796 LocListsSectionSize += 1;
797 }
798
799 LocListsSectionSize += MS->emitULEB128IntValue(LocExpression.Expr.size());
800 Asm->OutStreamer->emitBytes(StringRef(
801 (const char *)LocExpression.Expr.data(), LocExpression.Expr.size()));
802 LocListsSectionSize += LocExpression.Expr.size();
803 }
804
805
806 MS->emitInt8(dwarf::DW_LLE_end_of_list);
807 LocListsSectionSize += 1;
808}
809
813 std::vector<uint64_t> *RowOffsets) {
814
815 MS->switchSection(MC->getObjectFileInfo()->getDwarfLineSection());
816
817 MCSymbol *LineStartSym = MC->createTempSymbol();
818 MCSymbol *LineEndSym = MC->createTempSymbol();
819
820
823 LineSectionSize += 4;
824 }
825 emitLabelDifference(LineEndSym, LineStartSym,
827 Asm->OutStreamer->emitLabel(LineStartSym);
828
829
830 emitLineTablePrologue(LineTable.Prologue, DebugStrPool, DebugLineStrPool);
831
832
833 emitLineTableRows(LineTable, LineEndSym,
834 Unit.getOrigUnit().getAddressByteSize(), RowOffsets);
835}
836
840 MCSymbol *PrologueStartSym = MC->createTempSymbol();
841 MCSymbol *PrologueEndSym = MC->createTempSymbol();
842
843
845 LineSectionSize += 2;
846 if (P.getVersion() == 5) {
847
848 MS->emitInt8(P.getAddressSize());
849 LineSectionSize += 1;
850
851
853 LineSectionSize += 1;
854 }
855
856
857 emitLabelDifference(PrologueEndSym, PrologueStartSym, P.FormParams.Format,
858 LineSectionSize);
859
860 Asm->OutStreamer->emitLabel(PrologueStartSym);
861 emitLineTableProloguePayload(P, DebugStrPool, DebugLineStrPool);
862 Asm->OutStreamer->emitLabel(PrologueEndSym);
863}
864
865void DwarfStreamer::emitLineTablePrologueV2IncludeAndFileTable(
868
870 emitLineTableString(P, Include, DebugStrPool, DebugLineStrPool);
871
873 LineSectionSize += 1;
874
875
877
878
879 emitLineTableString(P, File.Name, DebugStrPool, DebugLineStrPool);
880
881
883
884
886
887
889 }
890
892 LineSectionSize += 1;
893}
894
895void DwarfStreamer::emitLineTablePrologueV5IncludeAndFileTable(
898 if (P.IncludeDirectories.empty()) {
899
900 MS->emitInt8(0);
901 LineSectionSize += 1;
902 } else {
903
904 MS->emitInt8(1);
905 LineSectionSize += 1;
906
907
908 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_LNCT_path);
909 LineSectionSize +=
910 MS->emitULEB128IntValue(P.IncludeDirectories[0].getForm());
911 }
912
913
914 LineSectionSize += MS->emitULEB128IntValue(P.IncludeDirectories.size());
915
916 for (auto Include : P.IncludeDirectories)
917 emitLineTableString(P, Include, DebugStrPool, DebugLineStrPool);
918
919 bool HasChecksums = P.ContentTypes.HasMD5;
920 bool HasInlineSources = P.ContentTypes.HasSource;
921
922 if (P.FileNames.empty()) {
923
924 MS->emitInt8(0);
925 LineSectionSize += 1;
926 } else {
927
928 MS->emitInt8(2 + (HasChecksums ? 1 : 0) + (HasInlineSources ? 1 : 0));
929 LineSectionSize += 1;
930
931
932 auto StrForm = P.FileNames[0].Name.getForm();
933 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_LNCT_path);
934 LineSectionSize += MS->emitULEB128IntValue(StrForm);
935
936 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_LNCT_directory_index);
937 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_FORM_udata);
938
939 if (HasChecksums) {
940 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_LNCT_MD5);
941 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_FORM_data16);
942 }
943
944 if (HasInlineSources) {
945 LineSectionSize += MS->emitULEB128IntValue(dwarf::DW_LNCT_LLVM_source);
946 LineSectionSize += MS->emitULEB128IntValue(StrForm);
947 }
948 }
949
950
951 LineSectionSize += MS->emitULEB128IntValue(P.FileNames.size());
952
953
954 for (auto File : P.FileNames) {
955 emitLineTableString(P, File.Name, DebugStrPool, DebugLineStrPool);
956 LineSectionSize += MS->emitULEB128IntValue(File.DirIdx);
957 if (HasChecksums) {
958 MS->emitBinaryData(
959 StringRef(reinterpret_cast<const char *>(File.Checksum.data()),
960 File.Checksum.size()));
961 LineSectionSize += File.Checksum.size();
962 }
963 if (HasInlineSources)
964 emitLineTableString(P, File.Source, DebugStrPool, DebugLineStrPool);
965 }
966}
967
968void DwarfStreamer::emitLineTableString(const DWARFDebugLine::Prologue &P,
969 const DWARFFormValue &String,
973 if (!StringVal) {
974 warn("Cann't read string from line table.");
975 return;
976 }
977
978 switch (String.getForm()) {
979 case dwarf::DW_FORM_string: {
980 StringRef Str = *StringVal;
981 Asm->OutStreamer->emitBytes(Str.data());
982 Asm->emitInt8(0);
983 LineSectionSize += Str.size() + 1;
984 } break;
985 case dwarf::DW_FORM_strp:
986 case dwarf::DW_FORM_line_strp: {
987 DwarfStringPoolEntryRef StringRef =
988 String.getForm() == dwarf::DW_FORM_strp
989 ? DebugStrPool.getEntry(*StringVal)
990 : DebugLineStrPool.getEntry(*StringVal);
991
992 emitIntOffset(StringRef.getOffset(), P.FormParams.Format, LineSectionSize);
993 } break;
994 default:
995 warn("Unsupported string form inside line table.");
996 break;
997 };
998}
999
1000void DwarfStreamer::emitLineTableProloguePayload(
1003
1004 MS->emitInt8(P.MinInstLength);
1005 LineSectionSize += 1;
1006 if (P.FormParams.Version >= 4) {
1007
1008 MS->emitInt8(P.MaxOpsPerInst);
1009 LineSectionSize += 1;
1010 }
1011
1012 MS->emitInt8(P.DefaultIsStmt);
1013 LineSectionSize += 1;
1014
1015 MS->emitInt8(P.LineBase);
1016 LineSectionSize += 1;
1017
1018 MS->emitInt8(P.LineRange);
1019 LineSectionSize += 1;
1020
1021 MS->emitInt8(P.OpcodeBase);
1022 LineSectionSize += 1;
1023
1024
1025 for (auto Length : P.StandardOpcodeLengths) {
1026 MS->emitInt8(Length);
1027 LineSectionSize += 1;
1028 }
1029
1030 if (P.FormParams.Version < 5)
1031 emitLineTablePrologueV2IncludeAndFileTable(P, DebugStrPool,
1032 DebugLineStrPool);
1033 else
1034 emitLineTablePrologueV5IncludeAndFileTable(P, DebugStrPool,
1035 DebugLineStrPool);
1036}
1037
1038void DwarfStreamer::emitLineTableRows(
1039 const DWARFDebugLine::LineTable &LineTable, MCSymbol *LineEndSym,
1040 unsigned AddressByteSize, std::vector<uint64_t> *RowOffsets) {
1041
1042 MCDwarfLineTableParams Params;
1046
1047 SmallString<128> EncodingBuffer;
1048
1049 if (LineTable.Rows.empty()) {
1050
1051
1053 EncodingBuffer);
1054 MS->emitBytes(EncodingBuffer);
1055 LineSectionSize += EncodingBuffer.size();
1056 MS->emitLabel(LineEndSym);
1057 return;
1058 }
1059
1060
1061 unsigned FileNum = 1;
1062 unsigned LastLine = 1;
1063 unsigned Column = 0;
1065 unsigned IsStatement = 1;
1066 unsigned Isa = 0;
1067 uint64_t Address = -1ULL;
1068
1069 unsigned RowsSinceLastSequence = 0;
1070
1071 for (const DWARFDebugLine::Row &Row : LineTable.Rows) {
1072
1073
1074 if (RowOffsets)
1075 RowOffsets->push_back(LineSectionSize);
1076
1079 MS->emitIntValue(dwarf::DW_LNS_extended_op, 1);
1080 MS->emitULEB128IntValue(AddressByteSize + 1);
1081 MS->emitIntValue(dwarf::DW_LNE_set_address, 1);
1082 MS->emitIntValue(Row.Address.Address, AddressByteSize);
1083 LineSectionSize +=
1084 2 + AddressByteSize + getULEB128Size(AddressByteSize + 1);
1086 } else {
1089 }
1090
1091
1092
1093
1094
1095
1096 if (FileNum != Row.File) {
1097 FileNum = Row.File;
1098 MS->emitIntValue(dwarf::DW_LNS_set_file, 1);
1099 MS->emitULEB128IntValue(FileNum);
1101 }
1102 if (Column != Row.Column) {
1103 Column = Row.Column;
1104 MS->emitIntValue(dwarf::DW_LNS_set_column, 1);
1105 MS->emitULEB128IntValue(Column);
1107 }
1108 if (Discriminator != Row.Discriminator &&
1109 MS->getContext().getDwarfVersion() >= 4) {
1112 MS->emitIntValue(dwarf::DW_LNS_extended_op, 1);
1113 MS->emitULEB128IntValue(Size + 1);
1114 MS->emitIntValue(dwarf::DW_LNE_set_discriminator, 1);
1115 MS->emitULEB128IntValue(Discriminator);
1117 1 + Size;
1118 }
1120
1121 if (Isa != Row.Isa) {
1122 Isa = Row.Isa;
1123 MS->emitIntValue(dwarf::DW_LNS_set_isa, 1);
1124 MS->emitULEB128IntValue(Isa);
1126 }
1127 if (IsStatement != Row.IsStmt) {
1128 IsStatement = Row.IsStmt;
1129 MS->emitIntValue(dwarf::DW_LNS_negate_stmt, 1);
1130 LineSectionSize += 1;
1131 }
1132 if (Row.BasicBlock) {
1133 MS->emitIntValue(dwarf::DW_LNS_set_basic_block, 1);
1134 LineSectionSize += 1;
1135 }
1136
1137 if (Row.PrologueEnd) {
1138 MS->emitIntValue(dwarf::DW_LNS_set_prologue_end, 1);
1139 LineSectionSize += 1;
1140 }
1141
1142 if (Row.EpilogueBegin) {
1143 MS->emitIntValue(dwarf::DW_LNS_set_epilogue_begin, 1);
1144 LineSectionSize += 1;
1145 }
1146
1147 int64_t LineDelta = int64_t(Row.Line) - LastLine;
1148 if (!Row.EndSequence) {
1150 EncodingBuffer);
1151 MS->emitBytes(EncodingBuffer);
1152 LineSectionSize += EncodingBuffer.size();
1153 EncodingBuffer.resize(0);
1154 Address = Row.Address.Address;
1155 LastLine = Row.Line;
1156 RowsSinceLastSequence++;
1157 } else {
1158 if (LineDelta) {
1159 MS->emitIntValue(dwarf::DW_LNS_advance_line, 1);
1160 MS->emitSLEB128IntValue(LineDelta);
1162 }
1164 MS->emitIntValue(dwarf::DW_LNS_advance_pc, 1);
1167 }
1169 0, EncodingBuffer);
1170 MS->emitBytes(EncodingBuffer);
1171 LineSectionSize += EncodingBuffer.size();
1172 EncodingBuffer.resize(0);
1174 LastLine = FileNum = IsStatement = 1;
1175 RowsSinceLastSequence = Column = Discriminator = Isa = 0;
1176 }
1177 }
1178
1179 if (RowsSinceLastSequence) {
1181 EncodingBuffer);
1182 MS->emitBytes(EncodingBuffer);
1183 LineSectionSize += EncodingBuffer.size();
1184 EncodingBuffer.resize(0);
1185 }
1186
1187 MS->emitLabel(LineEndSym);
1188}
1189
1191 uint64_t &SectionSize) {
1195}
1196
1197void DwarfStreamer::emitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
1199 uint64_t &SectionSize) {
1201 Asm->emitLabelDifference(Hi, Lo, Size);
1203}
1204
1205
1206
1207void DwarfStreamer::emitPubSectionForUnit(
1208 MCSection *Sec, StringRef SecName, const CompileUnit &Unit,
1209 const std::vectorCompileUnit::AccelInfo &Names) {
1210 if (Names.empty())
1211 return;
1212
1213
1214 Asm->OutStreamer->switchSection(Sec);
1215 MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + SecName + "_begin");
1216 MCSymbol *EndLabel = Asm->createTempSymbol("pub" + SecName + "_end");
1217
1218 bool HeaderEmitted = false;
1219
1220 for (const auto &Name : Names) {
1221 if (Name.SkipPubSection)
1222 continue;
1223
1224 if (!HeaderEmitted) {
1225
1226 Asm->emitLabelDifference(EndLabel, BeginLabel, 4);
1227 Asm->OutStreamer->emitLabel(BeginLabel);
1229 Asm->emitInt32(Unit.getStartOffset());
1230 Asm->emitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset());
1231 HeaderEmitted = true;
1232 }
1233 Asm->emitInt32(Name.Die->getOffset());
1234
1235
1236 Asm->OutStreamer->emitBytes(Name.Name.getString());
1237
1238 Asm->emitInt8(0);
1239 }
1240
1241 if (!HeaderEmitted)
1242 return;
1243 Asm->emitInt32(0);
1244 Asm->OutStreamer->emitLabel(EndLabel);
1245}
1246
1247
1249 emitPubSectionForUnit(MC->getObjectFileInfo()->getDwarfPubNamesSection(),
1250 "names", Unit, Unit.getPubnames());
1251}
1252
1253
1255 emitPubSectionForUnit(MC->getObjectFileInfo()->getDwarfPubTypesSection(),
1256 "types", Unit, Unit.getPubtypes());
1257}
1258
1259
1261 MS->switchSection(MC->getObjectFileInfo()->getDwarfFrameSection());
1262
1263 MS->emitBytes(CIEBytes);
1264 FrameSectionSize += CIEBytes.size();
1265}
1266
1267
1268
1269
1272 MS->switchSection(MC->getObjectFileInfo()->getDwarfFrameSection());
1273
1274 MS->emitIntValue(FDEBytes.size() + 4 + AddrSize, 4);
1275 MS->emitIntValue(CIEOffset, 4);
1276 MS->emitIntValue(Address, AddrSize);
1277 MS->emitBytes(FDEBytes);
1278 FrameSectionSize += FDEBytes.size() + 8 + AddrSize;
1279}
1280
1284 assert(Context != nullptr && "Empty DWARF context");
1285
1286
1287 if (const DWARFDebugMacro *Table = Context->getDebugMacinfo()) {
1288 MS->switchSection(MC->getObjectFileInfo()->getDwarfMacinfoSection());
1289 emitMacroTableImpl(Table, UnitMacroMap, StringPool, MacInfoSectionSize);
1290 }
1291
1292
1293 if (const DWARFDebugMacro *Table = Context->getDebugMacro()) {
1294 MS->switchSection(MC->getObjectFileInfo()->getDwarfMacroSection());
1295 emitMacroTableImpl(Table, UnitMacroMap, StringPool, MacroSectionSize);
1296 }
1297}
1298
1299void DwarfStreamer::emitMacroTableImpl(const DWARFDebugMacro *MacroTable,
1303 bool DefAttributeIsReported = false;
1304 bool UndefAttributeIsReported = false;
1305 bool ImportAttributeIsReported = false;
1306 for (const DWARFDebugMacro::MacroList &List : MacroTable->MacroLists) {
1308 if (UnitIt == UnitMacroMap.end()) {
1310 "couldn`t find compile unit for the macro table with offset = {0:x}",
1311 List.Offset));
1312 continue;
1313 }
1314
1315
1316 DIE *OutputUnitDIE = UnitIt->second->getOutputUnitDIE();
1317 if (OutputUnitDIE == nullptr)
1318 continue;
1319
1320
1321
1322 bool hasDWARFv5Header = false;
1323 for (auto &V : OutputUnitDIE->values()) {
1324 if (V.getAttribute() == dwarf::DW_AT_macro_info) {
1326 break;
1327 } else if (V.getAttribute() == dwarf::DW_AT_macros) {
1328 hasDWARFv5Header = true;
1330 break;
1331 }
1332 }
1333
1334
1335 if (hasDWARFv5Header) {
1336
1337 MS->emitIntValue(List.Header.Version, sizeof(List.Header.Version));
1338 OutOffset += sizeof(List.Header.Version);
1339
1340 uint8_t Flags = List.Header.Flags;
1341
1342
1343 if (Flags &
1344 DWARFDebugMacro::HeaderFlagMask::MACRO_OPCODE_OPERANDS_TABLE) {
1345 Flags &= ~DWARFDebugMacro::HeaderFlagMask::MACRO_OPCODE_OPERANDS_TABLE;
1346 warn("opcode_operands_table is not supported yet.");
1347 }
1348
1349
1350 std::optional<uint64_t> StmtListOffset;
1351 if (Flags & DWARFDebugMacro::HeaderFlagMask::MACRO_DEBUG_LINE_OFFSET) {
1352
1353 for (auto &V : OutputUnitDIE->values()) {
1354 if (V.getAttribute() == dwarf::DW_AT_stmt_list) {
1355 StmtListOffset = V.getDIEInteger().getValue();
1356 break;
1357 }
1358 }
1359
1360 if (!StmtListOffset) {
1361 Flags &= ~DWARFDebugMacro::HeaderFlagMask::MACRO_DEBUG_LINE_OFFSET;
1362 warn("couldn`t find line table for macro table.");
1363 }
1364 }
1365
1366
1367 MS->emitIntValue(Flags, sizeof(Flags));
1368 OutOffset += sizeof(Flags);
1369
1370
1371 if (StmtListOffset) {
1372 MS->emitIntValue(*StmtListOffset, List.Header.getOffsetByteSize());
1373 OutOffset += List.Header.getOffsetByteSize();
1374 }
1375 }
1376
1377
1378 for (const DWARFDebugMacro::Entry &MacroEntry : List.Macros) {
1379 if (MacroEntry.Type == 0) {
1380 OutOffset += MS->emitULEB128IntValue(MacroEntry.Type);
1381 continue;
1382 }
1383
1384 uint8_t MacroType = MacroEntry.Type;
1385 switch (MacroType) {
1386 default: {
1387 bool HasVendorSpecificExtension =
1391
1392 if (HasVendorSpecificExtension) {
1393
1394 MS->emitIntValue(MacroType, 1);
1395 OutOffset++;
1396
1397
1398 OutOffset += MS->emitULEB128IntValue(MacroEntry.ExtConstant);
1399
1400
1401 StringRef String = MacroEntry.ExtStr;
1402 MS->emitBytes(String);
1403 MS->emitIntValue(0, 1);
1404 OutOffset += String.size() + 1;
1405 } else
1406 warn("unknown macro type. skip.");
1407 } break;
1408
1409
1410
1411
1412
1413
1414 case dwarf::DW_MACRO_define:
1415 case dwarf::DW_MACRO_undef: {
1416
1417 MS->emitIntValue(MacroType, 1);
1418 OutOffset++;
1419
1420
1421 OutOffset += MS->emitULEB128IntValue(MacroEntry.Line);
1422
1423
1424 StringRef String = MacroEntry.MacroStr;
1425 MS->emitBytes(String);
1426 MS->emitIntValue(0, 1);
1427 OutOffset += String.size() + 1;
1428 } break;
1429 case dwarf::DW_MACRO_define_strp:
1430 case dwarf::DW_MACRO_undef_strp:
1431 case dwarf::DW_MACRO_define_strx:
1432 case dwarf::DW_MACRO_undef_strx: {
1433 assert(UnitIt->second->getOrigUnit().getVersion() >= 5);
1434
1435
1436
1437 switch (MacroType) {
1438 case dwarf::DW_MACRO_define_strx: {
1439 MacroType = dwarf::DW_MACRO_define_strp;
1440 if (!DefAttributeIsReported) {
1441 warn("DW_MACRO_define_strx unsupported yet. Convert to "
1442 "DW_MACRO_define_strp.");
1443 DefAttributeIsReported = true;
1444 }
1445 } break;
1446 case dwarf::DW_MACRO_undef_strx: {
1447 MacroType = dwarf::DW_MACRO_undef_strp;
1448 if (!UndefAttributeIsReported) {
1449 warn("DW_MACRO_undef_strx unsupported yet. Convert to "
1450 "DW_MACRO_undef_strp.");
1451 UndefAttributeIsReported = true;
1452 }
1453 } break;
1454 default:
1455
1456 break;
1457 }
1458
1459
1460 MS->emitIntValue(MacroType, 1);
1461 OutOffset++;
1462
1463
1464 OutOffset += MS->emitULEB128IntValue(MacroEntry.Line);
1465
1466
1467 DwarfStringPoolEntryRef EntryRef =
1468 StringPool.getEntry(MacroEntry.MacroStr);
1469 MS->emitIntValue(EntryRef.getOffset(), List.Header.getOffsetByteSize());
1470 OutOffset += List.Header.getOffsetByteSize();
1471 break;
1472 }
1473 case dwarf::DW_MACRO_start_file: {
1474
1475 MS->emitIntValue(MacroType, 1);
1476 OutOffset++;
1477
1478 OutOffset += MS->emitULEB128IntValue(MacroEntry.Line);
1479
1480 OutOffset += MS->emitULEB128IntValue(MacroEntry.File);
1481 } break;
1482 case dwarf::DW_MACRO_end_file: {
1483
1484 MS->emitIntValue(MacroType, 1);
1485 OutOffset++;
1486 } break;
1487 case dwarf::DW_MACRO_import:
1488 case dwarf::DW_MACRO_import_sup: {
1489 if (!ImportAttributeIsReported) {
1490 warn("DW_MACRO_import and DW_MACRO_import_sup are unsupported yet. "
1491 "remove.");
1492 ImportAttributeIsReported = true;
1493 }
1494 } break;
1495 }
1496 }
1497 }
1498}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
A class that represents an address range.
The AddressRanges class helps normalize address range collections.
static dwarf::Form BestForm(bool IsSigned, uint64_t Int)
Choose the best form for integer.
A structured debug information entry.
The Data class implementation for DWARF v5 accelerator table.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
iterator find(const_arg_type_t< KeyT > Val)
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT, true > const_iterator
uint64_t getOffset() const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Context object for machine code objects.
static LLVM_ABI void encode(MCContext &Context, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta, SmallVectorImpl< char > &OS)
Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
void setAlignment(Align Value)
virtual void emitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers.
void emitInt16(uint64_t Value)
unsigned emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
void emitInt8(uint64_t Value)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
DwarfDirectory MCUseDwarfDirectory
A string table that doesn't need relocations.
LLVM_ABI DwarfStringPoolEntryRef getEntry(StringRef S)
LLVM_ABI std::vector< DwarfStringPoolEntryRef > getEntriesForEmission() const
Return the list of strings to be emitted.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr size_t size() const
size - Get the string size.
Target - Wrapper for Target specific information.
TargetMachine * createTargetMachine(const Triple &TT, StringRef CPU, StringRef Features, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM=std::nullopt, CodeGenOptLevel OL=CodeGenOptLevel::Default, bool JIT=false) const
createTargetMachine - Create a target specific machine implementation for the specified Triple.
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
MCObjectFileInfo * createMCObjectFileInfo(MCContext &Ctx, bool PIC, bool LargeCodeModel=false) const
Create a MCObjectFileInfo implementation for the specified target triple.
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
MCAsmBackend * createMCAsmBackend(const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) const
createMCAsmBackend - Create a target specific assembly parser.
LLVM_ABI MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, std::unique_ptr< MCInstPrinter > IP, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCAsmBackend > TAB) const
MCRegisterInfo * createMCRegInfo(StringRef TT) const
LLVM_ABI MCStreamer * createMCObjectStreamer(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > TAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter, const MCSubtargetInfo &STI) const
Create a target specific MCStreamer.
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple, const MCTargetOptions &Options) const
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
AsmPrinter * createAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) const
createAsmPrinter - Create a target specific assembly printer pass.
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
Triple - Helper class for working with autoconf configuration names.
const std::string & getTriple() const
std::function< void( const Twine &Warning, StringRef Context, const DWARFDie *DIE)> MessageHandlerTy
OutputFileType
Type of output file.
uint64_t getValueIndex(T Value)
Stores all information relating to a compile unit, be it in its original instance in the object file ...
void emitDwarfDebugAddrsFooter(const CompileUnit &Unit, MCSymbol *EndLabel) override
Emit .debug_addr footer.
Definition DWARFStreamer.cpp:746
void emitDwarfDebugArangesTable(const CompileUnit &Unit, const AddressRanges &LinkedRanges) override
Emit .debug_aranges entries for Unit.
Definition DWARFStreamer.cpp:433
void emitLineTableForUnit(const DWARFDebugLine::LineTable &LineTable, const CompileUnit &Unit, OffsetsStringPool &DebugStrPool, OffsetsStringPool &DebugLineStrPool, std::vector< uint64_t > *RowOffsets=nullptr) override
Emit .debug_line table entry for specified LineTable The optional parameter RowOffsets,...
Definition DWARFStreamer.cpp:810
void emitAppleTypes(AccelTable< AppleAccelTableStaticTypeData > &Table) override
Emit Apple type accelerator table.
Definition DWARFStreamer.cpp:405
void emitDIE(DIE &Die) override
Recursively emit the DIE tree rooted at Die.
Definition DWARFStreamer.cpp:220
void emitDwarfDebugLocListFragment(const CompileUnit &Unit, const DWARFLocationExpressionsVector &LinkedLocationExpression, PatchLocation Patch, DebugDieValuePool &AddrPool) override
Emit debug ranges(.debug_loc, .debug_loclists) fragment.
Definition DWARFStreamer.cpp:639
void emitStrings(const NonRelocatableStringpool &Pool) override
Emit the string table described by Pool into .debug_str table.
Definition DWARFStreamer.cpp:294
static Expected< std::unique_ptr< DwarfStreamer > > createStreamer(const Triple &TheTriple, DWARFLinkerBase::OutputFileType FileType, raw_pwrite_stream &OutFile, DWARFLinkerBase::MessageHandlerTy Warning)
Definition DWARFStreamer.cpp:33
void emitDebugNames(DWARF5AccelTable &Table) override
Emit DWARF debug names.
Definition DWARFStreamer.cpp:350
void emitDwarfDebugLocListFooter(const CompileUnit &Unit, MCSymbol *EndLabel) override
Emit debug ranges(.debug_loc, .debug_loclists) footer.
Definition DWARFStreamer.cpp:653
MCSymbol * emitDwarfDebugAddrsHeader(const CompileUnit &Unit) override
Emit .debug_addr header.
Definition DWARFStreamer.cpp:706
void emitStringOffsets(const SmallVector< uint64_t > &StringOffset, uint16_t TargetDWARFVersion) override
Emit the debug string offset table described by StringOffsets into the .debug_str_offsets table.
Definition DWARFStreamer.cpp:307
void emitLineStrings(const NonRelocatableStringpool &Pool) override
Emit the string table described by Pool into .debug_line_str table.
Definition DWARFStreamer.cpp:339
Error init(Triple TheTriple, StringRef Swift5ReflectionSegmentName)
Definition DWARFStreamer.cpp:44
void emitSwiftReflectionSection(llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind, StringRef Buffer, uint32_t Alignment, uint32_t Size)
Emit the swift reflection section stored in Buffer.
Definition DWARFStreamer.cpp:421
MCSymbol * emitDwarfDebugRangeListHeader(const CompileUnit &Unit) override
Emit debug ranges(.debug_ranges, .debug_rnglists) header.
Definition DWARFStreamer.cpp:506
void emitCIE(StringRef CIEBytes) override
Emit a CIE.
Definition DWARFStreamer.cpp:1260
void emitSectionContents(StringRef SecData, DebugSectionKind SecKind) override
Emit contents of section SecName From Obj.
Definition DWARFStreamer.cpp:227
void emitAppleNames(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple names accelerator table.
Definition DWARFStreamer.cpp:389
void finish() override
Dump the file to the disk.
Definition DWARFStreamer.cpp:153
void emitAbbrevs(const std::vector< std::unique_ptr< DIEAbbrev > > &Abbrevs, unsigned DwarfVersion) override
Emit the abbreviation table Abbrevs to the debug_abbrev section.
Definition DWARFStreamer.cpp:211
MCSymbol * emitDwarfDebugLocListHeader(const CompileUnit &Unit) override
Emit debug locations(.debug_loc, .debug_loclists) header.
Definition DWARFStreamer.cpp:603
void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint64_t Address, StringRef Bytes) override
Emit an FDE with data Bytes.
Definition DWARFStreamer.cpp:1270
void emitPubNamesForUnit(const CompileUnit &Unit) override
Emit the .debug_pubnames contribution for Unit.
Definition DWARFStreamer.cpp:1248
void emitDwarfDebugRangeListFragment(const CompileUnit &Unit, const AddressRanges &LinkedRanges, PatchLocation Patch, DebugDieValuePool &AddrPool) override
Emit debug ranges(.debug_ranges, .debug_rnglists) fragment.
Definition DWARFStreamer.cpp:541
void emitPubTypesForUnit(const CompileUnit &Unit) override
Emit the .debug_pubtypes contribution for Unit.
Definition DWARFStreamer.cpp:1254
void emitDwarfDebugAddrs(const SmallVector< uint64_t > &Addrs, uint8_t AddrSize) override
Emit the addresses described by Addrs into .debug_addr table.
Definition DWARFStreamer.cpp:736
void emitAppleObjc(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple Objective-C accelerator table.
Definition DWARFStreamer.cpp:397
void emitAppleNamespaces(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple namespaces accelerator table.
Definition DWARFStreamer.cpp:381
void emitMacroTables(DWARFContext *Context, const Offset2UnitMap &UnitMacroMap, OffsetsStringPool &StringPool) override
Emit all available macro tables(DWARFv4 and DWARFv5).
Definition DWARFStreamer.cpp:1281
void switchToDebugInfoSection(unsigned DwarfVersion)
Set the current output section to debug_info and change the MC Dwarf version to DwarfVersion.
Definition DWARFStreamer.cpp:155
void emitCompileUnitHeader(CompileUnit &Unit, unsigned DwarfVersion) override
Emit the compilation unit header for Unit in the debug_info section.
Definition DWARFStreamer.cpp:176
void emitSwiftAST(StringRef Buffer)
Emit the swift_ast section stored in Buffer.
Definition DWARFStreamer.cpp:414
void emitDwarfDebugRangeListFooter(const CompileUnit &Unit, MCSymbol *EndLabel) override
Emit debug ranges(.debug_ranges, .debug_rnglists) footer.
Definition DWARFStreamer.cpp:552
An abstract base class for streams implementations that also support a pwrite operation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Swift5ReflectionSectionKind
IndexedValuesMap< uint64_t > DebugDieValuePool
DenseMap< uint64_t, CompileUnit * > Offset2UnitMap
DebugSectionKind
List of tracked debug tables.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
@ DW_ARANGES_VERSION
Section version number for .debug_aranges.
@ DW_PUBNAMES_VERSION
Section version number for .debug_pubnames.
@ DW_LENGTH_DWARF64
Indicator of 64-bit DWARF format.
LLVM_ABI MCTargetOptions InitMCTargetOptionsFromFlags()
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
uint64_t offsetToAlignment(uint64_t Value, Align Alignment)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
LLVM_ABI unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
void emitAppleAccelTable(AsmPrinter *Asm, AccelTable< DataT > &Contents, StringRef Prefix, const MCSymbol *SecBegin)
Emit an Apple Accelerator Table consisting of entries in the specified AccelTable.
LLVM_ABI void emitDWARF5AccelTable(AsmPrinter *Asm, DWARF5AccelTable &Contents, const DwarfDebug &DD, ArrayRef< std::unique_ptr< DwarfCompileUnit > > CUs)
StrongType< NonRelocatableStringpool, OffsetsTag > OffsetsStringPool
LLVM_ABI unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.
std::vector< DWARFLocationExpression > DWARFLocationExpressionsVector
Represents a set of absolute location expressions.
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint8_t MinInstLength
The size in bytes of the smallest target machine instruction.
int8_t LineBase
This parameter affects the meaning of the special opcodes. See below.
uint8_t LineRange
This parameter affects the meaning of the special opcodes. See below.
uint8_t OpcodeBase
The number assigned to the first special opcode.
dwarf::FormParams FormParams
Version, address size (starting in v5), and DWARF32/64 format; these parameters affect interpretation...
Represents a single DWARF expression, whose value is location-dependent.
uint8_t DWARF2LineOpcodeBase
First special line opcode - leave room for the standard opcodes.
uint8_t DWARF2LineRange
Range of line offsets in a special line info. opcode.
int8_t DWARF2LineBase
Minimum line offset in a special line info.
static const Target * lookupTarget(StringRef TripleStr, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
void set(uint64_t New) const