@@ -365,20 +365,7 @@ static void LLVM_ATTRIBUTE_UNUSED dumpDataAux(DataExtractor Data,
365
365
errs () << " \n " ;
366
366
}
367
367
368
- // This is a workaround for old compilers which do not allow
369
- // noreturn attribute usage in lambdas. Once the support for those
370
- // compilers are phased out, we can remove this and return back to
371
- // a ReportError lambda: [StartOffset](const char *ErrorMsg).
372
- static void LLVM_ATTRIBUTE_NORETURN ReportError (uint64_t StartOffset,
373
- const char *ErrorMsg) {
374
- std::string Str;
375
- raw_string_ostream OS (Str);
376
- OS << format (ErrorMsg, StartOffset);
377
- OS.flush ();
378
- report_fatal_error (Str);
379
- }
380
-
381
- void DWARFDebugFrame::parse (DWARFDataExtractor Data) {
368
+ Error DWARFDebugFrame::parse (DWARFDataExtractor Data) {
382
369
uint64_t Offset = 0 ;
383
370
DenseMap<uint64_t , CIE *> CIEs;
384
371
@@ -427,51 +414,55 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
427
414
// Walk the augmentation string to get all the augmentation data.
428
415
for (unsigned i = 0 , e = AugmentationString.size (); i != e; ++i) {
429
416
switch (AugmentationString[i]) {
430
- default :
431
- ReportError (
432
- StartOffset,
433
- " Unknown augmentation character in entry at %" PRIx64);
434
- case ' L' :
435
- LSDAPointerEncoding = Data.getU8 (&Offset);
436
- break ;
437
- case ' P' : {
438
- if (Personality)
439
- ReportError (StartOffset,
440
- " Duplicate personality in entry at %" PRIx64);
441
- PersonalityEncoding = Data.getU8 (&Offset);
442
- Personality = Data.getEncodedPointer (
443
- &Offset, *PersonalityEncoding,
444
- EHFrameAddress ? EHFrameAddress + Offset : 0 );
445
- break ;
446
- }
447
- case ' R' :
448
- FDEPointerEncoding = Data.getU8 (&Offset);
449
- break ;
450
- case ' S' :
451
- // Current frame is a signal trampoline.
452
- break ;
453
- case ' z' :
454
- if (i)
455
- ReportError (StartOffset,
456
- " 'z' must be the first character at %" PRIx64);
457
- // Parse the augmentation length first. We only parse it if
458
- // the string contains a 'z'.
459
- AugmentationLength = Data.getULEB128 (&Offset);
460
- StartAugmentationOffset = Offset;
461
- EndAugmentationOffset = Offset + *AugmentationLength;
462
- break ;
463
- case ' B' :
464
- // B-Key is used for signing functions associated with this
465
- // augmentation string
466
- break ;
417
+ default :
418
+ return createStringError (
419
+ errc::invalid_argument,
420
+ " unknown augmentation character in entry at 0x%" PRIx64,
421
+ StartOffset);
422
+ case ' L' :
423
+ LSDAPointerEncoding = Data.getU8 (&Offset);
424
+ break ;
425
+ case ' P' : {
426
+ if (Personality)
427
+ return createStringError (
428
+ errc::invalid_argument,
429
+ " duplicate personality in entry at 0x%" PRIx64, StartOffset);
430
+ PersonalityEncoding = Data.getU8 (&Offset);
431
+ Personality = Data.getEncodedPointer (
432
+ &Offset, *PersonalityEncoding,
433
+ EHFrameAddress ? EHFrameAddress + Offset : 0 );
434
+ break ;
435
+ }
436
+ case ' R' :
437
+ FDEPointerEncoding = Data.getU8 (&Offset);
438
+ break ;
439
+ case ' S' :
440
+ // Current frame is a signal trampoline.
441
+ break ;
442
+ case ' z' :
443
+ if (i)
444
+ return createStringError (
445
+ errc::invalid_argument,
446
+ " 'z' must be the first character at 0x%" PRIx64, StartOffset);
447
+ // Parse the augmentation length first. We only parse it if
448
+ // the string contains a 'z'.
449
+ AugmentationLength = Data.getULEB128 (&Offset);
450
+ StartAugmentationOffset = Offset;
451
+ EndAugmentationOffset = Offset + *AugmentationLength;
452
+ break ;
453
+ case ' B' :
454
+ // B-Key is used for signing functions associated with this
455
+ // augmentation string
456
+ break ;
467
457
}
468
458
}
469
459
470
460
if (AugmentationLength.hasValue ()) {
471
461
if (Offset != EndAugmentationOffset)
472
- ReportError (StartOffset,
473
- " Parsing augmentation data at %" PRIx64 " failed" );
474
-
462
+ return createStringError (errc::invalid_argument,
463
+ " parsing augmentation data at 0x%" PRIx64
464
+ " failed" ,
465
+ StartOffset);
475
466
AugmentationData = Data.getData ().slice (StartAugmentationOffset,
476
467
EndAugmentationOffset);
477
468
}
@@ -496,9 +487,10 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
496
487
if (IsEH) {
497
488
// The address size is encoded in the CIE we reference.
498
489
if (!Cie)
499
- ReportError (StartOffset, " Parsing FDE data at %" PRIx64
500
- " failed due to missing CIE" );
501
-
490
+ return createStringError (errc::invalid_argument,
491
+ " parsing FDE data at 0x%" PRIx64
492
+ " failed due to missing CIE" ,
493
+ StartOffset);
502
494
if (auto Val = Data.getEncodedPointer (
503
495
&Offset, Cie->getFDEPointerEncoding (),
504
496
EHFrameAddress ? EHFrameAddress + Offset : 0 )) {
@@ -524,8 +516,10 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
524
516
}
525
517
526
518
if (Offset != EndAugmentationOffset)
527
- ReportError (StartOffset,
528
- " Parsing augmentation data at %" PRIx64 " failed" );
519
+ return createStringError (errc::invalid_argument,
520
+ " parsing augmentation data at 0x%" PRIx64
521
+ " failed" ,
522
+ StartOffset);
529
523
}
530
524
} else {
531
525
InitialLocation = Data.getRelocatedAddress (&Offset);
@@ -538,14 +532,16 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
538
532
}
539
533
540
534
if (Error E =
541
- Entries.back ()->cfis ().parse (Data, &Offset, EndStructureOffset)) {
542
- report_fatal_error (toString (std::move (E)));
543
- }
535
+ Entries.back ()->cfis ().parse (Data, &Offset, EndStructureOffset))
536
+ return E;
544
537
545
538
if (Offset != EndStructureOffset)
546
- ReportError (StartOffset,
547
- " Parsing entry instructions at %" PRIx64 " failed" );
539
+ return createStringError (
540
+ errc::invalid_argument,
541
+ " parsing entry instructions at 0x%" PRIx64 " failed" , StartOffset);
548
542
}
543
+
544
+ return Error::success ();
549
545
}
550
546
551
547
FrameEntry *DWARFDebugFrame::getEntryAtOffset (uint64_t Offset) const {
0 commit comments