pub fn trace(
    device_memory: DeviceMemory<u32>,
    elf_data: &[u8],
) -> Result<Vec<Frame<u32>>, TraceError> {
    let mut frames = Vec::new();

    let elf = addr2line::object::File::parse(elf_data)?;
    // Get the elf file context
    let mut context = UnwindingContext::create(elf, device_memory)?;

    // Keep looping until we've got the entire trace
    loop {
        context.find_current_frames(&mut frames)?;

        let (unwind_frame, unwinding_left) = context.try_unwind(frames.last_mut())?;

        if let Some(unwind_frame) = unwind_frame {
            frames.push(unwind_frame);
        }

        if !unwinding_left {
            break;
        }
    }

    // Get the static data
    let static_variables = variables::find_static_variables(
        context.addr2line_context.dwarf(),
        &context.device_memory,
    )?;
    let static_frame = Frame {
        function: "Static".into(),
        location: Location {
            file: None,
            line: None,
            column: None,
        },
        frame_type: FrameType::Static,
        variables: static_variables,
    };
    frames.push(static_frame);

    Ok(frames)
}
/// Create the stacktrace for the cortex m target.
///
/// - device_memory: All the captured memory of the device.
/// It is not necessary to include any data that is present in the elf file because that will automatically be added.
/// It is required to have a decent chunk of the stack present. If not all of the stack is present,
/// then the eventually the tracing procedure will find a corrupt frame.
/// The standard set of registers is also required to be present.
/// - elf_data: The raw bytes of the elf file.
/// This must be the exact same elf file as the one the device was running. Even a recompilation of the exact same code can change the debug info.
Create the stacktrace for the cortex m target.
device_memory: All the captured memory of the device.
It is not necessary to include any data that is present in the elf file because that will automatically be added.
It is required to have a decent chunk of the stack present. If not all of the stack is present,
then the eventually the tracing procedure will find a corrupt frame.
The standard set of registers is also required to be present.
elf_data: The raw bytes of the elf file.
This must be the exact same elf file as the one the device was running. Even a recompilation of the exact same code can change the debug info.
Create the stacktrace for the cortex m target . device_memory : All the captured memory of the device . It is not necessary to include any data that is present in the elf file because that will automatically be added . It is required to have a decent chunk of the stack present . If not all of the stack is present then the eventually the tracing procedure will find a corrupt frame . The standard set of registers is also required to be present . elf_data : The raw bytes of the elf file . This must be the exact same elf file as the one the device was running . Even a recompilation of the exact same code can change the debug info .
pub fn trace(
    device_memory: DeviceMemory<u32>,
    elf_data: &[u8],
) -> Result<Vec<Frame<u32>>, TraceError> {
    let mut frames = Vec::new();
    let elf = addr2line::object::File::parse(elf_data)?;
    // Get the elf file context
    let mut context = UnwindingContext::create(elf, device_memory)?;
    // Keep looping until we've got the entire trace
    loop {
        context.find_current_frames(&mut frames)?;
        let (unwind_frame, unwinding_left) = context.try_unwind(frames.last_mut())?;
        if let Some(unwind_frame) = unwind_frame {
            frames.push(unwind_frame);
        }
        if !unwinding_left {
            break;
        }
    }
    // Get the static data
    let static_variables = variables::find_static_variables(
        context.addr2line_context.dwarf(),
        &context.device_memory,
    )?;
    let static_frame = Frame {
        function: "Static".into(),
        location: Location {
            file: None,
            line: None,
            column: None,
        },
        frame_type: FrameType::Static,
        variables: static_variables,
    };
    frames.push(static_frame);
    Ok(frames)
}
pub fn trace ( device_memory : DeviceMemory < u32 > , elf_data : & [ u8 ] , ) -> Result < Vec < Frame < u32 > > , TraceError > { let mut frames = Vec :: new ( ) ; let elf = addr2line :: object :: File :: parse ( elf_data ) ? ; // Get the elf file context let mut context = UnwindingContext :: create ( elf , device_memory ) ? ; // Keep looping until we've got the entire trace loop { context . find_current_frames ( & mut frames ) ? ; let ( unwind_frame , unwinding_left ) = context . try_unwind ( frames . last_mut ( ) ) ? ; if let Some ( unwind_frame ) = unwind_frame { frames . push ( unwind_frame ) ; } if ! unwinding_left { break ; } } // Get the static data let static_variables = variables :: find_static_variables ( context . addr2line_context . dwarf ( ) , & context . device_memory , ) ? ; let static_frame = Frame { function : " " . into ( ) , location : Location { file : None , line : None , column : None , } , frame_type : FrameType :: Static , variables : static_variables , } ; frames . push ( static_frame ) ; Ok ( frames ) }
Create the stacktrace for the cortex m target.
Create the stacktrace for the cortex m target .
device_memory
DeviceMemory<u32>
elf_data
&[u8]
device_memory
DeviceMemory<u32>
elf_data
&[u8]