diff --git a/src/read/cfi.rs b/src/read/cfi.rs index 71dedb0b..6e9bb87c 100644 --- a/src/read/cfi.rs +++ b/src/read/cfi.rs @@ -1898,9 +1898,9 @@ You may want to supply your own storage type for one of the following reasons: /// # /// struct StoreOnStack; /// -/// impl UnwindContextStorage for StoreOnStack { -/// type Rules = [(Register, RegisterRule); 192]; -/// type Stack = [UnwindTableRow; 4]; +/// impl UnwindContextStorage for StoreOnStack { +/// type Rules = [(Register, RegisterRule); 192]; +/// type Stack = [UnwindTableRow; 4]; /// } /// /// let mut ctx = UnwindContext::<_, StoreOnStack>::new_in(); @@ -1915,14 +1915,14 @@ You may want to supply your own storage type for one of the following reasons: /// # unreachable!() /// # } /// ``` -pub trait UnwindContextStorage: Sized { +pub trait UnwindContextStorage: Sized { /// The storage used for register rules in a unwind table row. /// /// Note that this is nested within the stack. - type Rules: ArrayLike)>; + type Rules: ArrayLike)>; /// The storage used for unwind table row stack. - type Stack: ArrayLike>; + type Stack: ArrayLike>; } #[cfg(feature = "read")] @@ -1931,9 +1931,9 @@ const MAX_RULES: usize = 192; const MAX_UNWIND_STACK_DEPTH: usize = 4; #[cfg(feature = "read")] -impl UnwindContextStorage for StoreOnHeap { - type Rules = [(Register, RegisterRule); MAX_RULES]; - type Stack = Box<[UnwindTableRow; MAX_UNWIND_STACK_DEPTH]>; +impl UnwindContextStorage for StoreOnHeap { + type Rules = [(Register, RegisterRule); MAX_RULES]; + type Stack = Box<[UnwindTableRow; MAX_UNWIND_STACK_DEPTH]>; } /// Common context needed when evaluating the call frame unwinding information. @@ -1970,7 +1970,7 @@ impl UnwindContextStorage for StoreOnHeap { /// # } /// ``` #[derive(Clone, PartialEq, Eq)] -pub struct UnwindContext = StoreOnHeap> { +pub struct UnwindContext = StoreOnHeap> { // Stack of rows. The last row is the row currently being built by the // program. There is always at least one row. The vast majority of CFI // programs will only ever have one row on the stack. @@ -1984,12 +1984,12 @@ pub struct UnwindContext = StoreOnHe // `DW_CFA_restore`. Otherwise, when we are currently evaluating a CIE's // initial instructions, `is_initialized` will be `false` and initial rules // cannot be read. - initial_rule: Option<(Register, RegisterRule)>, + initial_rule: Option<(Register, RegisterRule)>, is_initialized: bool, } -impl> Debug for UnwindContext { +impl> Debug for UnwindContext { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("UnwindContext") .field("stack", &self.stack) @@ -1999,14 +1999,14 @@ impl> Debug for UnwindContext } } -impl> Default for UnwindContext { +impl> Default for UnwindContext { fn default() -> Self { Self::new_in() } } #[cfg(feature = "read")] -impl UnwindContext { +impl UnwindContext { /// Construct a new call frame unwinding context. pub fn new() -> Self { Self::new_in() @@ -2515,11 +2515,11 @@ impl<'a, 'ctx, R: Reader, A: UnwindContextStorage> UnwindTable<'a, 'c // - https://github.com/libunwind/libunwind/blob/11fd461095ea98f4b3e3a361f5a8a558519363fa/include/tdep-aarch64/dwarf-config.h#L32 // - https://github.com/libunwind/libunwind/blob/11fd461095ea98f4b3e3a361f5a8a558519363fa/include/tdep-arm/dwarf-config.h#L31 // - https://github.com/libunwind/libunwind/blob/11fd461095ea98f4b3e3a361f5a8a558519363fa/include/tdep-mips/dwarf-config.h#L31 -struct RegisterRuleMap = StoreOnHeap> { +struct RegisterRuleMap = StoreOnHeap> { rules: ArrayVec, } -impl> Debug for RegisterRuleMap { +impl> Debug for RegisterRuleMap { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RegisterRuleMap") .field("rules", &self.rules) @@ -2527,7 +2527,7 @@ impl> Debug for RegisterRuleMap> Clone for RegisterRuleMap { +impl> Clone for RegisterRuleMap { fn clone(&self) -> Self { Self { rules: self.rules.clone(), @@ -2535,7 +2535,7 @@ impl> Clone for RegisterRuleMap> Default for RegisterRuleMap { +impl> Default for RegisterRuleMap { fn default() -> Self { RegisterRuleMap { rules: Default::default(), @@ -2547,12 +2547,12 @@ impl> Default for RegisterRuleMap> RegisterRuleMap { +impl> RegisterRuleMap { fn is_default(&self) -> bool { self.rules.is_empty() } - fn get(&self, register: Register) -> RegisterRule { + fn get(&self, register: Register) -> RegisterRule { self.rules .iter() .find(|rule| rule.0 == register) @@ -2563,7 +2563,7 @@ impl> RegisterRuleMap { .unwrap_or(RegisterRule::Undefined) } - fn set(&mut self, register: Register, rule: RegisterRule) -> Result<()> { + fn set(&mut self, register: Register, rule: RegisterRule) -> Result<()> { if !rule.is_defined() { let idx = self .rules @@ -2590,7 +2590,7 @@ impl> RegisterRuleMap { .map_err(|_| Error::TooManyRegisterRules) } - fn iter(&self) -> RegisterRuleIter { + fn iter(&self) -> RegisterRuleIter { RegisterRuleIter(self.rules.iter()) } } @@ -2616,9 +2616,9 @@ where } } -impl> PartialEq for RegisterRuleMap +impl> PartialEq for RegisterRuleMap where - R: ReaderOffset + PartialEq, + O: ReaderOffset + PartialEq, { fn eq(&self, rhs: &Self) -> bool { for &(reg, ref rule) in &*self.rules { @@ -2639,16 +2639,16 @@ where } } -impl> Eq for RegisterRuleMap where R: ReaderOffset + Eq {} +impl> Eq for RegisterRuleMap where O: ReaderOffset + Eq {} /// An unordered iterator for register rules. #[derive(Debug, Clone)] -pub struct RegisterRuleIter<'iter, R>(::core::slice::Iter<'iter, (Register, RegisterRule)>) +pub struct RegisterRuleIter<'iter, O>(::core::slice::Iter<'iter, (Register, RegisterRule)>) where - R: ReaderOffset; + O: ReaderOffset; -impl<'iter, R: ReaderOffset> Iterator for RegisterRuleIter<'iter, R> { - type Item = &'iter (Register, RegisterRule); +impl<'iter, O: ReaderOffset> Iterator for RegisterRuleIter<'iter, O> { + type Item = &'iter (Register, RegisterRule); fn next(&mut self) -> Option { self.0.next() @@ -2658,15 +2658,15 @@ impl<'iter, R: ReaderOffset> Iterator for RegisterRuleIter<'iter, R> { /// A row in the virtual unwind table that describes how to find the values of /// the registers in the *previous* frame for a range of PC addresses. #[derive(PartialEq, Eq)] -pub struct UnwindTableRow = StoreOnHeap> { +pub struct UnwindTableRow = StoreOnHeap> { start_address: u64, end_address: u64, saved_args_size: u64, - cfa: CfaRule, - registers: RegisterRuleMap, + cfa: CfaRule, + registers: RegisterRuleMap, } -impl> Debug for UnwindTableRow { +impl> Debug for UnwindTableRow { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("UnwindTableRow") .field("start_address", &self.start_address) @@ -2678,7 +2678,7 @@ impl> Debug for UnwindTableRow } } -impl> Clone for UnwindTableRow { +impl> Clone for UnwindTableRow { fn clone(&self) -> Self { Self { start_address: self.start_address, @@ -2690,7 +2690,7 @@ impl> Clone for UnwindTableRow } } -impl> Default for UnwindTableRow { +impl> Default for UnwindTableRow { fn default() -> Self { UnwindTableRow { start_address: 0, @@ -2702,7 +2702,7 @@ impl> Default for UnwindTableRow> UnwindTableRow { +impl> UnwindTableRow { fn is_default(&self) -> bool { self.start_address == 0 && self.end_address == 0 @@ -2741,7 +2741,7 @@ impl> UnwindTableRow { } /// Get the canonical frame address (CFA) recovery rule for this row. - pub fn cfa(&self) -> &CfaRule { + pub fn cfa(&self) -> &CfaRule { &self.cfa } @@ -2789,7 +2789,7 @@ impl> UnwindTableRow { /// > Vector Mask Registers 0–7 118-125 %k0–%k7 /// > Reserved 126-129 /// > - pub fn register(&self, register: Register) -> RegisterRule { + pub fn register(&self, register: Register) -> RegisterRule { self.registers.get(register) } @@ -2808,14 +2808,14 @@ impl> UnwindTableRow { /// } /// # } /// ``` - pub fn registers(&self) -> RegisterRuleIter { + pub fn registers(&self) -> RegisterRuleIter { self.registers.iter() } } /// The canonical frame address (CFA) recovery rules. #[derive(Clone, Debug, PartialEq, Eq)] -pub enum CfaRule { +pub enum CfaRule { /// The CFA is given offset from the given register's value. RegisterAndOffset { /// The register containing the base value. @@ -2825,10 +2825,10 @@ pub enum CfaRule { }, /// The CFA is obtained by evaluating this `Reader` as a DWARF expression /// program. - Expression(UnwindExpression), + Expression(UnwindExpression), } -impl Default for CfaRule { +impl Default for CfaRule { fn default() -> Self { CfaRule::RegisterAndOffset { register: Register(0), @@ -2837,7 +2837,7 @@ impl Default for CfaRule { } } -impl CfaRule { +impl CfaRule { fn is_default(&self) -> bool { match *self { CfaRule::RegisterAndOffset { register, offset } => { @@ -2856,7 +2856,7 @@ impl CfaRule { /// previous frame." #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] -pub enum RegisterRule { +pub enum RegisterRule { /// > A register that has this rule has no recoverable value in the previous /// > frame. (By convention, it is not preserved by a callee.) Undefined, @@ -2880,11 +2880,11 @@ pub enum RegisterRule { /// "The previous value of this register is located at the address produced /// by executing the DWARF expression." - Expression(UnwindExpression), + Expression(UnwindExpression), /// "The previous value of this register is the value produced by executing /// the DWARF expression." - ValExpression(UnwindExpression), + ValExpression(UnwindExpression), /// "The rule is defined externally to this specification by the augmenter." Architectural, @@ -2893,7 +2893,7 @@ pub enum RegisterRule { Constant(u64), } -impl RegisterRule { +impl RegisterRule { fn is_defined(&self) -> bool { !matches!(*self, RegisterRule::Undefined) } @@ -2902,7 +2902,7 @@ impl RegisterRule { /// A parsed call frame instruction. #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] -pub enum CallFrameInstruction { +pub enum CallFrameInstruction { // 6.4.2.1 Row Creation Methods /// > 1. DW_CFA_set_loc /// > @@ -3007,7 +3007,7 @@ pub enum CallFrameInstruction { /// > means by which the current CFA is computed. DefCfaExpression { /// The location of the DWARF expression. - expression: UnwindExpression, + expression: UnwindExpression, }, // 6.4.2.3 Register Rule Instructions @@ -3118,7 +3118,7 @@ pub enum CallFrameInstruction { /// The target register's number. register: Register, /// The location of the DWARF expression. - expression: UnwindExpression, + expression: UnwindExpression, }, /// > 10. DW_CFA_val_expression @@ -3135,7 +3135,7 @@ pub enum CallFrameInstruction { /// The target register's number. register: Register, /// The location of the DWARF expression. - expression: UnwindExpression, + expression: UnwindExpression, }, /// The `Restore` instruction represents both `DW_CFA_restore` and