pub fn wcet_measurement(
    input: &MeasureInput,
    settings: &RaukSettings,
    metadata: &RaukMetadata,
) -> Result<Option<PathBuf>> {
    let (dwarf_path, ktests_path) = get_analysis_paths(&input, &metadata)?;
    let mut updated_input = input.clone();
    updated_input.get_missing_input(settings);

    let file = fs::File::open(&dwarf_path)?;
    let mmap = unsafe { memmap::Mmap::map(&file)? };
    let object = object::File::parse(&*mmap)?;
    let endian = if object.is_little_endian() {
        gimli::RunTimeEndian::Little
    } else {
        gimli::RunTimeEndian::Big
    };
    let dwarf_cow = dwarf::load_dwarf_from_file(object)?;

    // Borrow a `Cow<[u8]>` to create an `EndianSlice`.
    let borrow_section: &dyn for<'a> Fn(
        &'a borrow::Cow<[u8]>,
    ) -> gimli::EndianSlice<'a, gimli::RunTimeEndian> =
        &|section| gimli::EndianSlice::new(&*section, endian);

    // Create `EndianSlice`s for all of the sections.
    let dwarf = dwarf_cow.borrow(&borrow_section);

    let ktests = klee::parse_ktest_files(&ktests_path)?;
    if ktests.is_empty() {
        return Err(anyhow!(
            "No test vectors found. Cannot continue with WCET measurement without test vectors"
        ));
    }

    let addr = dwarf::get_replay_addresses(&dwarf)?;
    let subprograms = dwarf::get_subprograms(&dwarf)?;
    let subroutines = dwarf::get_subroutines(&dwarf)?;
    let resources = dwarf::get_resources_from_subroutines(&subroutines);
    let vcells = dwarf::get_vcell_from_subroutines(&subroutines);
    let objdump = objdump::disassemble(&dwarf_path).context("Could not disassemble the binary")?;
    let app = AppInfo {
        subprograms,
        resource_locks: resources,
        variables: addr,
        vcells,
        objdump,
        release: input.is_release(),
    };

    let mut session = if let Some(chip) = updated_input.chip {
        core::open_and_attach_probe(&chip)?
    } else {
        return Err(anyhow!(
            "Cannot attach to hardware. No chip type given as input"
        ));
    };
    let mut core = session.core(0)?;

    let measurements = hardware::measure_replay_harness(input, &mut core, &ktests, &app)
        .context("Could not complete the measurement of the replay harness")?;

    let traces = post_measurement_analysis(measurements)
        .context("Could not complete the analysis of measurement data")?;
    println!("{:#?}", traces);

    let output_path = save_traces_to_directory(&traces, &metadata.rauk_output_directory)?;

    Ok(Some(output_path))
}
/// Measure the replay harness using the generated test vectors to get a
/// WCET for each user task in the RTIC application.
///
/// * `input` - Input for this command
/// * `settings` - The settings file for Rauk
/// * `metadata` - The metadata for Rauk
Measure the replay harness using the generated test vectors to get a
WCET for each user task in the RTIC application.


Measure the replay harness using the generated test vectors to get a WCET for each user task in the RTIC application .
pub fn wcet_measurement(
    input: &MeasureInput,
    settings: &RaukSettings,
    metadata: &RaukMetadata,
) -> Result<Option<PathBuf>> {
    let (dwarf_path, ktests_path) = get_analysis_paths(&input, &metadata)?;
    let mut updated_input = input.clone();
    updated_input.get_missing_input(settings);
    let file = fs::File::open(&dwarf_path)?;
    let mmap = unsafe { memmap::Mmap::map(&file)? };
    let object = object::File::parse(&*mmap)?;
    let endian = if object.is_little_endian() {
        gimli::RunTimeEndian::Little
    } else {
        gimli::RunTimeEndian::Big
    };
    let dwarf_cow = dwarf::load_dwarf_from_file(object)?;
    // Borrow a `Cow<[u8]>` to create an `EndianSlice`.
    let borrow_section: &dyn for<'a> Fn(
        &'a borrow::Cow<[u8]>,
    ) -> gimli::EndianSlice<'a, gimli::RunTimeEndian> =
        &|section| gimli::EndianSlice::new(&*section, endian);
    // Create `EndianSlice`s for all of the sections.
    let dwarf = dwarf_cow.borrow(&borrow_section);
    let ktests = klee::parse_ktest_files(&ktests_path)?;
    if ktests.is_empty() {
        return Err(anyhow!(
            "No test vectors found. Cannot continue with WCET measurement without test vectors"
        ));
    }
    let addr = dwarf::get_replay_addresses(&dwarf)?;
    let subprograms = dwarf::get_subprograms(&dwarf)?;
    let subroutines = dwarf::get_subroutines(&dwarf)?;
    let resources = dwarf::get_resources_from_subroutines(&subroutines);
    let vcells = dwarf::get_vcell_from_subroutines(&subroutines);
    let objdump = objdump::disassemble(&dwarf_path).context("Could not disassemble the binary")?;
    let app = AppInfo {
        subprograms,
        resource_locks: resources,
        variables: addr,
        vcells,
        objdump,
        release: input.is_release(),
    };
    let mut session = if let Some(chip) = updated_input.chip {
        core::open_and_attach_probe(&chip)?
    } else {
        return Err(anyhow!(
            "Cannot attach to hardware. No chip type given as input"
        ));
    };
    let mut core = session.core(0)?;
    let measurements = hardware::measure_replay_harness(input, &mut core, &ktests, &app)
        .context("Could not complete the measurement of the replay harness")?;
    let traces = post_measurement_analysis(measurements)
        .context("Could not complete the analysis of measurement data")?;
    println!("{:#?}", traces);
    let output_path = save_traces_to_directory(&traces, &metadata.rauk_output_directory)?;
    Ok(Some(output_path))
}
pub fn wcet_measurement ( input : & MeasureInput , settings : & RaukSettings , metadata : & RaukMetadata , ) -> Result < Option < PathBuf > > { let ( dwarf_path , ktests_path ) = get_analysis_paths ( & input , & metadata ) ? ; let mut updated_input = input . clone ( ) ; updated_input . get_missing_input ( settings ) ; let file = fs :: File :: open ( & dwarf_path ) ? ; let mmap = unsafe { memmap :: Mmap :: map ( & file ) ? } ; let object = object :: File :: parse ( & * mmap ) ? ; let endian = if object . is_little_endian ( ) { gimli :: RunTimeEndian :: Little } else { gimli :: RunTimeEndian :: Big } ; let dwarf_cow = dwarf :: load_dwarf_from_file ( object ) ? ; // Borrow a `Cow<[u8]>` to create an `EndianSlice`. let borrow_section : & dyn for < ' a > Fn ( & ' a borrow :: Cow < [ u8 ] > , ) -> gimli :: EndianSlice < ' a , gimli :: RunTimeEndian > = & | section | gimli :: EndianSlice :: new ( & * section , endian ) ; // Create `EndianSlice`s for all of the sections. let dwarf = dwarf_cow . borrow ( & borrow_section ) ; let ktests = klee :: parse_ktest_files ( & ktests_path ) ? ; if ktests . is_empty ( ) { return Err ( anyhow ! ( " " ) ) ; } let addr = dwarf :: get_replay_addresses ( & dwarf ) ? ; let subprograms = dwarf :: get_subprograms ( & dwarf ) ? ; let subroutines = dwarf :: get_subroutines ( & dwarf ) ? ; let resources = dwarf :: get_resources_from_subroutines ( & subroutines ) ; let vcells = dwarf :: get_vcell_from_subroutines ( & subroutines ) ; let objdump = objdump :: disassemble ( & dwarf_path ) . context ( " " ) ? ; let app = AppInfo { subprograms , resource_locks : resources , variables : addr , vcells , objdump , release : input . is_release ( ) , } ; let mut session = if let Some ( chip ) = updated_input . chip { core :: open_and_attach_probe ( & chip ) ? } else { return Err ( anyhow ! ( " " ) ) ; } ; let mut core = session . core ( 0 ) ? ; let measurements = hardware :: measure_replay_harness ( input , & mut core , & ktests , & app ) . context ( " " ) ? ; let traces = post_measurement_analysis ( measurements ) . context ( " " ) ? ; println ! ( " " traces ) ; let output_path = save_traces_to_directory ( & traces , & metadata . rauk_output_directory ) ? ; Ok ( Some ( output_path ) ) }
Measure the replay harness using the generated test vectors to get a
WCET for each user task in the RTIC application.
Measure the replay harness using the generated test vectors to get a WCET for each user task in the RTIC application .
input
&MeasureInput
settings
&RaukSettings
metadata
&RaukMetadata
input
&MeasureInput
settings
&RaukSettings
metadata
&RaukMetadata