LLVM  13.0.0git
DWARFStreamer.cpp
Go to the documentation of this file.
1 //===- DwarfStreamer.cpp --------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include "llvm/ADT/Triple.h"
14 #include "llvm/MC/MCAsmBackend.h"
15 #include "llvm/MC/MCCodeEmitter.h"
16 #include "llvm/MC/MCDwarf.h"
17 #include "llvm/MC/MCObjectWriter.h"
18 #include "llvm/MC/MCSection.h"
19 #include "llvm/MC/MCStreamer.h"
21 #include "llvm/MC/MCSymbol.h"
24 #include "llvm/Support/LEB128.h"
27 
28 namespace llvm {
29 
30 bool DwarfStreamer::init(Triple TheTriple) {
31  std::string ErrorStr;
32  std::string TripleName;
33  StringRef Context = "dwarf streamer init";
34 
35  // Get the target.
36  const Target *TheTarget =
37  TargetRegistry::lookupTarget(TripleName, TheTriple, ErrorStr);
38  if (!TheTarget)
39  return error(ErrorStr, Context), false;
40  TripleName = TheTriple.getTriple();
41 
42  // Create all the MC Objects.
43  MRI.reset(TheTarget->createMCRegInfo(TripleName));
44  if (!MRI)
45  return error(Twine("no register info for target ") + TripleName, Context),
46  false;
47 
49  MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
50  if (!MAI)
51  return error("no asm info for target " + TripleName, Context), false;
52 
53  MOFI.reset(new MCObjectFileInfo);
54  MC.reset(new MCContext(MAI.get(), MRI.get(), MOFI.get()));
55  MOFI->InitMCObjectFileInfo(TheTriple, /*PIC*/ false, *MC);
56 
57  MSTI.reset(TheTarget->createMCSubtargetInfo(TripleName, "", ""));
58  if (!MSTI)
59  return error("no subtarget info for target " + TripleName, Context), false;
60 
61  MAB = TheTarget->createMCAsmBackend(*MSTI, *MRI, MCOptions);
62  if (!MAB)
63  return error("no asm backend for target " + TripleName, Context), false;
64 
65  MII.reset(TheTarget->createMCInstrInfo());
66  if (!MII)
67  return error("no instr info info for target " + TripleName, Context), false;
68 
69  MCE = TheTarget->createMCCodeEmitter(*MII, *MRI, *MC);
70  if (!MCE)
71  return error("no code emitter for target " + TripleName, Context), false;
72 
73  switch (OutFileType) {
75  MIP = TheTarget->createMCInstPrinter(TheTriple, MAI->getAssemblerDialect(),
76  *MAI, *MII, *MRI);
77  MS = TheTarget->createAsmStreamer(
78  *MC, std::make_unique<formatted_raw_ostream>(OutFile), true, true, MIP,
79  std::unique_ptr<MCCodeEmitter>(MCE), std::unique_ptr<MCAsmBackend>(MAB),
80  true);
81  break;
82  }
84  MS = TheTarget->createMCObjectStreamer(
85  TheTriple, *MC, std::unique_ptr<MCAsmBackend>(MAB),
86  MAB->createObjectWriter(OutFile), std::unique_ptr<MCCodeEmitter>(MCE),
87  *MSTI, MCOptions.MCRelaxAll, MCOptions.MCIncrementalLinkerCompatible,
88  /*DWARFMustBeAtTheEnd*/ false);
89  break;
90  }
91  }
92 
93  if (!MS)
94  return error("no object streamer for target " + TripleName, Context), false;
95 
96  // Finally create the AsmPrinter we'll use to emit the DIEs.
97  TM.reset(TheTarget->createTargetMachine(TripleName, "", "", TargetOptions(),
98  None));
99  if (!TM)
100  return error("no target machine for target " + TripleName, Context), false;
101 
102  Asm.reset(TheTarget->createAsmPrinter(*TM, std::unique_ptr<MCStreamer>(MS)));
103  if (!Asm)
104  return error("no asm printer for target " + TripleName, Context), false;
105 
106  RangesSectionSize = 0;
107  LocSectionSize = 0;
108  LineSectionSize = 0;
109  FrameSectionSize = 0;
110  DebugInfoSectionSize = 0;
111 
112  return true;
113 }
114 
115 void DwarfStreamer::finish() { MS->Finish(); }
116 
117 void DwarfStreamer::switchToDebugInfoSection(unsigned DwarfVersion) {
118  MS->SwitchSection(MOFI->getDwarfInfoSection());
119  MC->setDwarfVersion(DwarfVersion);
120 }
121 
122 /// Emit the compilation unit header for \p Unit in the debug_info section.
123 ///
124 /// A Dwarf 4 section header is encoded as:
125 /// uint32_t Unit length (omitting this field)
126 /// uint16_t Version
127 /// uint32_t Abbreviation table offset
128 /// uint8_t Address size
129 /// Leading to a total of 11 bytes.
130 ///
131 /// A Dwarf 5 section header is encoded as:
132 /// uint32_t Unit length (omitting this field)
133 /// uint16_t Version
134 /// uint8_t Unit type
135 /// uint8_t Address size
136 /// uint32_t Abbreviation table offset
137 /// Leading to a total of 12 bytes.
139  unsigned DwarfVersion) {
140  switchToDebugInfoSection(DwarfVersion);
141 
142  /// The start of the unit within its section.
143  Unit.setLabelBegin(Asm->createTempSymbol("cu_begin"));
144  Asm->OutStreamer->emitLabel(Unit.getLabelBegin());
145 
146  // Emit size of content not including length itself. The size has already
147  // been computed in CompileUnit::computeOffsets(). Subtract 4 to that size to
148  // account for the length field.
149  Asm->emitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset() - 4);
150  Asm->emitInt16(DwarfVersion);
151 
152  if (DwarfVersion >= 5) {
153  Asm->emitInt8(dwarf::DW_UT_compile);
154  Asm->emitInt8(Unit.getOrigUnit().getAddressByteSize());
155  // We share one abbreviations table across all units so it's always at the
156  // start of the section.
157  Asm->emitInt32(0);
158  DebugInfoSectionSize += 12;
159  } else {
160  // We share one abbreviations table across all units so it's always at the
161  // start of the section.
162  Asm->emitInt32(0);
163  Asm->emitInt8(Unit.getOrigUnit().getAddressByteSize());
164  DebugInfoSectionSize += 11;
165  }
166 
167  // Remember this CU.
168  EmittedUnits.push_back({Unit.getUniqueID(), Unit.getLabelBegin()});
169 }
170 
171 /// Emit the \p Abbrevs array as the shared abbreviation table
172 /// for the linked Dwarf file.
174  const std::vector<std::unique_ptr<DIEAbbrev>> &Abbrevs,
175  unsigned DwarfVersion) {
176  MS->SwitchSection(MOFI->getDwarfAbbrevSection());
177  MC->setDwarfVersion(DwarfVersion);
178  Asm->emitDwarfAbbrevs(Abbrevs);
179 }
180 
181 /// Recursively emit the DIE tree rooted at \p Die.
183  MS->SwitchSection(MOFI->getDwarfInfoSection());
184  Asm->emitDwarfDIE(Die);
185  DebugInfoSectionSize += Die.getSize();
186 }
187 
188 /// Emit contents of section SecName From Obj.
190  MCSection *Section =
192  .Case("debug_line", MC->getObjectFileInfo()->getDwarfLineSection())
193  .Case("debug_loc", MC->getObjectFileInfo()->getDwarfLocSection())
194  .Case("debug_ranges",
195  MC->getObjectFileInfo()->getDwarfRangesSection())
196  .Case("debug_frame", MC->getObjectFileInfo()->getDwarfFrameSection())
197  .Case("debug_aranges",
198  MC->getObjectFileInfo()->getDwarfARangesSection())
199  .Default(nullptr);
200 
201  if (Section) {
202  MS->SwitchSection(Section);
203 
204  MS->emitBytes(SecData);
205  }
206 }
207 
208 /// Emit DIE containing warnings.
210  switchToDebugInfoSection(/* Version */ 2);
211  auto &Asm = getAsmPrinter();
212  Asm.emitInt32(11 + Die.getSize() - 4);
213  Asm.emitInt16(2);
214  Asm.emitInt32(0);
215  Asm.emitInt8(MOFI->getTargetTriple().isArch64Bit() ? 8 : 4);
216  DebugInfoSectionSize += 11;
217  emitDIE(Die);
218 }
219 
220 /// Emit the debug_str section stored in \p Pool.
222  Asm->OutStreamer->SwitchSection(MOFI->getDwarfStrSection());
223  std::vector<DwarfStringPoolEntryRef> Entries = Pool.getEntriesForEmission();
224  for (auto Entry : Entries) {
225  // Emit the string itself.
226  Asm->OutStreamer->emitBytes(Entry.getString());
227  // Emit a null terminator.
228  Asm->emitInt8(0);
229  }
230 
231 #if 0
232  if (DwarfVersion >= 5) {
233  // Emit an empty string offset section.
234  Asm->OutStreamer->SwitchSection(MOFI->getDwarfStrOffSection());
235  Asm->emitDwarfUnitLength(4, "Length of String Offsets Set");
236  Asm->emitInt16(DwarfVersion);
237  Asm->emitInt16(0);
238  }
239 #endif
240 }
241 
244  if (EmittedUnits.empty())
245  return;
246 
247  // Build up data structures needed to emit this section.
248  std::vector<MCSymbol *> CompUnits;
249  DenseMap<unsigned, size_t> UniqueIdToCuMap;
250  unsigned Id = 0;
251  for (auto &CU : EmittedUnits) {
252  CompUnits.push_back(CU.LabelBegin);
253  // We might be omitting CUs, so we need to remap them.
254  UniqueIdToCuMap[CU.ID] = Id++;
255  }
256 
257  Asm->OutStreamer->SwitchSection(MOFI->getDwarfDebugNamesSection());
259  Asm.get(), Table, CompUnits,
260  [&UniqueIdToCuMap](const DWARF5AccelTableStaticData &Entry) {
261  return UniqueIdToCuMap[Entry.getCUIndex()];
262  });
263 }
264 
267  Asm->OutStreamer->SwitchSection(MOFI->getDwarfAccelNamespaceSection());
268  auto *SectionBegin = Asm->createTempSymbol("namespac_begin");
269  Asm->OutStreamer->emitLabel(SectionBegin);
270  emitAppleAccelTable(Asm.get(), Table, "namespac", SectionBegin);
271 }
272 
275  Asm->OutStreamer->SwitchSection(MOFI->getDwarfAccelNamesSection());
276  auto *SectionBegin = Asm->createTempSymbol("names_begin");
277  Asm->OutStreamer->emitLabel(SectionBegin);
278  emitAppleAccelTable(Asm.get(), Table, "names", SectionBegin);
279 }
280 
283  Asm->OutStreamer->SwitchSection(MOFI->getDwarfAccelObjCSection());
284  auto *SectionBegin = Asm->createTempSymbol("objc_begin");
285  Asm->OutStreamer->emitLabel(SectionBegin);
286  emitAppleAccelTable(Asm.get(), Table, "objc", SectionBegin);
287 }
288 
291  Asm->OutStreamer->SwitchSection(MOFI->getDwarfAccelTypesSection());
292  auto *SectionBegin = Asm->createTempSymbol("types_begin");
293  Asm->OutStreamer->emitLabel(SectionBegin);
294  emitAppleAccelTable(Asm.get(), Table, "types", SectionBegin);
295 }
296 
297 /// Emit the swift_ast section stored in \p Buffers.
299  MCSection *SwiftASTSection = MOFI->getDwarfSwiftASTSection();
300  SwiftASTSection->setAlignment(Align(32));
301  MS->SwitchSection(SwiftASTSection);
302  MS->emitBytes(Buffer);
303 }
304 
305 /// Emit the debug_range section contents for \p FuncRange by
306 /// translating the original \p Entries. The debug_range section
307 /// format is totally trivial, consisting just of pairs of address
308 /// sized addresses describing the ranges.
310  int64_t UnitPcOffset, uint64_t OrigLowPc,
311  const FunctionIntervals::const_iterator &FuncRange,
312  const std::vector<DWARFDebugRangeList::RangeListEntry> &Entries,
313  unsigned AddressSize) {
314  MS->SwitchSection(MC->getObjectFileInfo()->getDwarfRangesSection());
315 
316  // Offset each range by the right amount.
317  int64_t PcOffset = Entries.empty() ? 0 : FuncRange.value() + UnitPcOffset;
318  for (const auto &Range : Entries) {
319  if (Range.isBaseAddressSelectionEntry(AddressSize)) {
320  warn("unsupported base address selection operation",
321  "emitting debug_ranges");
322  break;
323  }
324  // Do not emit empty ranges.
325  if (Range.StartAddress == Range.EndAddress)
326  continue;
327 
328  // All range entries should lie in the function range.
329  if (!(Range.StartAddress + OrigLowPc >= FuncRange.start() &&
330  Range.EndAddress + OrigLowPc <= FuncRange.stop()))
331  warn("inconsistent range data.", "emitting debug_ranges");
332  MS->emitIntValue(Range.StartAddress + PcOffset, AddressSize);
333  MS->emitIntValue(Range.EndAddress + PcOffset, AddressSize);
334  RangesSectionSize += 2 * AddressSize;
335  }
336 
337  // Add the terminator entry.
338  MS->emitIntValue(0, AddressSize);
339  MS->emitIntValue(0, AddressSize);
340  RangesSectionSize += 2 * AddressSize;
341 }
342 
343 /// Emit the debug_aranges contribution of a unit and
344 /// if \p DoDebugRanges is true the debug_range contents for a
345 /// compile_unit level DW_AT_ranges attribute (Which are basically the
346 /// same thing with a different base address).
347 /// Just aggregate all the ranges gathered inside that unit.
349  bool DoDebugRanges) {
350  unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
351  // Gather the ranges in a vector, so that we can simplify them. The
352  // IntervalMap will have coalesced the non-linked ranges, but here
353  // we want to coalesce the linked addresses.
354  std::vector<std::pair<uint64_t, uint64_t>> Ranges;
355  const auto &FunctionRanges = Unit.getFunctionRanges();
356  for (auto Range = FunctionRanges.begin(), End = FunctionRanges.end();
357  Range != End; ++Range)
358  Ranges.push_back(std::make_pair(Range.start() + Range.value(),
359  Range.stop() + Range.value()));
360 
361  // The object addresses where sorted, but again, the linked
362  // addresses might end up in a different order.
363  llvm::sort(Ranges);
364 
365  if (!Ranges.empty()) {
366  MS->SwitchSection(MC->getObjectFileInfo()->getDwarfARangesSection());
367 
368  MCSymbol *BeginLabel = Asm->createTempSymbol("Barange");
369  MCSymbol *EndLabel = Asm->createTempSymbol("Earange");
370 
371  unsigned HeaderSize =
372  sizeof(int32_t) + // Size of contents (w/o this field
373  sizeof(int16_t) + // DWARF ARange version number
374  sizeof(int32_t) + // Offset of CU in the .debug_info section
375  sizeof(int8_t) + // Pointer Size (in bytes)
376  sizeof(int8_t); // Segment Size (in bytes)
377 
378  unsigned TupleSize = AddressSize * 2;
379  unsigned Padding = offsetToAlignment(HeaderSize, Align(TupleSize));
380 
381  Asm->emitLabelDifference(EndLabel, BeginLabel, 4); // Arange length
382  Asm->OutStreamer->emitLabel(BeginLabel);
383  Asm->emitInt16(dwarf::DW_ARANGES_VERSION); // Version number
384  Asm->emitInt32(Unit.getStartOffset()); // Corresponding unit's offset
385  Asm->emitInt8(AddressSize); // Address size
386  Asm->emitInt8(0); // Segment size
387 
388  Asm->OutStreamer->emitFill(Padding, 0x0);
389 
390  for (auto Range = Ranges.begin(), End = Ranges.end(); Range != End;
391  ++Range) {
392  uint64_t RangeStart = Range->first;
393  MS->emitIntValue(RangeStart, AddressSize);
394  while ((Range + 1) != End && Range->second == (Range + 1)->first)
395  ++Range;
396  MS->emitIntValue(Range->second - RangeStart, AddressSize);
397  }
398 
399  // Emit terminator
400  Asm->OutStreamer->emitIntValue(0, AddressSize);
401  Asm->OutStreamer->emitIntValue(0, AddressSize);
402  Asm->OutStreamer->emitLabel(EndLabel);
403  }
404 
405  if (!DoDebugRanges)
406  return;
407 
408  MS->SwitchSection(MC->getObjectFileInfo()->getDwarfRangesSection());
409  // Offset each range by the right amount.
410  int64_t PcOffset = -Unit.getLowPc();
411  // Emit coalesced ranges.
412  for (auto Range = Ranges.begin(), End = Ranges.end(); Range != End; ++Range) {
413  MS->emitIntValue(Range->first + PcOffset, AddressSize);
414  while (Range + 1 != End && Range->second == (Range + 1)->first)
415  ++Range;
416  MS->emitIntValue(Range->second + PcOffset, AddressSize);
417  RangesSectionSize += 2 * AddressSize;
418  }
419 
420  // Add the terminator entry.
421  MS->emitIntValue(0, AddressSize);
422  MS->emitIntValue(0, AddressSize);
423  RangesSectionSize += 2 * AddressSize;
424 }
425 
426 /// Emit location lists for \p Unit and update attributes to point to the new
427 /// entries.
429  const CompileUnit &Unit, DWARFContext &Dwarf,
430  std::function<void(StringRef, SmallVectorImpl<uint8_t> &)> ProcessExpr) {
431  const auto &Attributes = Unit.getLocationAttributes();
432 
433  if (Attributes.empty())
434  return;
435 
436  MS->SwitchSection(MC->getObjectFileInfo()->getDwarfLocSection());
437 
438  unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
439  uint64_t BaseAddressMarker = (AddressSize == 8)
442  const DWARFSection &InputSec = Dwarf.getDWARFObj().getLocSection();
443  DataExtractor Data(InputSec.Data, Dwarf.isLittleEndian(), AddressSize);
444  DWARFUnit &OrigUnit = Unit.getOrigUnit();
445  auto OrigUnitDie = OrigUnit.getUnitDIE(false);
446  int64_t UnitPcOffset = 0;
447  if (auto OrigLowPc = dwarf::toAddress(OrigUnitDie.find(dwarf::DW_AT_low_pc)))
448  UnitPcOffset = int64_t(*OrigLowPc) - Unit.getLowPc();
449 
451  for (const auto &Attr : Attributes) {
452  uint64_t Offset = Attr.first.get();
453  Attr.first.set(LocSectionSize);
454  // This is the quantity to add to the old location address to get
455  // the correct address for the new one.
456  int64_t LocPcOffset = Attr.second + UnitPcOffset;
457  while (Data.isValidOffset(Offset)) {
458  uint64_t Low = Data.getUnsigned(&Offset, AddressSize);
459  uint64_t High = Data.getUnsigned(&Offset, AddressSize);
460  LocSectionSize += 2 * AddressSize;
461  // End of list entry.
462  if (Low == 0 && High == 0) {
463  Asm->OutStreamer->emitIntValue(0, AddressSize);
464  Asm->OutStreamer->emitIntValue(0, AddressSize);
465  break;
466  }
467  // Base address selection entry.
468  if (Low == BaseAddressMarker) {
469  Asm->OutStreamer->emitIntValue(BaseAddressMarker, AddressSize);
470  Asm->OutStreamer->emitIntValue(High + Attr.second, AddressSize);
471  LocPcOffset = 0;
472  continue;
473  }
474  // Location list entry.
475  Asm->OutStreamer->emitIntValue(Low + LocPcOffset, AddressSize);
476  Asm->OutStreamer->emitIntValue(High + LocPcOffset, AddressSize);
477  uint64_t Length = Data.getU16(&Offset);
478  Asm->OutStreamer->emitIntValue(Length, 2);
479  // Copy the bytes into to the buffer, process them, emit them.
480  Buffer.reserve(Length);
481  Buffer.resize(0);
482  StringRef Input = InputSec.Data.substr(Offset, Length);
483  ProcessExpr(Input, Buffer);
484  Asm->OutStreamer->emitBytes(
485  StringRef((const char *)Buffer.data(), Length));
486  Offset += Length;
487  LocSectionSize += Length + 2;
488  }
489  }
490 }
491 
493  StringRef PrologueBytes,
494  unsigned MinInstLength,
495  std::vector<DWARFDebugLine::Row> &Rows,
496  unsigned PointerSize) {
497  // Switch to the section where the table will be emitted into.
498  MS->SwitchSection(MC->getObjectFileInfo()->getDwarfLineSection());
499  MCSymbol *LineStartSym = MC->createTempSymbol();
500  MCSymbol *LineEndSym = MC->createTempSymbol();
501 
502  // The first 4 bytes is the total length of the information for this
503  // compilation unit (not including these 4 bytes for the length).
504  Asm->emitLabelDifference(LineEndSym, LineStartSym, 4);
505  Asm->OutStreamer->emitLabel(LineStartSym);
506  // Copy Prologue.
507  MS->emitBytes(PrologueBytes);
508  LineSectionSize += PrologueBytes.size() + 4;
509 
510  SmallString<128> EncodingBuffer;
511  raw_svector_ostream EncodingOS(EncodingBuffer);
512 
513  if (Rows.empty()) {
514  // We only have the dummy entry, dsymutil emits an entry with a 0
515  // address in that case.
517  EncodingOS);
518  MS->emitBytes(EncodingOS.str());
519  LineSectionSize += EncodingBuffer.size();
520  MS->emitLabel(LineEndSym);
521  return;
522  }
523 
524  // Line table state machine fields
525  unsigned FileNum = 1;
526  unsigned LastLine = 1;
527  unsigned Column = 0;
528  unsigned IsStatement = 1;
529  unsigned Isa = 0;
530  uint64_t Address = -1ULL;
531 
532  unsigned RowsSinceLastSequence = 0;
533 
534  for (unsigned Idx = 0; Idx < Rows.size(); ++Idx) {
535  auto &Row = Rows[Idx];
536 
537  int64_t AddressDelta;
538  if (Address == -1ULL) {
539  MS->emitIntValue(dwarf::DW_LNS_extended_op, 1);
540  MS->emitULEB128IntValue(PointerSize + 1);
541  MS->emitIntValue(dwarf::DW_LNE_set_address, 1);
542  MS->emitIntValue(Row.Address.Address, PointerSize);
543  LineSectionSize += 2 + PointerSize + getULEB128Size(PointerSize + 1);
544  AddressDelta = 0;
545  } else {
546  AddressDelta = (Row.Address.Address - Address) / MinInstLength;
547  }
548 
549  // FIXME: code copied and transformed from MCDwarf.cpp::EmitDwarfLineTable.
550  // We should find a way to share this code, but the current compatibility
551  // requirement with classic dsymutil makes it hard. Revisit that once this
552  // requirement is dropped.
553 
554  if (FileNum != Row.File) {
555  FileNum = Row.File;
556  MS->emitIntValue(dwarf::DW_LNS_set_file, 1);
557  MS->emitULEB128IntValue(FileNum);
558  LineSectionSize += 1 + getULEB128Size(FileNum);
559  }
560  if (Column != Row.Column) {
561  Column = Row.Column;
562  MS->emitIntValue(dwarf::DW_LNS_set_column, 1);
563  MS->emitULEB128IntValue(Column);
564  LineSectionSize += 1 + getULEB128Size(Column);
565  }
566 
567  // FIXME: We should handle the discriminator here, but dsymutil doesn't
568  // consider it, thus ignore it for now.
569 
570  if (Isa != Row.Isa) {
571  Isa = Row.Isa;
572  MS->emitIntValue(dwarf::DW_LNS_set_isa, 1);
573  MS->emitULEB128IntValue(Isa);
574  LineSectionSize += 1 + getULEB128Size(Isa);
575  }
576  if (IsStatement != Row.IsStmt) {
577  IsStatement = Row.IsStmt;
578  MS->emitIntValue(dwarf::DW_LNS_negate_stmt, 1);
579  LineSectionSize += 1;
580  }
581  if (Row.BasicBlock) {
582  MS->emitIntValue(dwarf::DW_LNS_set_basic_block, 1);
583  LineSectionSize += 1;
584  }
585 
586  if (Row.PrologueEnd) {
587  MS->emitIntValue(dwarf::DW_LNS_set_prologue_end, 1);
588  LineSectionSize += 1;
589  }
590 
591  if (Row.EpilogueBegin) {
592  MS->emitIntValue(dwarf::DW_LNS_set_epilogue_begin, 1);
593  LineSectionSize += 1;
594  }
595 
596  int64_t LineDelta = int64_t(Row.Line) - LastLine;
597  if (!Row.EndSequence) {
598  MCDwarfLineAddr::Encode(*MC, Params, LineDelta, AddressDelta, EncodingOS);
599  MS->emitBytes(EncodingOS.str());
600  LineSectionSize += EncodingBuffer.size();
601  EncodingBuffer.resize(0);
602  Address = Row.Address.Address;
603  LastLine = Row.Line;
604  RowsSinceLastSequence++;
605  } else {
606  if (LineDelta) {
607  MS->emitIntValue(dwarf::DW_LNS_advance_line, 1);
608  MS->emitSLEB128IntValue(LineDelta);
609  LineSectionSize += 1 + getSLEB128Size(LineDelta);
610  }
611  if (AddressDelta) {
612  MS->emitIntValue(dwarf::DW_LNS_advance_pc, 1);
614  LineSectionSize += 1 + getULEB128Size(AddressDelta);
615  }
617  0, EncodingOS);
618  MS->emitBytes(EncodingOS.str());
619  LineSectionSize += EncodingBuffer.size();
620  EncodingBuffer.resize(0);
621  Address = -1ULL;
622  LastLine = FileNum = IsStatement = 1;
623  RowsSinceLastSequence = Column = Isa = 0;
624  }
625  }
626 
627  if (RowsSinceLastSequence) {
629  EncodingOS);
630  MS->emitBytes(EncodingOS.str());
631  LineSectionSize += EncodingBuffer.size();
632  EncodingBuffer.resize(0);
633  }
634 
635  MS->emitLabel(LineEndSym);
636 }
637 
638 /// Copy the debug_line over to the updated binary while unobfuscating the file
639 /// names and directories.
641  MS->SwitchSection(MC->getObjectFileInfo()->getDwarfLineSection());
642  StringRef Contents = Data.getData();
643 
644  // We have to deconstruct the line table header, because it contains to
645  // length fields that will need to be updated when we change the length of
646  // the files and directories in there.
647  unsigned UnitLength = Data.getU32(&Offset);
648  uint64_t UnitEnd = Offset + UnitLength;
649  MCSymbol *BeginLabel = MC->createTempSymbol();
650  MCSymbol *EndLabel = MC->createTempSymbol();
651  unsigned Version = Data.getU16(&Offset);
652 
653  if (Version > 5) {
654  warn("Unsupported line table version: dropping contents and not "
655  "unobfsucating line table.");
656  return;
657  }
658 
659  Asm->emitLabelDifference(EndLabel, BeginLabel, 4);
660  Asm->OutStreamer->emitLabel(BeginLabel);
661  Asm->emitInt16(Version);
662  LineSectionSize += 6;
663 
664  MCSymbol *HeaderBeginLabel = MC->createTempSymbol();
665  MCSymbol *HeaderEndLabel = MC->createTempSymbol();
666  Asm->emitLabelDifference(HeaderEndLabel, HeaderBeginLabel, 4);
667  Asm->OutStreamer->emitLabel(HeaderBeginLabel);
668  Offset += 4;
669  LineSectionSize += 4;
670 
671  uint64_t AfterHeaderLengthOffset = Offset;
672  // Skip to the directories.
673  Offset += (Version >= 4) ? 5 : 4;
674  unsigned OpcodeBase = Data.getU8(&Offset);
675  Offset += OpcodeBase - 1;
676  Asm->OutStreamer->emitBytes(Contents.slice(AfterHeaderLengthOffset, Offset));
677  LineSectionSize += Offset - AfterHeaderLengthOffset;
678 
679  // Offset points to the first directory.
680  while (const char *Dir = Data.getCStr(&Offset)) {
681  if (Dir[0] == 0)
682  break;
683 
684  StringRef Translated = Translator(Dir);
685  Asm->OutStreamer->emitBytes(Translated);
686  Asm->emitInt8(0);
687  LineSectionSize += Translated.size() + 1;
688  }
689  Asm->emitInt8(0);
690  LineSectionSize += 1;
691 
692  while (const char *File = Data.getCStr(&Offset)) {
693  if (File[0] == 0)
694  break;
695 
696  StringRef Translated = Translator(File);
697  Asm->OutStreamer->emitBytes(Translated);
698  Asm->emitInt8(0);
699  LineSectionSize += Translated.size() + 1;
700 
701  uint64_t OffsetBeforeLEBs = Offset;
702  Asm->emitULEB128(Data.getULEB128(&Offset));
703  Asm->emitULEB128(Data.getULEB128(&Offset));
704  Asm->emitULEB128(Data.getULEB128(&Offset));
705  LineSectionSize += Offset - OffsetBeforeLEBs;
706  }
707  Asm->emitInt8(0);
708  LineSectionSize += 1;
709 
710  Asm->OutStreamer->emitLabel(HeaderEndLabel);
711 
712  // Copy the actual line table program over.
713  Asm->OutStreamer->emitBytes(Contents.slice(Offset, UnitEnd));
714  LineSectionSize += UnitEnd - Offset;
715 
716  Asm->OutStreamer->emitLabel(EndLabel);
717  Offset = UnitEnd;
718 }
719 
720 /// Emit the pubnames or pubtypes section contribution for \p
721 /// Unit into \p Sec. The data is provided in \p Names.
722 void DwarfStreamer::emitPubSectionForUnit(
723  MCSection *Sec, StringRef SecName, const CompileUnit &Unit,
724  const std::vector<CompileUnit::AccelInfo> &Names) {
725  if (Names.empty())
726  return;
727 
728  // Start the dwarf pubnames section.
729  Asm->OutStreamer->SwitchSection(Sec);
730  MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + SecName + "_begin");
731  MCSymbol *EndLabel = Asm->createTempSymbol("pub" + SecName + "_end");
732 
733  bool HeaderEmitted = false;
734  // Emit the pubnames for this compilation unit.
735  for (const auto &Name : Names) {
736  if (Name.SkipPubSection)
737  continue;
738 
739  if (!HeaderEmitted) {
740  // Emit the header.
741  Asm->emitLabelDifference(EndLabel, BeginLabel, 4); // Length
742  Asm->OutStreamer->emitLabel(BeginLabel);
743  Asm->emitInt16(dwarf::DW_PUBNAMES_VERSION); // Version
744  Asm->emitInt32(Unit.getStartOffset()); // Unit offset
745  Asm->emitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset()); // Size
746  HeaderEmitted = true;
747  }
748  Asm->emitInt32(Name.Die->getOffset());
749 
750  // Emit the string itself.
751  Asm->OutStreamer->emitBytes(Name.Name.getString());
752  // Emit a null terminator.
753  Asm->emitInt8(0);
754  }
755 
756  if (!HeaderEmitted)
757  return;
758  Asm->emitInt32(0); // End marker.
759  Asm->OutStreamer->emitLabel(EndLabel);
760 }
761 
762 /// Emit .debug_pubnames for \p Unit.
764  emitPubSectionForUnit(MC->getObjectFileInfo()->getDwarfPubNamesSection(),
765  "names", Unit, Unit.getPubnames());
766 }
767 
768 /// Emit .debug_pubtypes for \p Unit.
770  emitPubSectionForUnit(MC->getObjectFileInfo()->getDwarfPubTypesSection(),
771  "types", Unit, Unit.getPubtypes());
772 }
773 
774 /// Emit a CIE into the debug_frame section.
776  MS->SwitchSection(MC->getObjectFileInfo()->getDwarfFrameSection());
777 
778  MS->emitBytes(CIEBytes);
779  FrameSectionSize += CIEBytes.size();
780 }
781 
782 /// Emit a FDE into the debug_frame section. \p FDEBytes
783 /// contains the FDE data without the length, CIE offset and address
784 /// which will be replaced with the parameter values.
785 void DwarfStreamer::emitFDE(uint32_t CIEOffset, uint32_t AddrSize,
786  uint32_t Address, StringRef FDEBytes) {
787  MS->SwitchSection(MC->getObjectFileInfo()->getDwarfFrameSection());
788 
789  MS->emitIntValue(FDEBytes.size() + 4 + AddrSize, 4);
790  MS->emitIntValue(CIEOffset, 4);
791  MS->emitIntValue(Address, AddrSize);
792  MS->emitBytes(FDEBytes);
793  FrameSectionSize += FDEBytes.size() + 8 + AddrSize;
794 }
795 
796 } // namespace llvm
llvm::StringSwitch::Case
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:67
llvm::Target::createMCObjectStreamer
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, bool RelaxAll, bool IncrementalLinkerCompatible, bool DWARFMustBeAtTheEnd) const
Create a target specific MCStreamer.
Definition: TargetRegistry.h:470
llvm::DWARFSection
Definition: DWARFSection.h:16
llvm::DwarfStreamer::emitAppleTypes
void emitAppleTypes(AccelTable< AppleAccelTableStaticTypeData > &Table) override
Emit Apple type accelerator table.
Definition: DWARFStreamer.cpp:289
llvm::CompileUnit::getOrigUnit
DWARFUnit & getOrigUnit() const
Definition: DWARFLinkerCompileUnit.h:100
MCDwarf.h
llvm
Definition: AllocatorList.h:23
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
MCTargetOptions.h
llvm::IntervalMap::const_iterator::stop
const KeyT & stop() const
stop - Return the end of the current interval.
Definition: IntervalMap.h:1373
llvm::TargetOptions
Definition: TargetOptions.h:123
llvm::AccelTableKind::Dwarf
@ Dwarf
DWARF v5 .debug_names.
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:71
llvm::StringSwitch::Default
LLVM_NODISCARD R Default(T Value)
Definition: StringSwitch.h:181
MCCodeEmitter.h
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:124
High
uint64_t High
Definition: NVVMIntrRange.cpp:61
llvm::SmallVector< uint8_t, 32 >
llvm::Target::createMCAsmInfo
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple, const MCTargetOptions &Options) const
createMCAsmInfo - Create a MCAsmInfo implementation for the specified target triple.
Definition: TargetRegistry.h:339
llvm::DwarfStreamer::emitPaperTrailWarningsDie
void emitPaperTrailWarningsDie(DIE &Die) override
Emit DIE containing warnings.
Definition: DWARFStreamer.cpp:209
llvm::MCStreamer::Finish
void Finish(SMLoc EndLoc=SMLoc())
Finish emission of machine code.
Definition: MCStreamer.cpp:979
DWARFContext.h
MCTargetOptionsCommandFlags.h
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::DwarfStreamer::emitRangesEntries
void emitRangesEntries(int64_t UnitPcOffset, uint64_t OrigLowPc, const FunctionIntervals::const_iterator &FuncRange, const std::vector< DWARFDebugRangeList::RangeListEntry > &Entries, unsigned AddressSize) override
Emit debug_ranges for FuncRange by translating the original Entries.
Definition: DWARFStreamer.cpp:309
llvm::getULEB128Size
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
Definition: LEB128.cpp:19
llvm::DWARFContext
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Definition: DWARFContext.h:53
llvm::CompileUnit::getPubtypes
const std::vector< AccelInfo > & getPubtypes() const
Definition: DWARFLinkerCompileUnit.h:236
llvm::mc::InitMCTargetOptionsFromFlags
MCTargetOptions InitMCTargetOptionsFromFlags()
Definition: MCTargetOptionsCommandFlags.cpp:102
llvm::CompileUnit::getLabelBegin
MCSymbol * getLabelBegin()
Definition: DWARFLinkerCompileUnit.h:240
llvm::Target::createMCCodeEmitter
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, const MCRegisterInfo &MRI, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
Definition: TargetRegistry.h:454
llvm::DwarfStreamer::emitPubNamesForUnit
void emitPubNamesForUnit(const CompileUnit &Unit) override
Emit the .debug_pubnames contribution for Unit.
Definition: DWARFStreamer.cpp:763
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::Target::createAsmStreamer
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool IsVerboseAsm, bool UseDwarfDirectory, MCInstPrinter *InstPrint, std::unique_ptr< MCCodeEmitter > &&CE, std::unique_ptr< MCAsmBackend > &&TAB, bool ShowInst) const
Definition: TargetRegistry.h:525
llvm::IntervalMap::const_iterator
Definition: IntervalMap.h:1297
llvm::DIE
A structured debug information entry.
Definition: DIE.h:739
llvm::AccelTable
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
Definition: AccelTable.h:197
llvm::StringRef::slice
LLVM_NODISCARD StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
Definition: StringRef.h:713
llvm::CompileUnit::getLocationAttributes
const std::vector< std::pair< PatchLocation, int64_t > > & getLocationAttributes() const
Definition: DWARFLinkerCompileUnit.h:147
llvm::TargetRegistry::lookupTarget
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
Definition: TargetRegistry.cpp:62
llvm::Data
@ Data
Definition: SIMachineScheduler.h:56
DWARFLinkerCompileUnit.h
llvm::dwarf::toAddress
Optional< uint64_t > toAddress(const Optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an address.
Definition: DWARFFormValue.h:266
llvm::Target::createMCInstrInfo
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
Definition: TargetRegistry.h:348
llvm::BTF::HeaderSize
@ HeaderSize
Definition: BTF.h:58
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::DWARFUnit::getUnitDIE
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
Definition: DWARFUnit.h:382
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::StringRef::substr
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:612
llvm::Target::createMCRegInfo
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
Definition: TargetRegistry.h:364
llvm::emitAppleAccelTable
void emitAppleAccelTable(AsmPrinter *Asm, AccelTable< DataT > &Contents, StringRef Prefix, const MCSymbol *SecBegin)
Emit an Apple Accelerator Table consisting of entries in the specified AccelTable.
Definition: AccelTable.h:303
llvm::DwarfStreamer::switchToDebugInfoSection
void switchToDebugInfoSection(unsigned DwarfVersion)
Set the current output section to debug_info and change the MC Dwarf version to DwarfVersion.
Definition: DWARFStreamer.cpp:117
llvm::DwarfStreamer::emitPubTypesForUnit
void emitPubTypesForUnit(const CompileUnit &Unit) override
Emit the .debug_pubtypes contribution for Unit.
Definition: DWARFStreamer.cpp:769
MCAsmBackend.h
llvm::IntervalMap::const_iterator::start
const KeyT & start() const
start - Return the beginning of the current interval.
Definition: IntervalMap.h:1370
llvm::DwarfStreamer::emitAppleNamespaces
void emitAppleNamespaces(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple namespaces accelerator table.
Definition: DWARFStreamer.cpp:265
NonRelocatableStringpool.h
llvm::MCDwarfLineTableParams
Definition: MCDwarf.h:206
llvm::DwarfStreamer::translateLineTable
void translateLineTable(DataExtractor LineData, uint64_t Offset) override
Copy the debug_line over to the updated binary while unobfuscating the file names and directories.
Definition: DWARFStreamer.cpp:640
llvm::CompileUnit::getFunctionRanges
const FunctionIntervals & getFunctionRanges() const
Definition: DWARFLinkerCompileUnit.h:140
llvm::DwarfStreamer::emitCIE
void emitCIE(StringRef CIEBytes) override
Emit a CIE.
Definition: DWARFStreamer.cpp:775
llvm::DwarfStreamer::emitSectionContents
void emitSectionContents(StringRef SecData, StringRef SecName) override
Emit contents of section SecName From Obj.
Definition: DWARFStreamer.cpp:189
llvm::MCStreamer::emitLabel
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:414
MCSymbol.h
llvm::DwarfStreamer::emitUnitRangesEntries
void emitUnitRangesEntries(CompileUnit &Unit, bool DoRangesSection) override
Emit debug_aranges entries for Unit and if DoRangesSection is true, also emit the debug_ranges entrie...
Definition: DWARFStreamer.cpp:348
MCSubtargetInfo.h
llvm::NonRelocatableStringpool::getEntriesForEmission
std::vector< DwarfStringPoolEntryRef > getEntriesForEmission() const
Return the list of strings to be emitted.
Definition: NonRelocatableStringpool.cpp:41
llvm::SmallVectorImpl::resize
void resize(size_type N)
Definition: SmallVector.h:606
llvm::CompileUnit::getUniqueID
unsigned getUniqueID() const
Definition: DWARFLinkerCompileUnit.h:102
llvm::DwarfStreamer::emitCompileUnitHeader
void emitCompileUnitHeader(CompileUnit &Unit, unsigned DwarfVersion) override
Emit the compilation unit header for Unit in the debug_info section.
Definition: DWARFStreamer.cpp:138
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:991
llvm::DwarfStreamer::emitLineTableForUnit
void emitLineTableForUnit(MCDwarfLineTableParams Params, StringRef PrologueBytes, unsigned MinInstLength, std::vector< DWARFDebugLine::Row > &Rows, unsigned AdddressSize) override
Emit the line table described in Rows into the debug_line section.
Definition: DWARFStreamer.cpp:492
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::Triple::getTriple
const std::string & getTriple() const
Definition: Triple.h:378
llvm::None
const NoneType None
Definition: None.h:23
llvm::CompileUnit::getPubnames
const std::vector< AccelInfo > & getPubnames() const
Definition: DWARFLinkerCompileUnit.h:235
llvm::DwarfStreamer::emitFDE
void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint32_t Address, StringRef Bytes) override
Emit an FDE with data Bytes.
Definition: DWARFStreamer.cpp:785
llvm::DIE::getSize
unsigned getSize() const
Definition: DIE.h:778
llvm::SmallString< 128 >
llvm::MCDwarfLineAddr::Encode
static void Encode(MCContext &Context, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta, raw_ostream &OS)
Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
Definition: MCDwarf.cpp:655
llvm::OutputFileType::Object
@ Object
DWARFStreamer.h
llvm::MCTargetOptions::MCIncrementalLinkerCompatible
bool MCIncrementalLinkerCompatible
Definition: MCTargetOptions.h:50
llvm::DwarfStreamer::emitDebugNames
void emitDebugNames(AccelTable< DWARF5AccelTableStaticData > &Table) override
Emit DWARF debug names.
Definition: DWARFStreamer.cpp:242
llvm::DwarfStreamer::emitStrings
void emitStrings(const NonRelocatableStringpool &Pool) override
Emit the string table described by Pool.
Definition: DWARFStreamer.cpp:221
llvm::DWARF5AccelTableStaticData
Definition: AccelTable.h:271
llvm::CompileUnit
Stores all information relating to a compile unit, be it in its original instance in the object file ...
Definition: DWARFLinkerCompileUnit.h:50
LEB128.h
llvm::IntervalMap::const_iterator::value
const ValT & value() const
value - Return the mapped value at the current interval.
Definition: IntervalMap.h:1376
llvm::DwarfStreamer::emitAppleObjc
void emitAppleObjc(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple Objective-C accelerator table.
Definition: DWARFStreamer.cpp:281
llvm::DenseMap
Definition: DenseMap.h:714
llvm::HighlightColor::Address
@ Address
llvm::CompileUnit::getStartOffset
uint64_t getStartOffset() const
Definition: DWARFLinkerCompileUnit.h:128
llvm::DwarfStreamer::emitAppleNames
void emitAppleNames(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple names accelerator table.
Definition: DWARFStreamer.cpp:273
llvm::Target::createAsmPrinter
AsmPrinter * createAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) const
createAsmPrinter - Create a target specific assembly printer pass.
Definition: TargetRegistry.h:430
llvm::MCStreamer::emitIntValue
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.
Definition: MCStreamer.cpp:132
llvm::CompileUnit::getLowPc
uint64_t getLowPc() const
Definition: DWARFLinkerCompileUnit.h:132
llvm::dwarf::DW_ARANGES_VERSION
@ DW_ARANGES_VERSION
Section version number for .debug_aranges.
Definition: Dwarf.h:65
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::CompileUnit::getNextUnitOffset
uint64_t getNextUnitOffset() const
Definition: DWARFLinkerCompileUnit.h:129
llvm::MCTargetOptions
Definition: MCTargetOptions.h:36
llvm::DwarfStreamer::emitSwiftAST
void emitSwiftAST(StringRef Buffer)
Emit the swift_ast section stored in Buffer.
Definition: DWARFStreamer.cpp:298
MCSection.h
Triple.h
llvm::CompileUnit::setLabelBegin
void setLabelBegin(MCSymbol *S)
Definition: DWARFLinkerCompileUnit.h:241
TargetOptions.h
llvm::Target::createMCAsmBackend
MCAsmBackend * createMCAsmBackend(const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) const
createMCAsmBackend - Create a target specific assembly parser.
Definition: TargetRegistry.h:407
llvm::DwarfStreamer::getAsmPrinter
AsmPrinter & getAsmPrinter() const
Definition: DWARFStreamer.h:56
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::raw_svector_ostream::str
StringRef str() const
Return a StringRef for the vector contents.
Definition: raw_ostream.h:672
uint32_t
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
llvm::getSLEB128Size
unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.
Definition: LEB128.cpp:29
llvm::DwarfStreamer::emitDIE
void emitDIE(DIE &Die) override
Recursively emit the DIE tree rooted at Die.
Definition: DWARFStreamer.cpp:182
llvm::MCSection::setAlignment
void setAlignment(Align Value)
Definition: MCSection.h:132
MCObjectWriter.h
llvm::Target::createMCSubtargetInfo
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
Definition: TargetRegistry.h:379
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
llvm::Target::createMCInstPrinter
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
Definition: TargetRegistry.h:444
llvm::DWARFUnit::getAddressByteSize
uint8_t getAddressByteSize() const
Definition: DWARFUnit.h:288
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::MCStreamer::emitSLEB128IntValue
void emitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:169
llvm::NonRelocatableStringpool
A string table that doesn't need relocations.
Definition: NonRelocatableStringpool.h:23
llvm::DWARFUnit
Definition: DWARFUnit.h:203
llvm::dwarf::DW_PUBNAMES_VERSION
@ DW_PUBNAMES_VERSION
Section version number for .debug_pubnames.
Definition: Dwarf.h:64
llvm::MCTargetOptions::MCRelaxAll
bool MCRelaxAll
Definition: MCTargetOptions.h:43
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1446
llvm::DwarfStreamer::init
bool init(Triple TheTriple)
Definition: DWARFStreamer.cpp:30
llvm::MCPseudoProbeFlag::AddressDelta
@ AddressDelta
llvm::MCStreamer::emitULEB128IntValue
void emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:160
llvm::DataExtractor
Definition: DataExtractor.h:41
llvm::MCAsmBackend::createObjectWriter
std::unique_ptr< MCObjectWriter > createObjectWriter(raw_pwrite_stream &OS) const
Create a new MCObjectWriter instance for use by the assembler backend to emit the final object file.
Definition: MCAsmBackend.cpp:30
MCStreamer.h
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:350
llvm::raw_svector_ostream
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:647
llvm::DwarfStreamer::emitAbbrevs
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:173
llvm::MCStreamer::emitBytes
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition: MCStreamer.cpp:1172
llvm::SmallVectorImpl< uint8_t >
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:42
llvm::DwarfStreamer::emitLocationsForUnit
void emitLocationsForUnit(const CompileUnit &Unit, DWARFContext &Dwarf, std::function< void(StringRef, SmallVectorImpl< uint8_t > &)> ProcessExpr) override
Emit the debug_loc contribution for Unit by copying the entries from Dwarf and offsetting them.
Definition: DWARFStreamer.cpp:428
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:221
llvm::StringRef::size
LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:160
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition: SmallVector.h:624
TargetRegistry.h
llvm::MCStreamer::SwitchSection
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Definition: MCStreamer.cpp:1194
llvm::DWARFSection::Data
StringRef Data
Definition: DWARFSection.h:17
CU
Definition: AArch64AsmBackend.cpp:515
llvm::OutputFileType::Assembly
@ Assembly
llvm::offsetToAlignment
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...
Definition: Alignment.h:206
File
Instrumentation for Order File
Definition: InstrOrderFile.cpp:206
llvm::MCObjectFileInfo
Definition: MCObjectFileInfo.h:26
llvm::Target::createTargetMachine
TargetMachine * createTargetMachine(StringRef TT, StringRef CPU, StringRef Features, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM=None, CodeGenOpt::Level OL=CodeGenOpt::Default, bool JIT=false) const
createTargetMachine - Create a target specific machine implementation for the specified Triple.
Definition: TargetRegistry.h:393
llvm::emitDWARF5AccelTable
void emitDWARF5AccelTable(AsmPrinter *Asm, AccelTable< DWARF5AccelTableData > &Contents, const DwarfDebug &DD, ArrayRef< std::unique_ptr< DwarfCompileUnit >> CUs)
Definition: AccelTable.cpp:546
llvm::DwarfStreamer::finish
void finish()
Dump the file to the disk.
Definition: DWARFStreamer.cpp:115