@@ -230,7 +230,7 @@ template <typename DebugVector, typename ListEntry, typename DebugAddressEntry>
230
230
static bool emitWithBase (raw_ostream &OS, const DebugVector &Entries,
231
231
DebugAddrWriter &AddrWriter, DWARFUnit &CU,
232
232
uint32_t &Index, const ListEntry BaseAddressx,
233
- const ListEntry OffsetPair, const ListEntry EndOfList,
233
+ const ListEntry OffsetPair,
234
234
const std::function<void (uint32_t )> &Func) {
235
235
if (Entries.size () < 2 )
236
236
return false ;
@@ -241,7 +241,9 @@ static bool emitWithBase(raw_ostream &OS, const DebugVector &Entries,
241
241
const DebugAddressEntry &Entry = Entries[Index];
242
242
if (Entry.LowPC == 0 )
243
243
break ;
244
- assert (Base <= Entry.LowPC && " Entry base is higher than low PC" );
244
+ // In case rnglists or loclists are not sorted.
245
+ if (Base > Entry.LowPC )
246
+ break ;
245
247
uint32_t StartOffset = Entry.LowPC - Base;
246
248
uint32_t EndOffset = Entry.HighPC - Base;
247
249
if (encodeULEB128 (EndOffset, TempBuffer) > 2 )
@@ -266,8 +268,6 @@ static bool emitWithBase(raw_ostream &OS, const DebugVector &Entries,
266
268
encodeULEB128 (OffsetEntry.EndOffset , OS);
267
269
Func (OffsetEntry.Index );
268
270
}
269
- support::endian::write (OS, static_cast <uint8_t >(EndOfList),
270
- llvm::endianness::little);
271
271
return true ;
272
272
}
273
273
@@ -276,19 +276,17 @@ DebugRangeListsSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
276
276
std::lock_guard<std::mutex> Lock (WriterMutex);
277
277
278
278
RangeEntries.push_back (CurrentOffset);
279
- bool WrittenStartxLength = false ;
280
279
std::sort (
281
280
Ranges.begin (), Ranges.end (),
282
281
[](const DebugAddressRange &R1, const DebugAddressRange &R2) -> bool {
283
282
return R1.LowPC < R2.LowPC ;
284
283
});
285
284
for (unsigned I = 0 ; I < Ranges.size ();) {
286
- WrittenStartxLength = false ;
287
285
if (emitWithBase<DebugAddressRangesVector, dwarf::RnglistEntries,
288
- DebugAddressRange>(
289
- *CUBodyStream, Ranges, *AddrWriter, *CU, I ,
290
- dwarf::DW_RLE_base_addressx, dwarf::DW_RLE_offset_pair,
291
- dwarf::DW_RLE_end_of_list, [](uint32_t Index) -> void {}))
286
+ DebugAddressRange>(*CUBodyStream, Ranges, *AddrWriter, *CU,
287
+ I, dwarf::DW_RLE_base_addressx ,
288
+ dwarf::DW_RLE_offset_pair,
289
+ [](uint32_t Index) -> void {}))
292
290
continue ;
293
291
294
292
const DebugAddressRange &Range = Ranges[I];
@@ -299,12 +297,11 @@ DebugRangeListsSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
299
297
encodeULEB128 (Index, *CUBodyStream);
300
298
encodeULEB128 (Range.HighPC - Range.LowPC , *CUBodyStream);
301
299
++I;
302
- WrittenStartxLength = true ;
303
300
}
304
- if (WrittenStartxLength)
305
- support::endian::write (*CUBodyStream,
306
- static_cast <uint8_t >(dwarf::DW_RLE_end_of_list),
307
- llvm::endianness::little);
301
+
302
+ support::endian::write (*CUBodyStream,
303
+ static_cast <uint8_t >(dwarf::DW_RLE_end_of_list),
304
+ llvm::endianness::little);
308
305
CurrentOffset = CUBodyBuffer->size ();
309
306
return RangeEntries.size () - 1 ;
310
307
}
@@ -688,20 +685,18 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
688
685
}
689
686
690
687
std::vector<uint64_t > OffsetsArray;
691
- bool WrittenStartxLength = false ;
692
688
auto writeExpression = [&](uint32_t Index) -> void {
693
689
const DebugLocationEntry &Entry = LocList[Index];
694
690
encodeULEB128 (Entry.Expr .size (), LocBodyStream);
695
691
LocBodyStream << StringRef (
696
692
reinterpret_cast <const char *>(Entry.Expr .data ()), Entry.Expr .size ());
697
693
};
698
694
for (unsigned I = 0 ; I < LocList.size ();) {
699
- WrittenStartxLength = false ;
700
695
if (emitWithBase<DebugLocationsVector, dwarf::LoclistEntries,
701
- DebugLocationEntry>(
702
- LocBodyStream, LocList, AddrWriter, CU, I ,
703
- dwarf::DW_LLE_base_addressx, dwarf::DW_LLE_offset_pair,
704
- dwarf::DW_LLE_end_of_list, writeExpression))
696
+ DebugLocationEntry>(LocBodyStream, LocList, AddrWriter, CU,
697
+ I, dwarf::DW_LLE_base_addressx ,
698
+ dwarf::DW_LLE_offset_pair,
699
+ writeExpression))
705
700
continue ;
706
701
707
702
const DebugLocationEntry &Entry = LocList[I];
@@ -713,13 +708,11 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
713
708
encodeULEB128 (Entry.HighPC - Entry.LowPC , LocBodyStream);
714
709
writeExpression (I);
715
710
++I;
716
- WrittenStartxLength = true ;
717
711
}
718
712
719
- if (WrittenStartxLength)
720
- support::endian::write (LocBodyStream,
721
- static_cast <uint8_t >(dwarf::DW_LLE_end_of_list),
722
- llvm::endianness::little);
713
+ support::endian::write (LocBodyStream,
714
+ static_cast <uint8_t >(dwarf::DW_LLE_end_of_list),
715
+ llvm::endianness::little);
723
716
}
724
717
725
718
void DebugLoclistWriter::addList (DIEBuilder &DIEBldr, DIE &Die,
0 commit comments