LLVM: lib/ObjectYAML/DWARFEmitter.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

31#include

32#include

33#include

34#include

35#include

36#include

37#include

38

39using namespace llvm;

40

41template

46}

47

50 if (8 == Size)

52 else if (4 == Size)

54 else if (2 == Size)

56 else if (1 == Size)

58 else

60 "invalid integer write size: %zu", Size);

61

63}

64

66 std::vector<uint8_t> FillData(Size, 0);

67 OS.write(reinterpret_cast<char *>(FillData.data()), Size);

68}

69

72 bool IsLittleEndian) {

74 if (IsDWARF64)

76 IsLittleEndian));

79}

80

84 OS, IsLittleEndian));

85}

86

89 OS.write(Str.data(), Str.size());

91 }

92

94}

95

98 "Index should be less than the size of DebugAbbrev array");

99 auto It = AbbrevTableContents.find(Index);

100 if (It != AbbrevTableContents.cend())

101 return It->second;

102

103 std::string AbbrevTableBuffer;

105

108 AbbrevCode = AbbrevDecl.Code ? (uint64_t)*AbbrevDecl.Code : AbbrevCode + 1;

111 OS.write(AbbrevDecl.Children);

112 for (const auto &Attr : AbbrevDecl.Attributes) {

115 if (Attr.Form == dwarf::DW_FORM_implicit_const)

117 }

120 }

121

122

123

125

126 AbbrevTableContents.insert({Index, AbbrevTableBuffer});

127

128 return AbbrevTableContents[Index];

129}

130

134 OS.write(AbbrevTableContent.data(), AbbrevTableContent.size());

135 }

136

138}

139

144 if (Range.AddrSize)

145 AddrSize = *Range.AddrSize;

146 else

148

149 uint64_t Length = 4;

150

153

154 const uint64_t HeaderLength =

156 ? 12

157 : 4);

158 const uint64_t PaddedHeaderLength = alignTo(HeaderLength, AddrSize * 2);

159

160 if (Range.Length) {

162 } else {

163 Length += PaddedHeaderLength - HeaderLength;

164 Length += AddrSize * 2 * (Range.Descriptors.size() + 1);

165 }

166

173

174 for (const auto &Descriptor : Range.Descriptors) {

178 "unable to write debug_aranges address: %s",

182 }

184 }

185

187}

188

190 const size_t RangesOffset = OS.tell();

192 for (const auto &DebugRanges : *DI.DebugRanges) {

193 const size_t CurrOffset = OS.tell() - RangesOffset;

194 if (DebugRanges.Offset && (uint64_t)*DebugRanges.Offset < CurrOffset)

196 "'Offset' for 'debug_ranges' with index " +

197 Twine(EntryIndex) +

198 " must be greater than or equal to the "

199 "number of bytes written already (0x" +

201 if (DebugRanges.Offset)

203

205 if (DebugRanges.AddrSize)

206 AddrSize = *DebugRanges.AddrSize;

207 else

209 for (const auto &Entry : DebugRanges.Entries) {

214 "unable to write debug_ranges address offset: %s",

218 }

220 ++EntryIndex;

221 }

222

224}

225

227 bool IsLittleEndian, bool IsGNUPubSec = false) {

232 for (const auto &Entry : Sect.Entries) {

234 if (IsGNUPubSec)

236 OS.write(Entry.Name.data(), Entry.Name.size());

238 }

240}

241

243 assert(DI.PubNames && "unexpected emitDebugPubnames() call");

245}

246

248 assert(DI.PubTypes && "unexpected emitDebugPubtypes() call");

250}

251

253 assert(DI.GNUPubNames && "unexpected emitDebugGNUPubnames() call");

255 true);

256}

257

259 assert(DI.GNUPubTypes && "unexpected emitDebugGNUPubtypes() call");

261 true);

262}

263

271 uint32_t AbbrCode = Entry.AbbrCode;

272 if (AbbrCode == 0 || Entry.Values.empty())

273 return OS.tell() - EntryBegin;

274

277 if (!AbbrevTableInfoOrErr)

280 " for compilation unit with index " +

281 utostr(CUIndex));

282

284 DI.DebugAbbrev[AbbrevTableInfoOrErr->Index].Table);

285

286 if (AbbrCode > AbbrevDecls.size())

289 "abbrev code must be less than or equal to the number of "

290 "entries in abbreviation table");

292 auto FormVal = Entry.Values.begin();

293 auto AbbrForm = Abbrev.Attributes.begin();

294 for (; FormVal != Entry.Values.end() && AbbrForm != Abbrev.Attributes.end();

295 ++FormVal, ++AbbrForm) {

297 bool Indirect;

298 do {

299 Indirect = false;

300 switch (Form) {

301 case dwarf::DW_FORM_addr:

302

304 FormVal->Value, Params.AddrSize, OS, IsLittleEndian))

305 return std::move(Err);

306 break;

307 case dwarf::DW_FORM_ref_addr:

308

311 OS, IsLittleEndian))

312 return std::move(Err);

313 break;

314 case dwarf::DW_FORM_exprloc:

315 case dwarf::DW_FORM_block:

317 OS.write((const char *)FormVal->BlockData.data(),

318 FormVal->BlockData.size());

319 break;

320 case dwarf::DW_FORM_block1: {

322 OS.write((const char *)FormVal->BlockData.data(),

323 FormVal->BlockData.size());

324 break;

325 }

326 case dwarf::DW_FORM_block2: {

328 OS.write((const char *)FormVal->BlockData.data(),

329 FormVal->BlockData.size());

330 break;

331 }

332 case dwarf::DW_FORM_block4: {

334 OS.write((const char *)FormVal->BlockData.data(),

335 FormVal->BlockData.size());

336 break;

337 }

338 case dwarf::DW_FORM_strx:

339 case dwarf::DW_FORM_addrx:

340 case dwarf::DW_FORM_rnglistx:

341 case dwarf::DW_FORM_loclistx:

342 case dwarf::DW_FORM_udata:

343 case dwarf::DW_FORM_ref_udata:

344 case dwarf::DW_FORM_GNU_addr_index:

345 case dwarf::DW_FORM_GNU_str_index:

347 break;

348 case dwarf::DW_FORM_data1:

349 case dwarf::DW_FORM_ref1:

350 case dwarf::DW_FORM_flag:

351 case dwarf::DW_FORM_strx1:

352 case dwarf::DW_FORM_addrx1:

354 break;

355 case dwarf::DW_FORM_data2:

356 case dwarf::DW_FORM_ref2:

357 case dwarf::DW_FORM_strx2:

358 case dwarf::DW_FORM_addrx2:

360 break;

361 case dwarf::DW_FORM_data4:

362 case dwarf::DW_FORM_ref4:

363 case dwarf::DW_FORM_ref_sup4:

364 case dwarf::DW_FORM_strx4:

365 case dwarf::DW_FORM_addrx4:

367 break;

368 case dwarf::DW_FORM_data8:

369 case dwarf::DW_FORM_ref8:

370 case dwarf::DW_FORM_ref_sup8:

371 case dwarf::DW_FORM_ref_sig8:

373 break;

374 case dwarf::DW_FORM_sdata:

376 break;

377 case dwarf::DW_FORM_string:

378 OS.write(FormVal->CStr.data(), FormVal->CStr.size());

380 break;

381 case dwarf::DW_FORM_indirect:

383 Indirect = true;

385 ++FormVal;

386 break;

387 case dwarf::DW_FORM_strp:

388 case dwarf::DW_FORM_sec_offset:

389 case dwarf::DW_FORM_GNU_ref_alt:

390 case dwarf::DW_FORM_GNU_strp_alt:

391 case dwarf::DW_FORM_line_strp:

392 case dwarf::DW_FORM_strp_sup:

395 IsLittleEndian));

396 break;

397 default:

398 break;

399 }

400 } while (Indirect);

401 }

402

403 return OS.tell() - EntryBegin;

404}

405

412 else

415 uint64_t Length = 3;

418 ++Length;

420 case dwarf::DW_UT_compile:

421 case dwarf::DW_UT_partial:

422 default:

423 break;

424 case dwarf::DW_UT_type:

425 case dwarf::DW_UT_split_type:

426

428 break;

429 case dwarf::DW_UT_skeleton:

430 case dwarf::DW_UT_split_compile:

431 Length += 8;

432 }

433 }

434

435

436

437

438

439 std::string EntryBuffer;

441

445 writeDIE(DI, I, AbbrevTableID, Params, Entry, EntryBufferOS,

447 Length += *EntryLength;

448 else

449 return EntryLength.takeError();

450 }

451

452

453

456

459

460 uint64_t AbbrevTableOffset = 0;

463 } else {

466 AbbrevTableOffset = AbbrevTableInfoOrErr->Offset;

467 } else {

468

469

470

471 consumeError(AbbrevTableInfoOrErr.takeError());

472 }

473 }

474

480 case dwarf::DW_UT_compile:

481 case dwarf::DW_UT_partial:

482 default:

483 break;

484 case dwarf::DW_UT_type:

485 case dwarf::DW_UT_split_type:

488 break;

489 case dwarf::DW_UT_skeleton:

490 case dwarf::DW_UT_split_compile:

492 break;

493 }

494 } else {

497 }

498

499 OS.write(EntryBuffer.data(), EntryBuffer.size());

500 }

501

503}

504

506 OS.write(File.Name.data(), File.Name.size());

511}

512

514 uint8_t AddrSize, bool IsLittleEndian,

516

517

518

519

520

521 std::string OpBuffer;

524 switch (Op.SubOpcode) {

525 case dwarf::DW_LNE_set_address:

527 IsLittleEndian));

528 break;

529 case dwarf::DW_LNE_define_file:

531 break;

532 case dwarf::DW_LNE_set_discriminator:

534 break;

535 case dwarf::DW_LNE_end_sequence:

536 break;

537 default:

538 for (auto OpByte : Op.UnknownOpcodeData)

540 }

541 uint64_t ExtLen = Op.ExtLen.value_or(OpBuffer.size());

543 OS.write(OpBuffer.data(), OpBuffer.size());

544}

545

550 if (Op.Opcode == 0) {

552 } else if (Op.Opcode < OpcodeBase) {

553 switch (Op.Opcode) {

554 case dwarf::DW_LNS_copy:

555 case dwarf::DW_LNS_negate_stmt:

556 case dwarf::DW_LNS_set_basic_block:

557 case dwarf::DW_LNS_const_add_pc:

558 case dwarf::DW_LNS_set_prologue_end:

559 case dwarf::DW_LNS_set_epilogue_begin:

560 break;

561

562 case dwarf::DW_LNS_advance_pc:

563 case dwarf::DW_LNS_set_file:

564 case dwarf::DW_LNS_set_column:

565 case dwarf::DW_LNS_set_isa:

567 break;

568

569 case dwarf::DW_LNS_advance_line:

571 break;

572

573 case dwarf::DW_LNS_fixed_advance_pc:

575 break;

576

577 default:

578 for (auto OpData : Op.StandardOpcodeData) {

580 }

581 }

582 }

583}

584

585static std::vector<uint8_t>

587

588

589 std::vector<uint8_t> StandardOpcodeLengths{0, 1, 1, 1, 1, 0,

590 0, 0, 1, 0, 0, 1};

592

593 StandardOpcodeLengths.resize(9);

594 } else if (OpcodeBase) {

595 StandardOpcodeLengths.resize(*OpcodeBase > 0 ? *OpcodeBase - 1 : 0, 0);

596 }

597 return StandardOpcodeLengths;

598}

599

602

603

604 std::string Buffer;

606

608

614

615 std::vector<uint8_t> StandardOpcodeLengths =

620 : StandardOpcodeLengths.size() + 1;

622 for (uint8_t OpcodeLength : StandardOpcodeLengths)

624

626 BufferOS.write(IncludeDir.data(), IncludeDir.size());

627 BufferOS.write('\0');

628 }

629 BufferOS.write('\0');

630

633 BufferOS.write('\0');

634

637

641

645 } else {

646 Length = 2;

649 Length += Buffer.size();

650 }

651

655 OS.write(Buffer.data(), Buffer.size());

656 }

657

659}

660

665 AddrSize = *TableEntry.AddrSize;

666 else

668

670 if (TableEntry.Length)

672 else

673

676

681

688 "unable to write debug_addr segment: %s",

690 if (AddrSize != 0)

694 "unable to write debug_addr address: %s",

696 }

697 }

698

700}

701

708 else

709

712

716

719 }

720

722}

723

724namespace {

725

726void emitDebugNamesHeader(raw_ostream &OS, bool IsLittleEndian,

728 uint32_t CombinedSizeOtherParts) {

729

730 StringRef AugmentationString = "LLVM0700";

731 size_t TotalSize = CombinedSizeOtherParts + 5 * sizeof(uint32_t) +

732 2 * sizeof(uint16_t) + sizeof(NameCount) +

733 sizeof(AbbrevSize) + AugmentationString.size();

735

736

746 OS.write(AugmentationString.data(), AugmentationString.size());

747}

748

749

750std::string

752 std::string Data;

757 for (auto [Idx, Form] : Abbrev.Indices) {

760 }

763 }

765 return Data;

766}

767

768

769

770std::string emitDebugNamesCUOffsets(bool IsLittleEndian) {

771 std::string Data;

774 return Data;

775}

776

777

778

779

780

781std::string emitDebugNamesNameTable(

782 bool IsLittleEndian,

783 const DenseMap<uint32_t, std::vectorDWARFYAML::DebugNameEntry> &Entries,

785 assert(Entries.size() == EntryPoolOffsets.size());

786

787 std::string Data;

789

792 for (uint32_t PoolOffset : EntryPoolOffsets)

794 return Data;

795}

796

797

802 StrpToEntries[Entry.NameStrp].push_back(Entry);

803 return StrpToEntries;

804}

805

806

807

809getNonZeroDataSizesFor(uint32_t AbbrevCode,

811 const auto *AbbrevIt = find_if(Abbrevs, [&](const auto &Abbrev) {

812 return Abbrev.Code.value == AbbrevCode;

813 });

814 if (AbbrevIt == Abbrevs.end())

816 "did not find an Abbreviation for this code");

817

820 for (auto [Idx, Form] : AbbrevIt->Indices) {

822 if (!FormSize)

824 "unsupported Form for YAML debug_names emitter");

825 if (FormSize == 0)

826 continue;

828 }

829 return DataSizes;

830}

831

832struct PoolOffsetsAndData {

833 std::string PoolData;

834 std::vector<uint32_t> PoolOffsets;

835};

836

837

838

839

840

842 bool IsLittleEndian,

843 const DenseMap<uint32_t, std::vectorDWARFYAML::DebugNameEntry>

844 &StrpToEntries,

846 PoolOffsetsAndData Result;

848

851 Result.PoolOffsets.push_back(Result.PoolData.size());

852

855

857 getNonZeroDataSizesFor(Entry.Code, Abbrevs);

858 if (!DataSizes)

860 if (DataSizes->size() != Entry.Values.size())

863 "mismatch between provided and required number of values");

864

868 return std::move(E);

869 }

871 }

872

874}

875}

876

880

883

884

885

888 if (!PoolInfo)

890 std::string NamesTableData = emitDebugNamesNameTable(

891 DI.IsLittleEndian, StrpToEntries, PoolInfo->PoolOffsets);

892

893 std::string AbbrevData = emitDebugNamesAbbrev(DebugNames.Abbrevs);

894 std::string CUOffsetsData = emitDebugNamesCUOffsets(DI.IsLittleEndian);

895

896 size_t TotalSize = PoolInfo->PoolData.size() + NamesTableData.size() +

897 AbbrevData.size() + CUOffsetsData.size();

898

899

901 AbbrevData.size(), TotalSize);

902 OS.write(CUOffsetsData.data(), CUOffsetsData.size());

903

904 OS.write(NamesTableData.data(), NamesTableData.size());

905 OS.write(AbbrevData.data(), AbbrevData.size());

906 OS.write(PoolInfo->PoolData.data(), PoolInfo->PoolData.size());

907

909}

910

914 if (Values.size() != ExpectedOperands)

917 "invalid number (%zu) of operands for the operator: %s, %" PRIu64

918 " expected",

919 Values.size(), EncodingString.str().c_str(), ExpectedOperands);

920

922}

923

926 bool IsLittleEndian) {

929 "unable to write address for the operator %s: %s",

930 EncodingName.str().c_str(),

932

934}

935

939 uint8_t AddrSize, bool IsLittleEndian) {

940 auto CheckOperands = [&](uint64_t ExpectedOperands) -> Error {

942 Operation.Values, ExpectedOperands);

943 };

944

948 case dwarf::DW_OP_consts:

949 if (Error Err = CheckOperands(1))

950 return std::move(Err);

952 break;

953 case dwarf::DW_OP_stack_value:

954 if (Error Err = CheckOperands(0))

955 return std::move(Err);

956 break;

957 default:

960 "DWARF expression: " +

961 (EncodingStr.empty()

962 ? "0x" + utohexstr(Operation.Operator)

963 : EncodingStr) +

964 " is not supported");

965 }

966 return OS.tell() - ExpressionBegin;

967}

968

972 bool IsLittleEndian) {

975

977

978 auto CheckOperands = [&](uint64_t ExpectedOperands) -> Error {

979 return checkOperandCount(EncodingName, Entry.Values, ExpectedOperands);

980 };

981

984 IsLittleEndian);

985 };

986

987 switch (Entry.Operator) {

988 case dwarf::DW_RLE_end_of_list:

989 if (Error Err = CheckOperands(0))

990 return std::move(Err);

991 break;

992 case dwarf::DW_RLE_base_addressx:

993 if (Error Err = CheckOperands(1))

994 return std::move(Err);

996 break;

997 case dwarf::DW_RLE_startx_endx:

998 case dwarf::DW_RLE_startx_length:

999 case dwarf::DW_RLE_offset_pair:

1000 if (Error Err = CheckOperands(2))

1001 return std::move(Err);

1004 break;

1005 case dwarf::DW_RLE_base_address:

1006 if (Error Err = CheckOperands(1))

1007 return std::move(Err);

1008 if (Error Err = WriteAddress(Entry.Values[0]))

1009 return std::move(Err);

1010 break;

1011 case dwarf::DW_RLE_start_end:

1012 if (Error Err = CheckOperands(2))

1013 return std::move(Err);

1014 if (Error Err = WriteAddress(Entry.Values[0]))

1015 return std::move(Err);

1016 cantFail(WriteAddress(Entry.Values[1]));

1017 break;

1018 case dwarf::DW_RLE_start_length:

1019 if (Error Err = CheckOperands(2))

1020 return std::move(Err);

1021 if (Error Err = WriteAddress(Entry.Values[0]))

1022 return std::move(Err);

1024 break;

1025 }

1026

1027 return OS.tell() - BeginOffset;

1028}

1029

1033 bool IsLittleEndian) {

1036

1038

1039 auto CheckOperands = [&](uint64_t ExpectedOperands) -> Error {

1040 return checkOperandCount(EncodingName, Entry.Values, ExpectedOperands);

1041 };

1042

1045 IsLittleEndian);

1046 };

1047

1048 auto WriteDWARFOperations = [&]() -> Error {

1049 std::string OpBuffer;

1051 uint64_t DescriptionsLength = 0;

1052

1056 DescriptionsLength += *OpSize;

1057 else

1058 return OpSize.takeError();

1059 }

1060

1061 if (Entry.DescriptionsLength)

1062 DescriptionsLength = *Entry.DescriptionsLength;

1063 else

1064 DescriptionsLength = OpBuffer.size();

1065

1067 OS.write(OpBuffer.data(), OpBuffer.size());

1068

1070 };

1071

1072 switch (Entry.Operator) {

1073 case dwarf::DW_LLE_end_of_list:

1074 if (Error Err = CheckOperands(0))

1075 return std::move(Err);

1076 break;

1077 case dwarf::DW_LLE_base_addressx:

1078 if (Error Err = CheckOperands(1))

1079 return std::move(Err);

1081 break;

1082 case dwarf::DW_LLE_startx_endx:

1083 case dwarf::DW_LLE_startx_length:

1084 case dwarf::DW_LLE_offset_pair:

1085 if (Error Err = CheckOperands(2))

1086 return std::move(Err);

1089 if (Error Err = WriteDWARFOperations())

1090 return std::move(Err);

1091 break;

1092 case dwarf::DW_LLE_default_location:

1093 if (Error Err = CheckOperands(0))

1094 return std::move(Err);

1095 if (Error Err = WriteDWARFOperations())

1096 return std::move(Err);

1097 break;

1098 case dwarf::DW_LLE_base_address:

1099 if (Error Err = CheckOperands(1))

1100 return std::move(Err);

1101 if (Error Err = WriteAddress(Entry.Values[0]))

1102 return std::move(Err);

1103 break;

1104 case dwarf::DW_LLE_start_end:

1105 if (Error Err = CheckOperands(2))

1106 return std::move(Err);

1107 if (Error Err = WriteAddress(Entry.Values[0]))

1108 return std::move(Err);

1109 cantFail(WriteAddress(Entry.Values[1]));

1110 if (Error Err = WriteDWARFOperations())

1111 return std::move(Err);

1112 break;

1113 case dwarf::DW_LLE_start_length:

1114 if (Error Err = CheckOperands(2))

1115 return std::move(Err);

1116 if (Error Err = WriteAddress(Entry.Values[0]))

1117 return std::move(Err);

1119 if (Error Err = WriteDWARFOperations())

1120 return std::move(Err);

1121 break;

1122 }

1123

1124 return OS.tell() - BeginOffset;

1125}

1126

1127template

1130 bool IsLittleEndian, bool Is64BitAddrSize) {

1132

1133

1135

1137 if (Table.AddrSize)

1138 AddrSize = *Table.AddrSize;

1139 else

1140 AddrSize = Is64BitAddrSize ? 8 : 4;

1141

1142

1143

1144

1145

1146 std::string ListBuffer;

1148

1149

1150

1151

1152 std::vector<uint64_t> Offsets;

1153

1155 Offsets.push_back(ListBufferOS.tell());

1156 if (List.Content) {

1157 List.Content->writeAsBinary(ListBufferOS, UINT64_MAX);

1158 Length += List.Content->binary_size();

1159 } else if (List.Entries) {

1160 for (const EntryType &Entry : *List.Entries) {

1162 writeListEntry(ListBufferOS, Entry, AddrSize, IsLittleEndian);

1163 if (!EntrySize)

1165 Length += *EntrySize;

1166 }

1167 }

1168 }

1169

1170

1171

1172

1173

1175 if (Table.OffsetEntryCount)

1176 OffsetEntryCount = *Table.OffsetEntryCount;

1177 else

1178 OffsetEntryCount = Table.Offsets ? Table.Offsets->size() : Offsets.size();

1180 OffsetEntryCount * (Table.Format == dwarf::DWARF64 ? 8 : 4);

1181 Length += OffsetsSize;

1182

1183

1184

1185 if (Table.Length)

1186 Length = *Table.Length;

1187

1193

1197 IsLittleEndian);

1198 };

1199

1200 if (Table.Offsets)

1202 Table.Offsets->size()),

1203 0);

1204 else if (OffsetEntryCount != 0)

1205 EmitOffsets(Offsets, OffsetsSize);

1206

1207 OS.write(ListBuffer.data(), ListBuffer.size());

1208 }

1209

1211}

1212

1215 return writeDWARFListsDWARFYAML::RnglistEntry(

1217}

1218

1221 return writeDWARFListsDWARFYAML::LoclistEntry(

1223}

1224

1227 auto EmitFunc =

1247 SecName + " is not supported");

1248 });

1249

1250 return EmitFunc;

1251}

1252

1255 StringMap<std::unique_ptr> &OutputBuffers) {

1256 std::string Data;

1258

1260

1261 if (Error Err = EmitFunc(DebugInfoStream, DI))

1262 return Err;

1263 DebugInfoStream.flush();

1264 if (!Data.empty())

1266

1268}

1269

1272 bool Is64BitAddrSize) {

1273 auto CollectDiagnostic = [](const SMDiagnostic &Diag, void *DiagContext) {

1274 *static_cast<SMDiagnostic *>(DiagContext) = Diag;

1275 };

1276

1278 yaml::Input YIn(YAMLString, nullptr, CollectDiagnostic,

1279 &GeneratedDiag);

1280

1284

1285 YIn >> DI;

1286 if (YIn.error())

1288

1291

1295

1296 if (Err)

1297 return std::move(Err);

1298 return std::move(DebugSections);

1299}

This file defines the StringMap class.

static void writeDWARFOffset(uint64_t Offset, dwarf::DwarfFormat Format, raw_ostream &OS, bool IsLittleEndian)

static Error emitDebugSectionImpl(const DWARFYAML::Data &DI, StringRef Sec, StringMap< std::unique_ptr< MemoryBuffer > > &OutputBuffers)

static void ZeroFillBytes(raw_ostream &OS, size_t Size)

static void emitFileEntry(raw_ostream &OS, const DWARFYAML::File &File)

static Error writeDWARFLists(raw_ostream &OS, ArrayRef< DWARFYAML::ListTable< EntryType > > Tables, bool IsLittleEndian, bool Is64BitAddrSize)

static void writeLineTableOpcode(const DWARFYAML::LineTableOpcode &Op, uint8_t OpcodeBase, uint8_t AddrSize, raw_ostream &OS, bool IsLittleEndian)

static Error writeVariableSizedInteger(uint64_t Integer, size_t Size, raw_ostream &OS, bool IsLittleEndian)

static Expected< uint64_t > writeListEntry(raw_ostream &OS, const DWARFYAML::RnglistEntry &Entry, uint8_t AddrSize, bool IsLittleEndian)

static void writeInteger(T Integer, raw_ostream &OS, bool IsLittleEndian)

static void writeExtendedOpcode(const DWARFYAML::LineTableOpcode &Op, uint8_t AddrSize, bool IsLittleEndian, raw_ostream &OS)

static Error checkOperandCount(StringRef EncodingString, ArrayRef< yaml::Hex64 > Values, uint64_t ExpectedOperands)

static Expected< uint64_t > writeDWARFExpression(raw_ostream &OS, const DWARFYAML::DWARFOperation &Operation, uint8_t AddrSize, bool IsLittleEndian)

static Error emitPubSection(raw_ostream &OS, const DWARFYAML::PubSection &Sect, bool IsLittleEndian, bool IsGNUPubSec=false)

static Expected< uint64_t > writeDIE(const DWARFYAML::Data &DI, uint64_t CUIndex, uint64_t AbbrevTableID, const dwarf::FormParams &Params, const DWARFYAML::Entry &Entry, raw_ostream &OS, bool IsLittleEndian)

static void writeInitialLength(const dwarf::DwarfFormat Format, const uint64_t Length, raw_ostream &OS, bool IsLittleEndian)

static std::vector< uint8_t > getStandardOpcodeLengths(uint16_t Version, std::optional< uint8_t > OpcodeBase)

static Error writeListEntryAddress(StringRef EncodingName, raw_ostream &OS, uint64_t Addr, uint8_t AddrSize, bool IsLittleEndian)

Common declarations for yaml2obj.

This file declares classes for handling the YAML representation of DWARF Debug Info.

Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx

This file contains constants used for implementing Dwarf debug support.

ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))

PowerPC Reduce CR logical Operation

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

size_t size() const

size - Get the array size.

This class represents an Operation in the Expression.

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.

Error takeError()

Take ownership of the stored error.

static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")

Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.

Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...

StringRef getMessage() const

void push_back(const T &Elt)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...

StringRef - Represent a constant reference to a string, i.e.

std::string str() const

str - Get the contents as an std::string.

constexpr bool empty() const

empty - Check if the string is empty.

constexpr size_t size() const

size - Get the string size.

constexpr const char * data() const

data - Get a pointer to the start of the string (which may not be null terminated).

A switch()-like statement whose cases are string literals.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

static Twine utohexstr(const uint64_t &Val)

LLVM Value Representation.

This class implements an extremely fast bulk output stream that can only output to a stream.

raw_ostream & write_zeros(unsigned NumZeros)

write_zeros - Insert 'NumZeros' nulls.

uint64_t tell() const

tell - Return the current offset with the file.

raw_ostream & write(unsigned char C)

A raw_ostream that writes to an std::string.

StringRef RangeListEncodingString(unsigned Encoding)

StringRef LocListEncodingString(unsigned Encoding)

StringRef OperationEncodingString(unsigned Encoding)

Error emitDebugStrOffsets(raw_ostream &OS, const Data &DI)

Error emitDebugInfo(raw_ostream &OS, const Data &DI)

Error emitDebugRanges(raw_ostream &OS, const Data &DI)

Error emitDebugAranges(raw_ostream &OS, const Data &DI)

Error emitDebugGNUPubnames(raw_ostream &OS, const Data &DI)

Error emitDebugAbbrev(raw_ostream &OS, const Data &DI)

Error emitDebugRnglists(raw_ostream &OS, const Data &DI)

Error emitDebugLoclists(raw_ostream &OS, const Data &DI)

std::function< Error(raw_ostream &, const Data &)> getDWARFEmitterByName(StringRef SecName)

Expected< StringMap< std::unique_ptr< MemoryBuffer > > > emitDebugSections(StringRef YAMLString, bool IsLittleEndian=sys::IsLittleEndianHost, bool Is64BitAddrSize=true)

Error emitDebugGNUPubtypes(raw_ostream &OS, const Data &DI)

Error emitDebugStr(raw_ostream &OS, const Data &DI)

Error emitDebugPubnames(raw_ostream &OS, const Data &DI)

Error emitDebugAddr(raw_ostream &OS, const Data &DI)

Error emitDebugNames(raw_ostream &OS, const Data &DI)

Error emitDebugPubtypes(raw_ostream &OS, const Data &DI)

Error emitDebugLine(raw_ostream &OS, const Data &DI)

DwarfFormat

Constants that define the DWARF format as 32 or 64 bit.

std::optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)

Get the fixed byte size for a given form.

@ DW_LENGTH_DWARF64

Indicator of 64-bit DWARF format.

static const bool IsLittleEndianHost

void swapByteOrder(T &Value)

This is an optimization pass for GlobalISel generic memory operations.

detail::zippy< detail::zip_first, T, U, Args... > zip_equal(T &&t, U &&u, Args &&...args)

zip iterator that assumes that all iteratees have the same length.

std::error_code inconvertibleErrorCode()

The value returned by this function can be returned from convertToErrorCode for Error values where no...

SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

Error joinErrors(Error E1, Error E2)

Concatenate errors.

auto make_first_range(ContainerTy &&c)

Given a container of pairs, return a range over the first elements.

void cantFail(Error Err, const char *Msg=nullptr)

Report a fatal error if Err is a failure value.

uint64_t alignTo(uint64_t Size, Align A)

Returns a multiple of A needed to store Size bytes.

auto make_second_range(ContainerTy &&c)

Given a container of pairs, return a range over the second elements.

unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)

Utility function to encode a SLEB128 value to an output stream.

auto find_if(R &&Range, UnaryPredicate P)

Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.

const char * toString(DWARFSectionKind Kind)

unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)

Utility function to encode a ULEB128 value to an output stream.

void consumeError(Error Err)

Consume a Error without doing anything.

std::vector< AttributeAbbrev > Attributes

std::optional< yaml::Hex64 > Length

std::optional< yaml::Hex8 > AddrSize

dwarf::DwarfFormat Format

yaml::Hex8 SegSelectorSize

std::vector< SegAddrPair > SegAddrPairs

std::vector< Unit > Units

std::vector< LineTable > DebugLines

std::optional< std::vector< AddrTableEntry > > DebugAddr

std::optional< std::vector< Ranges > > DebugRanges

std::optional< std::vector< ListTable< LoclistEntry > > > DebugLoclists

std::vector< AbbrevTable > DebugAbbrev

Expected< AbbrevTableInfo > getAbbrevTableInfoByID(uint64_t ID) const

std::optional< PubSection > GNUPubNames

std::optional< std::vector< ARange > > DebugAranges

StringRef getAbbrevTableContentByIndex(uint64_t Index) const

std::optional< PubSection > GNUPubTypes

SetVector< StringRef > getNonEmptySectionNames() const

std::optional< std::vector< StringOffsetsTable > > DebugStrOffsets

std::optional< std::vector< StringRef > > DebugStrings

std::optional< std::vector< ListTable< RnglistEntry > > > DebugRnglists

std::optional< PubSection > PubNames

std::optional< DebugNamesSection > DebugNames

std::optional< PubSection > PubTypes

std::optional< uint64_t > Length

std::optional< uint8_t > OpcodeBase

std::vector< LineTableOpcode > Opcodes

std::optional< uint64_t > PrologueLength

dwarf::DwarfFormat Format

std::vector< File > Files

std::vector< StringRef > IncludeDirs

std::optional< std::vector< uint8_t > > StandardOpcodeLengths

dwarf::DwarfFormat Format

std::vector< PubEntry > Entries

std::optional< yaml::Hex64 > Length

std::vector< yaml::Hex64 > Offsets

dwarf::DwarfFormat Format

std::optional< uint64_t > AbbrevTableID

dwarf::DwarfFormat Format

std::optional< yaml::Hex64 > Length

yaml::Hex64 TypeSignatureOrDwoID

std::optional< uint8_t > AddrSize

llvm::dwarf::UnitType Type

std::vector< Entry > Entries

std::optional< yaml::Hex64 > AbbrOffset

A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...

uint8_t getDwarfOffsetByteSize() const

The size of a reference is determined by the DWARF 32/64-bit format.

uint8_t getRefAddrByteSize() const

The definition of the size of form DW_FORM_ref_addr depends on the version.