fixup graph cycles

This commit is contained in:
Alwin Berger 2023-10-04 10:25:08 +02:00
parent c332e6f6df
commit 38d887cf0a
2 changed files with 26 additions and 14 deletions

View File

@ -33,6 +33,7 @@ pub struct RawFreeRTOSSystemState {
current_tcb: TCB_t,
prio_ready_lists: [freertos::List_t; NUM_PRIOS],
delay_list: freertos::List_t,
delay_list_overflow: freertos::List_t,
dumping_ground: HashMap<u32,freertos::rtos_struct>,
input_counter: u32,
last_pc: Option<u64>,
@ -41,7 +42,7 @@ pub struct RawFreeRTOSSystemState {
static mut CURRENT_SYSTEMSTATE_VEC: Vec<RawFreeRTOSSystemState> = vec![];
/// A reduced version of freertos::TCB_t
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub struct RefinedTCB {
pub task_name: String,
pub priority: u32,
@ -51,6 +52,15 @@ pub struct RefinedTCB {
notify_state: u8,
}
impl PartialEq for RefinedTCB {
fn eq(&self, other: &Self) -> bool {
self.task_name == other.task_name &&
self.priority == other.priority &&
self.base_priority == other.base_priority
// && self.notify_state == other.notify_state
}
}
impl Hash for RefinedTCB {
fn hash<H: Hasher>(&self, state: &mut H) {
self.task_name.hash(state);
@ -107,7 +117,8 @@ pub struct RefinedFreeRTOSSystemState {
impl PartialEq for RefinedFreeRTOSSystemState {
fn eq(&self, other: &Self) -> bool {
self.current_task == other.current_task && self.ready_list_after == other.ready_list_after &&
self.last_pc == other.last_pc
self.delay_list_after == other.delay_list_after
// && self.last_pc == other.last_pc
}
}

View File

@ -134,24 +134,25 @@ fn refine_system_states(input: &mut Vec<RawFreeRTOSSystemState>) -> Vec<RefinedF
for j in collector.iter() {let _ = iteration_counts.try_insert(j.task_name.clone(), 1);}
for j in delay_list.iter() {let _ = iteration_counts.try_insert(j.task_name.clone(), 0);}
// increase when:
// normal current and delayed afterwards
// async current and not previous
if cur.task_name.contains("async") {
if let Some(l) = ret.last() {
if l.current_task.0.task_name != cur.task_name {
*iteration_counts.get_mut(&cur.task_name).unwrap()+=1;
// Ensure that async events appear in the delay list, so we the counts in all states
if let Some(lst) = ret.last() {
for a in lst.delay_list_after.iter().filter(|x| x.0.task_name.contains("async")) {
if delay_list.iter().find(|x| (*x).task_name==a.0.task_name).is_none() && cur.task_name != a.0.task_name {
delay_list.push(a.0.clone());
delay_list.sort_by(|a,b| a.task_name.cmp(&b.task_name));
}
} else {
*iteration_counts.get_mut(&cur.task_name).unwrap()+=1;
}
} else if let Some(_) = delay_list.iter().find(|x| (*x).task_name==cur.task_name) {
}
// increase when:
// current and delayed afterwards
if let Some(_) = delay_list.iter().find(|x| (*x).task_name==cur.task_name) {
*iteration_counts.get_mut(&cur.task_name).unwrap()+=1;
}
let collector = collector.into_iter().map(|x| {let t = *iteration_counts.get(&x.task_name).unwrap_or(&1); (x, t)}).collect();
let filter_delay = delay_list.into_iter().filter(|x| !x.task_name.contains("async"));
let delay_list : Vec<(RefinedTCB, u32)> = filter_delay.map(|x| {let t = *iteration_counts.get(&x.task_name).unwrap_or(&0); (x, t)}).collect();
// let filter_delay = delay_list.into_iter().filter(|x| !x.task_name.contains("async"));
let delay_list : Vec<(RefinedTCB, u32)> = delay_list.into_iter().map(|x| {let t = *iteration_counts.get(&x.task_name).unwrap_or(&0); (x, t)}).collect();
let t = *iteration_counts.get(&cur.task_name).unwrap_or(&1);
// We don't care about the order
ret.push(RefinedFreeRTOSSystemState {