@@ -185,6 +185,7 @@ namespace bolt {
185
185
class DIEStreamer : public DwarfStreamer {
186
186
DIEBuilder *DIEBldr;
187
187
DWARFRewriter &Rewriter;
188
+ GDBIndex &GDBIndexSection;
188
189
189
190
private:
190
191
// / Emit the compilation unit header for \p Unit in the debug_info
@@ -247,7 +248,7 @@ class DIEStreamer : public DwarfStreamer {
247
248
const uint64_t TypeSignature = cast<DWARFTypeUnit>(Unit).getTypeHash ();
248
249
DIE *TypeDIE = DIEBldr->getTypeDIE (Unit);
249
250
const DIEBuilder::DWARFUnitInfo &UI = DIEBldr->getUnitInfoByDwarfUnit (Unit);
250
- Rewriter .addGDBTypeUnitEntry (
251
+ GDBIndexSection .addGDBTypeUnitEntry (
251
252
{UI.UnitOffset , TypeSignature, TypeDIE->getOffset ()});
252
253
if (Unit.getVersion () < 5 ) {
253
254
// Switch the section to .debug_types section.
@@ -279,11 +280,12 @@ class DIEStreamer : public DwarfStreamer {
279
280
280
281
public:
281
282
DIEStreamer (DIEBuilder *DIEBldr, DWARFRewriter &Rewriter,
283
+ GDBIndex &GDBIndexSection,
282
284
DWARFLinkerBase::OutputFileType OutFileType,
283
285
raw_pwrite_stream &OutFile,
284
286
DWARFLinkerBase::MessageHandlerTy Warning)
285
287
: DwarfStreamer(OutFileType, OutFile, Warning), DIEBldr(DIEBldr),
286
- Rewriter (Rewriter){};
288
+ Rewriter (Rewriter), GDBIndexSection(GDBIndexSection) {};
287
289
288
290
using DwarfStreamer::emitCompileUnitHeader;
289
291
@@ -326,12 +328,11 @@ static cl::opt<bool> KeepARanges(
326
328
" keep or generate .debug_aranges section if .gdb_index is written" ),
327
329
cl::Hidden, cl::cat(BoltCategory));
328
330
329
- static cl::opt<bool >
330
- DeterministicDebugInfo (" deterministic-debuginfo" ,
331
- cl::desc (" disables parallel execution of tasks that may produce "
332
- " nondeterministic debug info" ),
333
- cl::init(true ),
334
- cl::cat(BoltCategory));
331
+ static cl::opt<bool > DeterministicDebugInfo (
332
+ " deterministic-debuginfo" ,
333
+ cl::desc (" disables parallel execution of tasks that may produce "
334
+ " nondeterministic debug info" ),
335
+ cl::init(true ), cl::cat(BoltCategory));
335
336
336
337
static cl::opt<std::string> DwarfOutputPath (
337
338
" dwarf-output-path" ,
@@ -460,10 +461,11 @@ static std::optional<uint64_t> getAsAddress(const DWARFUnit &DU,
460
461
static std::unique_ptr<DIEStreamer>
461
462
createDIEStreamer (const Triple &TheTriple, raw_pwrite_stream &OutFile,
462
463
StringRef Swift5ReflectionSegmentName, DIEBuilder &DIEBldr,
463
- DWARFRewriter &Rewriter) {
464
+ DWARFRewriter &Rewriter, GDBIndex &GDBIndexSection ) {
464
465
465
466
std::unique_ptr<DIEStreamer> Streamer = std::make_unique<DIEStreamer>(
466
- &DIEBldr, Rewriter, DWARFLinkerBase::OutputFileType::Object, OutFile,
467
+ &DIEBldr, Rewriter, GDBIndexSection,
468
+ DWARFLinkerBase::OutputFileType::Object, OutFile,
467
469
[&](const Twine &Warning, StringRef Context, const DWARFDie *) {});
468
470
Error Err = Streamer->init (TheTriple, Swift5ReflectionSegmentName);
469
471
if (Err)
@@ -484,13 +486,12 @@ emitUnit(DIEBuilder &DIEBldr, DIEStreamer &Streamer, DWARFUnit &Unit) {
484
486
return {U.UnitOffset , U.UnitLength , TypeHash};
485
487
}
486
488
487
- static void emitDWOBuilder (const std::string &DWOName,
488
- DIEBuilder &DWODIEBuilder, DWARFRewriter &Rewriter,
489
- DWARFUnit &SplitCU, DWARFUnit &CU,
490
- DWARFRewriter::DWPState &State,
491
- DebugLocWriter &LocWriter,
492
- DebugStrOffsetsWriter &StrOffstsWriter,
493
- DebugStrWriter &StrWriter) {
489
+ static void
490
+ emitDWOBuilder (const std::string &DWOName, DIEBuilder &DWODIEBuilder,
491
+ DWARFRewriter &Rewriter, DWARFUnit &SplitCU, DWARFUnit &CU,
492
+ DWARFRewriter::DWPState &State, DebugLocWriter &LocWriter,
493
+ DebugStrOffsetsWriter &StrOffstsWriter,
494
+ DebugStrWriter &StrWriter, GDBIndex &GDBIndexSection) {
494
495
// Populate debug_info and debug_abbrev for current dwo into StringRef.
495
496
DWODIEBuilder.generateAbbrevs ();
496
497
DWODIEBuilder.finish ();
@@ -500,8 +501,9 @@ static void emitDWOBuilder(const std::string &DWOName,
500
501
std::make_shared<raw_svector_ostream>(OutBuffer);
501
502
const object::ObjectFile *File = SplitCU.getContext ().getDWARFObj ().getFile ();
502
503
auto TheTriple = std::make_unique<Triple>(File->makeTriple ());
503
- std::unique_ptr<DIEStreamer> Streamer = createDIEStreamer (
504
- *TheTriple, *ObjOS, " DwoStreamerInitAug2" , DWODIEBuilder, Rewriter);
504
+ std::unique_ptr<DIEStreamer> Streamer =
505
+ createDIEStreamer (*TheTriple, *ObjOS, " DwoStreamerInitAug2" ,
506
+ DWODIEBuilder, Rewriter, GDBIndexSection);
505
507
DWARFRewriter::UnitMetaVectorType TUMetaVector;
506
508
DWARFRewriter::UnitMeta CUMI = {0 , 0 , 0 };
507
509
if (SplitCU.getContext ().getMaxDWOVersion () >= 5 ) {
@@ -652,6 +654,7 @@ void DWARFRewriter::updateDebugInfo() {
652
654
653
655
DWARF5AcceleratorTable DebugNamesTable (opts::CreateDebugNames, BC,
654
656
*StrWriter);
657
+ GDBIndex GDBIndexSection (BC);
655
658
DWPState State;
656
659
if (opts::WriteDWP)
657
660
initDWPState (State);
@@ -704,7 +707,8 @@ void DWARFRewriter::updateDebugInfo() {
704
707
TempRangesSectionWriter->finalizeSection ();
705
708
706
709
emitDWOBuilder (DWOName, DWODIEBuilder, *this , **SplitCU, *Unit, State,
707
- DebugLocDWoWriter, DWOStrOffstsWriter, DWOStrWriter);
710
+ DebugLocDWoWriter, DWOStrOffstsWriter, DWOStrWriter,
711
+ GDBIndexSection);
708
712
}
709
713
710
714
if (Unit->getVersion () >= 5 ) {
@@ -729,9 +733,10 @@ void DWARFRewriter::updateDebugInfo() {
729
733
std::make_unique<raw_svector_ostream>(OutBuffer);
730
734
const object::ObjectFile *File = BC.DwCtx ->getDWARFObj ().getFile ();
731
735
auto TheTriple = std::make_unique<Triple>(File->makeTriple ());
732
- std::unique_ptr<DIEStreamer> Streamer =
733
- createDIEStreamer (*TheTriple, *ObjOS, " TypeStreamer" , DIEBlder, *this );
734
- CUOffsetMap OffsetMap = finalizeTypeSections (DIEBlder, *Streamer);
736
+ std::unique_ptr<DIEStreamer> Streamer = createDIEStreamer (
737
+ *TheTriple, *ObjOS, " TypeStreamer" , DIEBlder, *this , GDBIndexSection);
738
+ CUOffsetMap OffsetMap =
739
+ finalizeTypeSections (DIEBlder, *Streamer, GDBIndexSection);
735
740
736
741
const bool SingleThreadedMode =
737
742
opts::NoThreads || opts::DeterministicDebugInfo;
@@ -761,7 +766,8 @@ void DWARFRewriter::updateDebugInfo() {
761
766
762
767
finalizeDebugSections (DIEBlder, DebugNamesTable, *Streamer, *ObjOS,
763
768
OffsetMap);
764
- updateGdbIndexSection (OffsetMap, CUIndex);
769
+ GDBIndexSection.updateGdbIndexSection (OffsetMap, CUIndex,
770
+ *ARangesSectionWriter);
765
771
}
766
772
767
773
void DWARFRewriter::updateUnitDebugInfo (
@@ -1429,7 +1435,8 @@ void DWARFRewriter::updateLineTableOffsets(const MCAsmLayout &Layout) {
1429
1435
}
1430
1436
1431
1437
CUOffsetMap DWARFRewriter::finalizeTypeSections (DIEBuilder &DIEBlder,
1432
- DIEStreamer &Streamer) {
1438
+ DIEStreamer &Streamer,
1439
+ GDBIndex &GDBIndexSection) {
1433
1440
// update TypeUnit DW_AT_stmt_list with new .debug_line information.
1434
1441
auto updateLineTable = [&](const DWARFUnit &Unit) -> void {
1435
1442
DIE *UnitDIE = DIEBlder.getUnitDIEbyUnit (Unit);
@@ -1449,8 +1456,8 @@ CUOffsetMap DWARFRewriter::finalizeTypeSections(DIEBuilder &DIEBlder,
1449
1456
std::make_shared<raw_svector_ostream>(OutBuffer);
1450
1457
const object::ObjectFile *File = BC.DwCtx ->getDWARFObj ().getFile ();
1451
1458
auto TheTriple = std::make_unique<Triple>(File->makeTriple ());
1452
- std::unique_ptr<DIEStreamer> TypeStreamer =
1453
- createDIEStreamer ( *TheTriple, *ObjOS, " TypeStreamer" , DIEBlder, *this );
1459
+ std::unique_ptr<DIEStreamer> TypeStreamer = createDIEStreamer (
1460
+ *TheTriple, *ObjOS, " TypeStreamer" , DIEBlder, *this , GDBIndexSection );
1454
1461
1455
1462
// generate debug_info and CUMap
1456
1463
CUOffsetMap CUMap;
0 commit comments