@@ -793,6 +793,20 @@ DebugLoclistsSectionRef::create(MCCASBuilder &MB,
793
793
return get (B->build ());
794
794
}
795
795
796
+ Expected<DebugRangesSectionRef>
797
+ DebugRangesSectionRef::create (MCCASBuilder &MB,
798
+ ArrayRef<cas::ObjectRef> Fragments) {
799
+ Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
800
+ if (!B)
801
+ return B.takeError ();
802
+
803
+ if (auto E = createGenericDebugSection<DebugRangesSectionRef>(
804
+ MB, Fragments, B->Data , B->Refs ))
805
+ return E;
806
+
807
+ return get (B->build ());
808
+ }
809
+
796
810
Expected<uint64_t > SectionRef::materialize (MCCASReader &Reader,
797
811
raw_ostream *Stream) const {
798
812
// Start a new section for relocations.
@@ -1262,6 +1276,14 @@ DebugLoclistsSectionRef::materialize(MCCASReader &Reader,
1262
1276
Reader, Remaining, *this );
1263
1277
}
1264
1278
1279
+ Expected<uint64_t >
1280
+ DebugRangesSectionRef::materialize (MCCASReader &Reader,
1281
+ raw_ostream *Stream) const {
1282
+ StringRef Remaining = getData ();
1283
+ return materializeGenericDebugSection<DebugRangesSectionRef>(
1284
+ Reader, Remaining, *this );
1285
+ }
1286
+
1265
1287
Expected<AtomRef> AtomRef::create (MCCASBuilder &MB,
1266
1288
ArrayRef<cas::ObjectRef> Fragments) {
1267
1289
Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
@@ -1592,7 +1614,8 @@ DwarfSectionsCache mccasformats::v1::getDwarfSections(MCAssembler &Asm) {
1592
1614
Asm.getContext ().getObjectFileInfo ()->getDwarfStrSection (),
1593
1615
Asm.getContext ().getObjectFileInfo ()->getDwarfAbbrevSection (),
1594
1616
Asm.getContext ().getObjectFileInfo ()->getDwarfStrOffSection (),
1595
- Asm.getContext ().getObjectFileInfo ()->getDwarfLoclistsSection ()};
1617
+ Asm.getContext ().getObjectFileInfo ()->getDwarfLoclistsSection (),
1618
+ Asm.getContext ().getObjectFileInfo ()->getDwarfRangesSection ()};
1596
1619
}
1597
1620
1598
1621
Error MCCASBuilder::prepare () {
@@ -2452,6 +2475,23 @@ Error MCCASBuilder::createDebugLoclistsSection() {
2452
2475
return finalizeSection<DebugLoclistsSectionRef>();
2453
2476
}
2454
2477
2478
+ Error MCCASBuilder::createDebugRangesSection () {
2479
+
2480
+ auto MaybeDebugRangesRef =
2481
+ createGenericDebugRef<DebugRangesRef>(DwarfSections.Ranges );
2482
+ if (!MaybeDebugRangesRef)
2483
+ return Error::success ();
2484
+
2485
+ if (!*MaybeDebugRangesRef)
2486
+ return MaybeDebugRangesRef->takeError ();
2487
+
2488
+ startSection (DwarfSections.Ranges );
2489
+ addNode (**MaybeDebugRangesRef);
2490
+ if (auto E = createPaddingRef (DwarfSections.Ranges ))
2491
+ return E;
2492
+ return finalizeSection<DebugRangesSectionRef>();
2493
+ }
2494
+
2455
2495
static ArrayRef<char > getFragmentContents (const MCFragment &Fragment) {
2456
2496
switch (Fragment.getKind ()) {
2457
2497
#define MCFRAGMENT_NODE_REF (MCFragmentName, MCEnumName, MCEnumIdentifier ) \
@@ -2597,6 +2637,13 @@ Error MCCASBuilder::buildFragments() {
2597
2637
continue ;
2598
2638
}
2599
2639
2640
+ // Handle Debug Ranges sections separately.
2641
+ if (&Sec == DwarfSections.Ranges ) {
2642
+ if (auto E = createDebugRangesSection ())
2643
+ return E;
2644
+ continue ;
2645
+ }
2646
+
2600
2647
// Start Subsection for one section.
2601
2648
startSection (&Sec);
2602
2649
@@ -2757,7 +2804,7 @@ void MCCASBuilder::startSection(const MCSection *Sec) {
2757
2804
// SectionRelocs. No Atoms are considered for this section.
2758
2805
if (R.F && Sec != DwarfSections.Line && Sec != DwarfSections.DebugInfo &&
2759
2806
Sec != DwarfSections.Abbrev && Sec != DwarfSections.StrOffsets &&
2760
- Sec != DwarfSections.Loclists )
2807
+ Sec != DwarfSections.Loclists && Sec != DwarfSections. Ranges )
2761
2808
RelMap[R.F ].push_back (R.MRE );
2762
2809
else
2763
2810
// If the fragment is nullptr, it should a section with only relocation
@@ -2964,6 +3011,8 @@ Expected<uint64_t> MCCASReader::materializeGroup(cas::ObjectRef ID) {
2964
3011
return F->materialize (*this );
2965
3012
if (auto F = DebugLoclistsSectionRef::Cast (*Node))
2966
3013
return F->materialize (*this );
3014
+ if (auto F = DebugRangesSectionRef::Cast (*Node))
3015
+ return F->materialize (*this );
2967
3016
if (auto F = CStringRef::Cast (*Node)) {
2968
3017
auto Size = F->materialize (OS);
2969
3018
if (!Size)
@@ -3032,6 +3081,8 @@ Expected<uint64_t> MCCASReader::materializeSection(cas::ObjectRef ID,
3032
3081
return F->materialize (*Stream);
3033
3082
if (auto F = DebugLoclistsRef::Cast (*Node))
3034
3083
return F->materialize (*Stream);
3084
+ if (auto F = DebugRangesRef::Cast (*Node))
3085
+ return F->materialize (*Stream);
3035
3086
if (auto F = AddendsRef::Cast (*Node))
3036
3087
// AddendsRef is already handled when materializing Atoms, skip.
3037
3088
return 0 ;
0 commit comments