fn update_registers_with_exception_stack(&mut self, fpu: bool) -> Result<(), TraceError> {
        let current_sp = self.device_memory.register(gimli::Arm::SP)?;

        fn read_stack_var(
            device_memory: &DeviceMemory<u32>,
            starting_sp: u32,
            index: usize,
        ) -> Result<u32, TraceError> {
            device_memory
                .read_u32(starting_sp as u64 + index as u64 * 4, RunTimeEndian::Little)
                .ok_or(TraceError::MissingMemory(
                    starting_sp as u64 + index as u64 * 4,
                ))
        }

        *self.device_memory.register_mut(gimli::Arm::R0)? =
            read_stack_var(&self.device_memory, current_sp, 0)?;
        *self.device_memory.register_mut(gimli::Arm::R1)? =
            read_stack_var(&self.device_memory, current_sp, 1)?;
        *self.device_memory.register_mut(gimli::Arm::R2)? =
            read_stack_var(&self.device_memory, current_sp, 2)?;
        *self.device_memory.register_mut(gimli::Arm::R3)? =
            read_stack_var(&self.device_memory, current_sp, 3)?;
        *self.device_memory.register_mut(gimli::Arm::R12)? =
            read_stack_var(&self.device_memory, current_sp, 4)?;
        *self.device_memory.register_mut(gimli::Arm::LR)? =
            read_stack_var(&self.device_memory, current_sp, 5)?;
        *self.device_memory.register_mut(gimli::Arm::PC)? =
            read_stack_var(&self.device_memory, current_sp, 6)?;
        // At stack place 7 is the PSR register, but we don't need that, so we skip it

        // Adjust the sp with the size of what we've read
        *self.device_memory.register_mut(gimli::Arm::SP)? =
            self.device_memory.register(gimli::Arm::SP)? + 8 * std::mem::size_of::<u32>() as u32;

        if fpu {
            *self.device_memory.register_mut(gimli::Arm::D0)? =
                read_stack_var(&self.device_memory, current_sp, 8)?;
            *self.device_memory.register_mut(gimli::Arm::D1)? =
                read_stack_var(&self.device_memory, current_sp, 9)?;
            *self.device_memory.register_mut(gimli::Arm::D2)? =
                read_stack_var(&self.device_memory, current_sp, 10)?;
            *self.device_memory.register_mut(gimli::Arm::D3)? =
                read_stack_var(&self.device_memory, current_sp, 11)?;
            *self.device_memory.register_mut(gimli::Arm::D4)? =
                read_stack_var(&self.device_memory, current_sp, 12)?;
            *self.device_memory.register_mut(gimli::Arm::D5)? =
                read_stack_var(&self.device_memory, current_sp, 13)?;
            *self.device_memory.register_mut(gimli::Arm::D6)? =
                read_stack_var(&self.device_memory, current_sp, 14)?;
            *self.device_memory.register_mut(gimli::Arm::D7)? =
                read_stack_var(&self.device_memory, current_sp, 15)?;
            *self.device_memory.register_mut(gimli::Arm::D8)? =
                read_stack_var(&self.device_memory, current_sp, 16)?;
            *self.device_memory.register_mut(gimli::Arm::D9)? =
                read_stack_var(&self.device_memory, current_sp, 17)?;
            *self.device_memory.register_mut(gimli::Arm::D10)? =
                read_stack_var(&self.device_memory, current_sp, 18)?;
            *self.device_memory.register_mut(gimli::Arm::D11)? =
                read_stack_var(&self.device_memory, current_sp, 19)?;
            *self.device_memory.register_mut(gimli::Arm::D12)? =
                read_stack_var(&self.device_memory, current_sp, 20)?;
            *self.device_memory.register_mut(gimli::Arm::D13)? =
                read_stack_var(&self.device_memory, current_sp, 21)?;
            *self.device_memory.register_mut(gimli::Arm::D14)? =
                read_stack_var(&self.device_memory, current_sp, 22)?;
            *self.device_memory.register_mut(gimli::Arm::D15)? =
                read_stack_var(&self.device_memory, current_sp, 23)?;
            // At stack place 24 is the fpscr register, but we don't need that, so we skip it

            // Adjust the sp with the size of what we've read
            *self.device_memory.register_mut(gimli::Arm::SP)? =
                self.device_memory.register(gimli::Arm::SP)?
                    + 17 * std::mem::size_of::<u32>() as u32;
        }

        Ok(())
    }
/// Assumes we are at an exception point in the stack unwinding.
/// Reads the registers that were stored on the stack and updates our current register representation with it.
///
/// Returns Ok if everything went fine or an error with an address if the stack could not be read
Assumes we are at an exception point in the stack unwinding.
Reads the registers that were stored on the stack and updates our current register representation with it.

Returns Ok if everything went fine or an error with an address if the stack could not be read
Assumes we are at an exception point in the stack unwinding . Reads the registers that were stored on the stack and updates our current register representation with it . Returns Ok if everything went fine or an error with an address if the stack could not be read
fn update_registers_with_exception_stack(&mut self, fpu: bool) -> Result<(), TraceError> {
        let current_sp = self.device_memory.register(gimli::Arm::SP)?;
        fn read_stack_var(
            device_memory: &DeviceMemory<u32>,
            starting_sp: u32,
            index: usize,
        ) -> Result<u32, TraceError> {
            device_memory
                .read_u32(starting_sp as u64 + index as u64 * 4, RunTimeEndian::Little)
                .ok_or(TraceError::MissingMemory(
                    starting_sp as u64 + index as u64 * 4,
                ))
        }
        *self.device_memory.register_mut(gimli::Arm::R0)? =
            read_stack_var(&self.device_memory, current_sp, 0)?;
        *self.device_memory.register_mut(gimli::Arm::R1)? =
            read_stack_var(&self.device_memory, current_sp, 1)?;
        *self.device_memory.register_mut(gimli::Arm::R2)? =
            read_stack_var(&self.device_memory, current_sp, 2)?;
        *self.device_memory.register_mut(gimli::Arm::R3)? =
            read_stack_var(&self.device_memory, current_sp, 3)?;
        *self.device_memory.register_mut(gimli::Arm::R12)? =
            read_stack_var(&self.device_memory, current_sp, 4)?;
        *self.device_memory.register_mut(gimli::Arm::LR)? =
            read_stack_var(&self.device_memory, current_sp, 5)?;
        *self.device_memory.register_mut(gimli::Arm::PC)? =
            read_stack_var(&self.device_memory, current_sp, 6)?;
        // At stack place 7 is the PSR register, but we don't need that, so we skip it
        // Adjust the sp with the size of what we've read
        *self.device_memory.register_mut(gimli::Arm::SP)? =
            self.device_memory.register(gimli::Arm::SP)? + 8 * std::mem::size_of::<u32>() as u32;
        if fpu {
            *self.device_memory.register_mut(gimli::Arm::D0)? =
                read_stack_var(&self.device_memory, current_sp, 8)?;
            *self.device_memory.register_mut(gimli::Arm::D1)? =
                read_stack_var(&self.device_memory, current_sp, 9)?;
            *self.device_memory.register_mut(gimli::Arm::D2)? =
                read_stack_var(&self.device_memory, current_sp, 10)?;
            *self.device_memory.register_mut(gimli::Arm::D3)? =
                read_stack_var(&self.device_memory, current_sp, 11)?;
            *self.device_memory.register_mut(gimli::Arm::D4)? =
                read_stack_var(&self.device_memory, current_sp, 12)?;
            *self.device_memory.register_mut(gimli::Arm::D5)? =
                read_stack_var(&self.device_memory, current_sp, 13)?;
            *self.device_memory.register_mut(gimli::Arm::D6)? =
                read_stack_var(&self.device_memory, current_sp, 14)?;
            *self.device_memory.register_mut(gimli::Arm::D7)? =
                read_stack_var(&self.device_memory, current_sp, 15)?;
            *self.device_memory.register_mut(gimli::Arm::D8)? =
                read_stack_var(&self.device_memory, current_sp, 16)?;
            *self.device_memory.register_mut(gimli::Arm::D9)? =
                read_stack_var(&self.device_memory, current_sp, 17)?;
            *self.device_memory.register_mut(gimli::Arm::D10)? =
                read_stack_var(&self.device_memory, current_sp, 18)?;
            *self.device_memory.register_mut(gimli::Arm::D11)? =
                read_stack_var(&self.device_memory, current_sp, 19)?;
            *self.device_memory.register_mut(gimli::Arm::D12)? =
                read_stack_var(&self.device_memory, current_sp, 20)?;
            *self.device_memory.register_mut(gimli::Arm::D13)? =
                read_stack_var(&self.device_memory, current_sp, 21)?;
            *self.device_memory.register_mut(gimli::Arm::D14)? =
                read_stack_var(&self.device_memory, current_sp, 22)?;
            *self.device_memory.register_mut(gimli::Arm::D15)? =
                read_stack_var(&self.device_memory, current_sp, 23)?;
            // At stack place 24 is the fpscr register, but we don't need that, so we skip it
            // Adjust the sp with the size of what we've read
            *self.device_memory.register_mut(gimli::Arm::SP)? =
                self.device_memory.register(gimli::Arm::SP)?
                    + 17 * std::mem::size_of::<u32>() as u32;
        }
        Ok(())
    }
fn update_registers_with_exception_stack ( & mut self , fpu : bool ) -> Result < ( ) , TraceError > { let current_sp = self . device_memory . register ( gimli :: Arm :: SP ) ? ; fn read_stack_var ( device_memory : & DeviceMemory < u32 > , starting_sp : u32 , index : usize , ) -> Result < u32 , TraceError > { device_memory . read_u32 ( starting_sp as u64 + index as u64 * 4 , RunTimeEndian :: Little ) . ok_or ( TraceError :: MissingMemory ( starting_sp as u64 + index as u64 * 4 , ) ) } * self . device_memory . register_mut ( gimli :: Arm :: R0 ) ? = read_stack_var ( & self . device_memory , current_sp , 0 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: R1 ) ? = read_stack_var ( & self . device_memory , current_sp , 1 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: R2 ) ? = read_stack_var ( & self . device_memory , current_sp , 2 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: R3 ) ? = read_stack_var ( & self . device_memory , current_sp , 3 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: R12 ) ? = read_stack_var ( & self . device_memory , current_sp , 4 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: LR ) ? = read_stack_var ( & self . device_memory , current_sp , 5 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: PC ) ? = read_stack_var ( & self . device_memory , current_sp , 6 ) ? ; // At stack place 7 is the PSR register, but we don't need that, so we skip it // Adjust the sp with the size of what we've read * self . device_memory . register_mut ( gimli :: Arm :: SP ) ? = self . device_memory . register ( gimli :: Arm :: SP ) ? + 8 * std :: mem :: size_of :: < u32 > ( ) as u32 ; if fpu { * self . device_memory . register_mut ( gimli :: Arm :: D0 ) ? = read_stack_var ( & self . device_memory , current_sp , 8 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D1 ) ? = read_stack_var ( & self . device_memory , current_sp , 9 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D2 ) ? = read_stack_var ( & self . device_memory , current_sp , 10 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D3 ) ? = read_stack_var ( & self . device_memory , current_sp , 11 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D4 ) ? = read_stack_var ( & self . device_memory , current_sp , 12 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D5 ) ? = read_stack_var ( & self . device_memory , current_sp , 13 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D6 ) ? = read_stack_var ( & self . device_memory , current_sp , 14 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D7 ) ? = read_stack_var ( & self . device_memory , current_sp , 15 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D8 ) ? = read_stack_var ( & self . device_memory , current_sp , 16 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D9 ) ? = read_stack_var ( & self . device_memory , current_sp , 17 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D10 ) ? = read_stack_var ( & self . device_memory , current_sp , 18 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D11 ) ? = read_stack_var ( & self . device_memory , current_sp , 19 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D12 ) ? = read_stack_var ( & self . device_memory , current_sp , 20 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D13 ) ? = read_stack_var ( & self . device_memory , current_sp , 21 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D14 ) ? = read_stack_var ( & self . device_memory , current_sp , 22 ) ? ; * self . device_memory . register_mut ( gimli :: Arm :: D15 ) ? = read_stack_var ( & self . device_memory , current_sp , 23 ) ? ; // At stack place 24 is the fpscr register, but we don't need that, so we skip it // Adjust the sp with the size of what we've read * self . device_memory . register_mut ( gimli :: Arm :: SP ) ? = self . device_memory . register ( gimli :: Arm :: SP ) ? + 17 * std :: mem :: size_of :: < u32 > ( ) as u32 ; } Ok ( ( ) ) }
Assumes we are at an exception point in the stack unwinding.
Assumes we are at an exception point in the stack unwinding .
&mut self
fpu
bool
&mut self
fpu
bool