use std::collections::HashSet;
#[derive(Clone, Debug, Default)]
pub struct FunctionInfo {
pub name: String,
pub entry_pc: usize,
}
#[derive(Clone, Default)]
pub struct ReachableAnalysis {
pub total_instructions: usize,
pub total_branches: usize,
pub total_edges: usize,
pub reachable_pcs: HashSet<usize>,
pub reachable_branch_pcs: HashSet<usize>,
pub reachable_edges: HashSet<u64>,
}
#[derive(Clone, Debug, Default)]
pub struct CoverageStats {
pub total_instructions: usize,
pub hit_instructions: usize,
pub total_branches: usize,
pub hit_branches: usize,
pub total_blocks: usize,
pub hit_blocks: usize,
}
impl CoverageStats {
pub fn instruction_coverage_pct(&self) -> f64 {
if self.total_instructions == 0 {
0.0
} else {
100.0 * self.hit_instructions as f64 / self.total_instructions as f64
}
}
pub fn branch_coverage_pct(&self) -> f64 {
if self.total_branches == 0 {
0.0
} else {
100.0 * self.hit_branches as f64 / self.total_branches as f64
}
}
pub fn block_coverage_pct(&self) -> f64 {
if self.total_blocks == 0 {
0.0
} else {
100.0 * self.hit_blocks as f64 / self.total_blocks as f64
}
}
}
#[derive(Clone, Debug, Default)]
pub struct CoverageWriteStats {
pub run_time_secs: u64,
pub executions: u64,
pub edges_hit: usize,
pub edges_total: usize,
pub branches_hit: usize,
pub branches_total: usize,
pub instructions_hit: usize,
pub instructions_total: usize,
}
#[derive(Clone, Debug)]
pub struct CachedFunctionInfo {
pub name: String,
pub entry_pc: usize,
pub total_instructions: usize,
pub total_blocks: usize,
pub instruction_pcs: Vec<usize>,
pub blocks: Vec<(usize, Vec<usize>)>,
}
#[derive(Clone, Debug)]
pub struct CachedProgramAnalysis {
pub program_name: String,
pub functions: Vec<CachedFunctionInfo>,
pub cfg_json: std::collections::HashMap<String, String>,
}