@@ -251,7 +251,7 @@ Error DWARFYAML::emitDebugGNUPubtypes(raw_ostream &OS, const Data &DI) {
251
251
}
252
252
253
253
static Expected<uint64_t > writeDIE (ArrayRef<DWARFYAML::Abbrev> AbbrevDecls,
254
- const DWARFYAML::Unit &Unit ,
254
+ const dwarf::FormParams &Params ,
255
255
const DWARFYAML::Entry &Entry,
256
256
raw_ostream &OS, bool IsLittleEndian) {
257
257
uint64_t EntryBegin = OS.tell ();
@@ -278,14 +278,14 @@ static Expected<uint64_t> writeDIE(ArrayRef<DWARFYAML::Abbrev> AbbrevDecls,
278
278
case dwarf::DW_FORM_addr:
279
279
// TODO: Test this error.
280
280
if (Error Err = writeVariableSizedInteger (
281
- FormVal->Value , Unit. FormParams .AddrSize , OS, IsLittleEndian))
281
+ FormVal->Value , Params .AddrSize , OS, IsLittleEndian))
282
282
return std::move (Err);
283
283
break ;
284
284
case dwarf::DW_FORM_ref_addr:
285
285
// TODO: Test this error.
286
- if (Error Err = writeVariableSizedInteger (
287
- FormVal-> Value , Unit. FormParams . getRefAddrByteSize (), OS ,
288
- IsLittleEndian))
286
+ if (Error Err = writeVariableSizedInteger (FormVal-> Value ,
287
+ Params. getRefAddrByteSize (),
288
+ OS, IsLittleEndian))
289
289
return std::move (Err);
290
290
break ;
291
291
case dwarf::DW_FORM_exprloc:
@@ -367,9 +367,9 @@ static Expected<uint64_t> writeDIE(ArrayRef<DWARFYAML::Abbrev> AbbrevDecls,
367
367
case dwarf::DW_FORM_GNU_strp_alt:
368
368
case dwarf::DW_FORM_line_strp:
369
369
case dwarf::DW_FORM_strp_sup:
370
- cantFail (writeVariableSizedInteger (
371
- FormVal-> Value , Unit. FormParams .getDwarfOffsetByteSize (), OS,
372
- IsLittleEndian));
370
+ cantFail (writeVariableSizedInteger (FormVal-> Value ,
371
+ Params .getDwarfOffsetByteSize (), OS,
372
+ IsLittleEndian));
373
373
break ;
374
374
default :
375
375
break ;
@@ -382,10 +382,10 @@ static Expected<uint64_t> writeDIE(ArrayRef<DWARFYAML::Abbrev> AbbrevDecls,
382
382
383
383
Error DWARFYAML::emitDebugInfo (raw_ostream &OS, const DWARFYAML::Data &DI) {
384
384
for (const DWARFYAML::Unit &Unit : DI.CompileUnits ) {
385
+ dwarf::FormParams Params = {Unit.Version , Unit.AddrSize , Unit.Format };
385
386
uint64_t Length = 3 ; // sizeof(version) + sizeof(address_size)
386
- Length += Unit.FormParams .Version >= 5 ? 1 : 0 ; // sizeof(unit_type)
387
- Length +=
388
- Unit.FormParams .getDwarfOffsetByteSize (); // sizeof(debug_abbrev_offset)
387
+ Length += Unit.Version >= 5 ? 1 : 0 ; // sizeof(unit_type)
388
+ Length += Params.getDwarfOffsetByteSize (); // sizeof(debug_abbrev_offset)
389
389
390
390
// Since the length of the current compilation unit is undetermined yet, we
391
391
// firstly write the content of the compilation unit to a buffer to
@@ -396,7 +396,7 @@ Error DWARFYAML::emitDebugInfo(raw_ostream &OS, const DWARFYAML::Data &DI) {
396
396
397
397
for (const DWARFYAML::Entry &Entry : Unit.Entries ) {
398
398
if (Expected<uint64_t > EntryLength = writeDIE (
399
- DI.AbbrevDecls , Unit , Entry, EntryBufferOS, DI.IsLittleEndian ))
399
+ DI.AbbrevDecls , Params , Entry, EntryBufferOS, DI.IsLittleEndian ))
400
400
Length += *EntryLength;
401
401
else
402
402
return EntryLength.takeError ();
@@ -407,17 +407,15 @@ Error DWARFYAML::emitDebugInfo(raw_ostream &OS, const DWARFYAML::Data &DI) {
407
407
if (Unit.Length )
408
408
Length = *Unit.Length ;
409
409
410
- writeInitialLength (Unit.FormParams . Format , Length, OS, DI.IsLittleEndian );
411
- writeInteger ((uint16_t )Unit.FormParams . Version , OS, DI.IsLittleEndian );
412
- if (Unit.FormParams . Version >= 5 ) {
410
+ writeInitialLength (Unit.Format , Length, OS, DI.IsLittleEndian );
411
+ writeInteger ((uint16_t )Unit.Version , OS, DI.IsLittleEndian );
412
+ if (Unit.Version >= 5 ) {
413
413
writeInteger ((uint8_t )Unit.Type , OS, DI.IsLittleEndian );
414
- writeInteger ((uint8_t )Unit.FormParams .AddrSize , OS, DI.IsLittleEndian );
415
- writeDWARFOffset (Unit.AbbrOffset , Unit.FormParams .Format , OS,
416
- DI.IsLittleEndian );
414
+ writeInteger ((uint8_t )Unit.AddrSize , OS, DI.IsLittleEndian );
415
+ writeDWARFOffset (Unit.AbbrOffset , Unit.Format , OS, DI.IsLittleEndian );
417
416
} else {
418
- writeDWARFOffset (Unit.AbbrOffset , Unit.FormParams .Format , OS,
419
- DI.IsLittleEndian );
420
- writeInteger ((uint8_t )Unit.FormParams .AddrSize , OS, DI.IsLittleEndian );
417
+ writeDWARFOffset (Unit.AbbrOffset , Unit.Format , OS, DI.IsLittleEndian );
418
+ writeInteger ((uint8_t )Unit.AddrSize , OS, DI.IsLittleEndian );
421
419
}
422
420
423
421
OS.write (EntryBuffer.data (), EntryBuffer.size ());
@@ -473,8 +471,7 @@ Error DWARFYAML::emitDebugLine(raw_ostream &OS, const DWARFYAML::Data &DI) {
473
471
case dwarf::DW_LNE_set_discriminator:
474
472
// TODO: Test this error.
475
473
if (Error Err = writeVariableSizedInteger (
476
- Op.Data , DI.CompileUnits [0 ].FormParams .AddrSize , OS,
477
- DI.IsLittleEndian ))
474
+ Op.Data , DI.CompileUnits [0 ].AddrSize , OS, DI.IsLittleEndian ))
478
475
return Err;
479
476
break ;
480
477
case dwarf::DW_LNE_define_file:
0 commit comments