@@ -412,159 +412,263 @@ pub enum Error {
412412}
413413
414414impl fmt:: Display for Error {
415- #[ inline]
416415 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> :: core:: result:: Result < ( ) , fmt:: Error > {
417- write ! ( f, "{}" , self . description( ) )
418- }
419- }
420-
421- impl Error {
422- /// A short description of the error.
423- pub fn description ( & self ) -> & str {
424416 match * self {
425- Error :: Io => "An I/O error occurred while reading." ,
417+ Error :: Io => write ! ( f , "An I/O error occurred while reading." ) ,
426418 Error :: PcRelativePointerButSectionBaseIsUndefined => {
427- "Found a PC relative pointer, but the section base is undefined."
419+ write ! (
420+ f,
421+ "Found a PC relative pointer, but the section base is undefined."
422+ )
428423 }
429424 Error :: TextRelativePointerButTextBaseIsUndefined => {
430- "Found a `.text` relative pointer, but the `.text` base is undefined."
425+ write ! (
426+ f,
427+ "Found a `.text` relative pointer, but the `.text` base is undefined."
428+ )
431429 }
432430 Error :: DataRelativePointerButDataBaseIsUndefined => {
433- "Found a data relative pointer, but the data base is undefined."
431+ write ! (
432+ f,
433+ "Found a data relative pointer, but the data base is undefined."
434+ )
434435 }
435436 Error :: FuncRelativePointerInBadContext => {
436- "Found a function relative pointer in a context that does not have a function base."
437+ write ! (
438+ f,
439+ "Found a function relative pointer in a context that does not have a function base."
440+ )
437441 }
438442 Error :: CannotParseOmitPointerEncoding => {
439- "Cannot parse a pointer with a `DW_EH_PE_omit` encoding."
443+ write ! ( f , "Cannot parse a pointer with a `DW_EH_PE_omit` encoding." )
440444 }
441- Error :: BadUnsignedLeb128 => "An error parsing an unsigned LEB128 value" ,
442- Error :: BadSignedLeb128 => "An error parsing a signed LEB128 value" ,
445+ Error :: BadUnsignedLeb128 => write ! ( f , "An error parsing an unsigned LEB128 value" ) ,
446+ Error :: BadSignedLeb128 => write ! ( f , "An error parsing a signed LEB128 value" ) ,
443447 Error :: AbbreviationTagZero => {
444- "An abbreviation declared that its tag is zero,
448+ write ! (
449+ f,
450+ "An abbreviation declared that its tag is zero,
445451 but zero is reserved for null records"
452+ )
446453 }
447454 Error :: AttributeNameZero => {
448- "An attribute specification declared that its name is zero,
455+ write ! (
456+ f,
457+ "An attribute specification declared that its name is zero,
449458 but zero is reserved for null records"
459+ )
450460 }
451461 Error :: AttributeFormZero => {
452- "An attribute specification declared that its form is zero,
462+ write ! (
463+ f,
464+ "An attribute specification declared that its form is zero,
453465 but zero is reserved for null records"
466+ )
454467 }
455468 Error :: BadHasChildren => {
456- "The abbreviation's has-children byte was not one of
457- `DW_CHILDREN_{yes,no}`"
469+ write ! (
470+ f,
471+ "The abbreviation's has-children byte was not one of
472+ `DW_CHILDREN_{{yes,no}}`"
473+ )
458474 }
459- Error :: UnknownForm ( _) => "Found an unknown `DW_FORM_*` type" ,
475+ Error :: UnknownForm ( _) => write ! ( f , "Found an unknown `DW_FORM_*` type" ) ,
460476 Error :: DuplicateAbbreviationCode => {
461- "Found an abbreviation code that has already been used"
462- }
463- Error :: UnknownReservedLength => "Found an unknown reserved length value" ,
464- Error :: UnknownVersion ( _) => "Found an unknown DWARF version" ,
465- Error :: UnknownAbbreviation ( _) => "Found a record with an unknown abbreviation code" ,
466- Error :: UnexpectedEof ( _) => "Hit the end of input before it was expected" ,
467- Error :: UnknownLocListsEntry ( _) => "Found an unknown location lists entry" ,
468- Error :: UnknownRangeListsEntry ( _) => "Found an unknown range lists entry" ,
469- Error :: UnsupportedAddressSize ( _) => "The specified address size is not supported" ,
470- Error :: UnsupportedOffsetSize ( _) => "The specified offset size is not supported" ,
477+ write ! ( f, "Found an abbreviation code that has already been used" )
478+ }
479+ Error :: UnknownReservedLength => write ! ( f, "Found an unknown reserved length value" ) ,
480+ Error :: UnknownVersion ( _) => write ! ( f, "Found an unknown DWARF version" ) ,
481+ Error :: UnknownAbbreviation ( _) => {
482+ write ! ( f, "Found a record with an unknown abbreviation code" )
483+ }
484+ Error :: UnexpectedEof ( _) => write ! ( f, "Hit the end of input before it was expected" ) ,
485+ Error :: UnknownLocListsEntry ( _) => write ! ( f, "Found an unknown location lists entry" ) ,
486+ Error :: UnknownRangeListsEntry ( _) => write ! ( f, "Found an unknown range lists entry" ) ,
487+ Error :: UnsupportedAddressSize ( _) => {
488+ write ! ( f, "The specified address size is not supported" )
489+ }
490+ Error :: UnsupportedOffsetSize ( _) => {
491+ write ! ( f, "The specified offset size is not supported" )
492+ }
471493 Error :: MinimumInstructionLengthZero => {
472- "The minimum instruction length must not be zero."
494+ write ! ( f , "The minimum instruction length must not be zero." )
473495 }
474496 Error :: MaximumOperationsPerInstructionZero => {
475- "The maximum operations per instruction must not be zero."
476- }
477- Error :: LineRangeZero => "The line range must not be zero." ,
478- Error :: OpcodeBaseZero => "The opcode base must not be zero." ,
479- Error :: BadUtf8 => "Found an invalid UTF-8 string." ,
480- Error :: NotCieId => "Expected to find the CIE ID, but found something else." ,
481- Error :: NotCiePointer => "Expected to find a CIE pointer, but found the CIE ID instead." ,
482- Error :: BadBranchTarget ( _) => "Invalid branch target in DWARF expression" ,
497+ write ! (
498+ f,
499+ "The maximum operations per instruction must not be zero."
500+ )
501+ }
502+ Error :: LineRangeZero => write ! ( f, "The line range must not be zero." ) ,
503+ Error :: OpcodeBaseZero => write ! ( f, "The opcode base must not be zero." ) ,
504+ Error :: BadUtf8 => write ! ( f, "Found an invalid UTF-8 string." ) ,
505+ Error :: NotCieId => write ! ( f, "Expected to find the CIE ID, but found something else." ) ,
506+ Error :: NotCiePointer => {
507+ write ! (
508+ f,
509+ "Expected to find a CIE pointer, but found the CIE ID instead." ,
510+ )
511+ }
512+ Error :: BadBranchTarget ( _) => write ! ( f, "Invalid branch target in DWARF expression" ) ,
483513 Error :: InvalidPushObjectAddress => {
484- "DW_OP_push_object_address used but no object address given"
514+ write ! (
515+ f,
516+ "DW_OP_push_object_address used but no object address given"
517+ )
518+ }
519+ Error :: NotEnoughStackItems => {
520+ write ! ( f, "Not enough items on stack when evaluating expression" )
521+ }
522+ Error :: TooManyIterations => {
523+ write ! ( f, "Too many iterations to evaluate DWARF expression" )
524+ }
525+ Error :: InvalidExpression ( _) => write ! ( f, "Invalid opcode in DWARF expression" ) ,
526+ Error :: UnsupportedEvaluation => {
527+ write ! ( f, "Unsupported operation when evaluating expression" )
485528 }
486- Error :: NotEnoughStackItems => "Not enough items on stack when evaluating expression" ,
487- Error :: TooManyIterations => "Too many iterations to evaluate DWARF expression" ,
488- Error :: InvalidExpression ( _) => "Invalid opcode in DWARF expression" ,
489- Error :: UnsupportedEvaluation => "Unsupported operation when evaluating expression" ,
490529 Error :: InvalidPiece => {
491- "DWARF expression has piece followed by non-piece expression at end"
530+ write ! (
531+ f,
532+ "DWARF expression has piece followed by non-piece expression at end"
533+ )
534+ }
535+ Error :: InvalidExpressionTerminator ( _) => {
536+ write ! ( f, "Expected DW_OP_piece or DW_OP_bit_piece" )
537+ }
538+ Error :: DivisionByZero => {
539+ write ! ( f, "Division or modulus by zero when evaluating expression" )
540+ }
541+ Error :: TypeMismatch => write ! ( f, "Type mismatch when evaluating expression" ) ,
542+ Error :: IntegralTypeRequired => {
543+ write ! ( f, "Integral type expected when evaluating expression" )
492544 }
493- Error :: InvalidExpressionTerminator ( _) => "Expected DW_OP_piece or DW_OP_bit_piece" ,
494- Error :: DivisionByZero => "Division or modulus by zero when evaluating expression" ,
495- Error :: TypeMismatch => "Type mismatch when evaluating expression" ,
496- Error :: IntegralTypeRequired => "Integral type expected when evaluating expression" ,
497545 Error :: UnsupportedTypeOperation => {
498- "An expression operation used types that are not supported"
546+ write ! (
547+ f,
548+ "An expression operation used types that are not supported"
549+ )
499550 }
500551 Error :: InvalidShiftExpression => {
501- "The shift value in an expression must be a non-negative integer."
552+ write ! (
553+ f,
554+ "The shift value in an expression must be a non-negative integer."
555+ )
502556 }
503557 Error :: InvalidDerefSize ( _) => {
504- "The size of a deref expression must not be larger than the size of an address."
558+ write ! (
559+ f,
560+ "The size of a deref expression must not be larger than the size of an address."
561+ )
505562 }
506- Error :: UnknownCallFrameInstruction ( _) => "An unknown DW_CFA_* instruction" ,
563+ Error :: UnknownCallFrameInstruction ( _) => write ! ( f , "An unknown DW_CFA_* instruction" ) ,
507564 Error :: InvalidAddressRange => {
508- "The end of an address range must not be before the beginning."
565+ write ! (
566+ f,
567+ "The end of an address range must not be before the beginning."
568+ )
509569 }
510- Error :: AddressOverflow => "An address calculation overflowed." ,
570+ Error :: AddressOverflow => write ! ( f , "An address calculation overflowed." ) ,
511571 Error :: CfiInstructionInInvalidContext => {
512- "Encountered a call frame instruction in a context in which it is not valid."
572+ write ! (
573+ f,
574+ "Encountered a call frame instruction in a context in which it is not valid."
575+ )
513576 }
514577 Error :: PopWithEmptyStack => {
515- "When evaluating call frame instructions, found a `DW_CFA_restore_state` stack pop \
578+ write ! (
579+ f,
580+ "When evaluating call frame instructions, found a `DW_CFA_restore_state` stack pop \
516581 instruction, but the stack was empty, and had nothing to pop."
582+ )
583+ }
584+ Error :: NoUnwindInfoForAddress => {
585+ write ! ( f, "Do not have unwind info for the given address." )
517586 }
518- Error :: NoUnwindInfoForAddress => "Do not have unwind info for the given address." ,
519587 Error :: UnsupportedOffset => {
520- "An offset value was larger than the maximum supported value."
588+ write ! (
589+ f,
590+ "An offset value was larger than the maximum supported value."
591+ )
521592 }
522593 Error :: UnknownPointerEncoding ( _) => {
523- "The given pointer encoding is either unknown or invalid."
524- }
525- Error :: NoEntryAtGivenOffset => "Did not find an entry at the given offset." ,
526- Error :: OffsetOutOfBounds => "The given offset is out of bounds." ,
527- Error :: UnknownAugmentation => "Found an unknown CFI augmentation." ,
594+ write ! (
595+ f,
596+ "The given pointer encoding is either unknown or invalid."
597+ )
598+ }
599+ Error :: NoEntryAtGivenOffset => write ! ( f, "Did not find an entry at the given offset." ) ,
600+ Error :: OffsetOutOfBounds => write ! ( f, "The given offset is out of bounds." ) ,
601+ Error :: UnknownAugmentation => write ! ( f, "Found an unknown CFI augmentation." ) ,
528602 Error :: UnsupportedPointerEncoding => {
529- "We do not support the given pointer encoding yet."
603+ write ! ( f, "We do not support the given pointer encoding yet." )
604+ }
605+ Error :: UnsupportedRegister ( _) => {
606+ write ! ( f, "Registers larger than `u16` are not supported." )
530607 }
531- Error :: UnsupportedRegister ( _) => "Registers larger than `u16` are not supported." ,
532608 Error :: TooManyRegisterRules => {
533- "The CFI program defined more register rules than we have storage for."
609+ write ! (
610+ f,
611+ "The CFI program defined more register rules than we have storage for."
612+ )
534613 }
535614 Error :: StackFull => {
536- "Attempted to push onto the CFI stack, but it was already at full capacity."
615+ write ! (
616+ f,
617+ "Attempted to push onto the CFI stack, but it was already at full capacity."
618+ )
537619 }
538620 Error :: VariableLengthSearchTable => {
539- "The `.eh_frame_hdr` binary search table claims to be variable-length encoded, \
621+ write ! (
622+ f,
623+ "The `.eh_frame_hdr` binary search table claims to be variable-length encoded, \
540624 which makes binary search impossible."
625+ )
626+ }
627+ Error :: UnsupportedUnitType => {
628+ write ! ( f, "The `DW_UT_*` value for this unit is not supported yet" )
541629 }
542- Error :: UnsupportedUnitType => "The `DW_UT_*` value for this unit is not supported yet" ,
543- Error :: UnsupportedSegmentSize => "Nonzero segment size not supported yet" ,
630+ Error :: UnsupportedSegmentSize => write ! ( f, "Nonzero segment size not supported yet" ) ,
544631 Error :: MissingUnitDie => {
545- "A compilation unit or type unit is missing its top level DIE."
632+ write ! (
633+ f,
634+ "A compilation unit or type unit is missing its top level DIE."
635+ )
546636 }
547637 Error :: MissingSplitUnit => {
548- "A split DWARF section does not contain the split compilation unit."
638+ write ! (
639+ f,
640+ "A split DWARF section does not contain the split compilation unit."
641+ )
642+ }
643+ Error :: UnsupportedAttributeForm => {
644+ write ! ( f, "A DIE attribute used an unsupported form." )
645+ }
646+ Error :: MissingFileEntryFormatPath => {
647+ write ! ( f, "Missing DW_LNCT_path in file entry format." )
549648 }
550- Error :: UnsupportedAttributeForm => "A DIE attribute used an unsupported form." ,
551- Error :: MissingFileEntryFormatPath => "Missing DW_LNCT_path in file entry format." ,
552649 Error :: ExpectedStringAttributeValue => {
553- "Expected an attribute value to be a string form."
554- }
555- Error :: InvalidImplicitConst => "DW_FORM_implicit_const used in an invalid context." ,
556- Error :: InvalidIndexSectionCount => "Invalid section count in `.dwp` index." ,
557- Error :: InvalidIndexSlotCount => "Invalid slot count in `.dwp` index." ,
558- Error :: InvalidIndexRow => "Invalid hash row in `.dwp` index." ,
559- Error :: UnknownIndexSection ( _) => "Unknown section type in `.dwp` index." ,
560- Error :: UnknownIndexSectionV2 ( _) => "Unknown section type in version 2 `.dwp` index." ,
561- Error :: InvalidMacinfoType ( _) => "Invalid macinfo type in `.debug_macinfo`." ,
562- Error :: InvalidMacroType ( _) => "Invalid macro type in `.debug_macro`." ,
650+ write ! ( f, "Expected an attribute value to be a string form." )
651+ }
652+ Error :: InvalidImplicitConst => {
653+ write ! ( f, "DW_FORM_implicit_const used in an invalid context." )
654+ }
655+ Error :: InvalidIndexSectionCount => write ! ( f, "Invalid section count in `.dwp` index." ) ,
656+ Error :: InvalidIndexSlotCount => write ! ( f, "Invalid slot count in `.dwp` index." ) ,
657+ Error :: InvalidIndexRow => write ! ( f, "Invalid hash row in `.dwp` index." ) ,
658+ Error :: UnknownIndexSection ( _) => write ! ( f, "Unknown section type in `.dwp` index." ) ,
659+ Error :: UnknownIndexSectionV2 ( _) => {
660+ write ! ( f, "Unknown section type in version 2 `.dwp` index." )
661+ }
662+ Error :: InvalidMacinfoType ( _) => write ! ( f, "Invalid macinfo type in `.debug_macinfo`." ) ,
663+ Error :: InvalidMacroType ( _) => write ! ( f, "Invalid macro type in `.debug_macro`." ) ,
563664 Error :: UnsupportedOpcodeOperandsTable => {
564- "The optional `opcode_operands_table` in `.debug_macro` is currently not supported."
665+ write ! (
666+ f,
667+ "The optional `opcode_operands_table` in `.debug_macro` is currently not supported."
668+ )
565669 }
566670 Error :: InvalidNameAttributeIndex ( _) => {
567- "Invalid index in a `.debug_names` attribute value."
671+ write ! ( f , "Invalid index in a `.debug_names` attribute value." )
568672 }
569673 }
570674 }
0 commit comments