fn handle_breakpoint(
    bkpt: &Breakpoint,
    core: &mut Core,
    measurements: &mut Vec<MeasurementResult>,
    current_hw_bkpt: &mut u32,
    app: &AppInfo,
) -> Result<LoopAction> {
    let status = match bkpt {
        // On ReplayStart the loop is complete
        Breakpoint::Other(OtherBreakpoint::ReplayStart) => LoopAction::Break,
        // Save the name and continue to the next loop iteration
        Breakpoint::Other(OtherBreakpoint::InsideTask) => {
            let name = read_breakpoint_task_name(core, &app.subprograms)?;
            let (b, _, u) = measurements.pop().unwrap();
            measurements.push((b, name, u));

            LoopAction::Continue
        }
        // Save the name and continue to the next loop iteration
        Breakpoint::Other(OtherBreakpoint::InsideLock) => {
            let name = read_breakpoint_lock_name(core, &app.resource_locks)?;
            let (b, _, u) = measurements.pop().unwrap();
            measurements.push((b, name, u));

            LoopAction::Continue
        }
        // If inside a hardware read, set hardware breakpoint before exiting the reading
        Breakpoint::Other(OtherBreakpoint::InsideHardwareRead) => {
            // Get all vcells in range of this lock and update vcell_stack
            if let Some(mut current_vcell) = get_current_vcell_from_lr(core, &app.vcells)? {
                if current_vcell.ranges.is_empty() {
                    return Err(anyhow!("Subroutine has no address ranges"));
                }
                let (_, high_pc) = current_vcell.ranges.pop().unwrap();
                *current_hw_bkpt = high_pc as u32;
                core.set_hw_breakpoint(*current_hw_bkpt)?;
            }

            LoopAction::Continue
        }
        // Ignore everything else for now
        _ => LoopAction::Nothing,
    };
    Ok(status)
}
/// Executes the necessary actions for each valid breakpoint. Measures the cycle count and gets the
/// name for all breakpoints and stores the result. Also sets a HW breakpoint if inside a hardware
/// read.
Executes the necessary actions for each valid breakpoint. Measures the cycle count and gets the
name for all breakpoints and stores the result. Also sets a HW breakpoint if inside a hardware
read.
Executes the necessary actions for each valid breakpoint . Measures the cycle count and gets the name for all breakpoints and stores the result . Also sets a HW breakpoint if inside a hardware read .
fn handle_breakpoint(
    bkpt: &Breakpoint,
    core: &mut Core,
    measurements: &mut Vec<MeasurementResult>,
    current_hw_bkpt: &mut u32,
    app: &AppInfo,
) -> Result<LoopAction> {
    let status = match bkpt {
        // On ReplayStart the loop is complete
        Breakpoint::Other(OtherBreakpoint::ReplayStart) => LoopAction::Break,
        // Save the name and continue to the next loop iteration
        Breakpoint::Other(OtherBreakpoint::InsideTask) => {
            let name = read_breakpoint_task_name(core, &app.subprograms)?;
            let (b, _, u) = measurements.pop().unwrap();
            measurements.push((b, name, u));
            LoopAction::Continue
        }
        // Save the name and continue to the next loop iteration
        Breakpoint::Other(OtherBreakpoint::InsideLock) => {
            let name = read_breakpoint_lock_name(core, &app.resource_locks)?;
            let (b, _, u) = measurements.pop().unwrap();
            measurements.push((b, name, u));
            LoopAction::Continue
        }
        // If inside a hardware read, set hardware breakpoint before exiting the reading
        Breakpoint::Other(OtherBreakpoint::InsideHardwareRead) => {
            // Get all vcells in range of this lock and update vcell_stack
            if let Some(mut current_vcell) = get_current_vcell_from_lr(core, &app.vcells)? {
                if current_vcell.ranges.is_empty() {
                    return Err(anyhow!("Subroutine has no address ranges"));
                }
                let (_, high_pc) = current_vcell.ranges.pop().unwrap();
                *current_hw_bkpt = high_pc as u32;
                core.set_hw_breakpoint(*current_hw_bkpt)?;
            }
            LoopAction::Continue
        }
        // Ignore everything else for now
        _ => LoopAction::Nothing,
    };
    Ok(status)
}
fn handle_breakpoint ( bkpt : & Breakpoint , core : & mut Core , measurements : & mut Vec < MeasurementResult > , current_hw_bkpt : & mut u32 , app : & AppInfo , ) -> Result < LoopAction > { let status = match bkpt { // On ReplayStart the loop is complete Breakpoint :: Other ( OtherBreakpoint :: ReplayStart ) => LoopAction :: Break , // Save the name and continue to the next loop iteration Breakpoint :: Other ( OtherBreakpoint :: InsideTask ) => { let name = read_breakpoint_task_name ( core , & app . subprograms ) ? ; let ( b , _ , u ) = measurements . pop ( ) . unwrap ( ) ; measurements . push ( ( b , name , u ) ) ; LoopAction :: Continue } // Save the name and continue to the next loop iteration Breakpoint :: Other ( OtherBreakpoint :: InsideLock ) => { let name = read_breakpoint_lock_name ( core , & app . resource_locks ) ? ; let ( b , _ , u ) = measurements . pop ( ) . unwrap ( ) ; measurements . push ( ( b , name , u ) ) ; LoopAction :: Continue } // If inside a hardware read, set hardware breakpoint before exiting the reading Breakpoint :: Other ( OtherBreakpoint :: InsideHardwareRead ) => { // Get all vcells in range of this lock and update vcell_stack if let Some ( mut current_vcell ) = get_current_vcell_from_lr ( core , & app . vcells ) ? { if current_vcell . ranges . is_empty ( ) { return Err ( anyhow ! ( " " ) ) ; } let ( _ , high_pc ) = current_vcell . ranges . pop ( ) . unwrap ( ) ; * current_hw_bkpt = high_pc as u32 ; core . set_hw_breakpoint ( * current_hw_bkpt ) ? ; } LoopAction :: Continue } // Ignore everything else for now _ => LoopAction :: Nothing , } ; Ok ( status ) }
Executes the necessary actions for each valid breakpoint.
Executes the necessary actions for each valid breakpoint .
bkpt
&Breakpoint
core
&mut Core
measurements
&mut Vec<MeasurementResult>
current_hw_bkpt
&mut u32
app
&AppInfo
bkpt
&Breakpoint
core
&mut Core
measurements
&mut Vec<MeasurementResult>
current_hw_bkpt
&mut u32
app
&AppInfo