/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
"Logging specific to algorithms for liveness properties verification");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
"Logging specific to algorithms for liveness properties verification");
- xbt_automaton_propositional_symbol_t ps = NULL;
- xbt_dynar_t values = xbt_dynar_new(sizeof(int), NULL);
- xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps) {
+ xbt_automaton_propositional_symbol_t ps = nullptr;
+ xbt_dynar_t values = xbt_dynar_new(sizeof(int), nullptr);
+ xbt_dynar_foreach(simgrid::mc::property_automaton->propositional_symbols, cursor, ps) {
int res = xbt_automaton_propositional_symbol_evaluate(ps);
xbt_dynar_push_as(values, int, res);
}
int res = xbt_automaton_propositional_symbol_evaluate(ps);
xbt_dynar_push_as(values, int, res);
}
- mc_visited_pair_t new_pair = NULL;
- new_pair = MC_visited_pair_new(pair->num, pair->automaton_state, pair->atomic_propositions, pair->graph_state);
+ simgrid::mc::VisitedPair* new_pair = nullptr;
+ new_pair = simgrid::mc::visited_pair_new(pair->num, pair->automaton_state, pair->atomic_propositions, pair->graph_state);
int cursor;
index = get_search_interval(acceptance_pairs, new_pair, &min, &max);
if (min != -1 && max != -1) { // Acceptance pair with same number of processes and same heap bytes used exists
int cursor;
index = get_search_interval(acceptance_pairs, new_pair, &min, &max);
if (min != -1 && max != -1) { // Acceptance pair with same number of processes and same heap bytes used exists
- // Parallell implementation
- /*res = xbt_parmap_mc_apply(parmap, snapshot_compare, xbt_dynar_get_ptr(acceptance_pairs, min), (max-min)+1, pair);
- if(res != -1){
- return ((mc_pair_t)xbt_dynar_get_as(acceptance_pairs, (min+res)-1, mc_pair_t))->num;
- } */
-
- pair_test = (mc_visited_pair_t) xbt_dynar_get_as(acceptance_pairs, cursor, mc_visited_pair_t);
+ pair_test = (simgrid::mc::VisitedPair*) xbt_dynar_get_as(acceptance_pairs, cursor, simgrid::mc::VisitedPair*);
if (xbt_automaton_state_compare(pair_test->automaton_state, new_pair->automaton_state) == 0) {
if (xbt_automaton_propositional_symbols_compare_value(pair_test->atomic_propositions, new_pair->atomic_propositions) == 0) {
if (snapshot_compare(pair_test, new_pair) == 0) {
XBT_INFO("Pair %d already reached (equal to pair %d) !", new_pair->num, pair_test->num);
xbt_fifo_shift(mc_stack);
if (xbt_automaton_state_compare(pair_test->automaton_state, new_pair->automaton_state) == 0) {
if (xbt_automaton_propositional_symbols_compare_value(pair_test->atomic_propositions, new_pair->atomic_propositions) == 0) {
if (snapshot_compare(pair_test, new_pair) == 0) {
XBT_INFO("Pair %d already reached (equal to pair %d) !", new_pair->num, pair_test->num);
xbt_fifo_shift(mc_stack);
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, pair_test->num, initial_global_state->prev_req);
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, pair_test->num, initial_global_state->prev_req);
- pair_test = (mc_visited_pair_t) xbt_dynar_get_as(acceptance_pairs, index, mc_visited_pair_t);
- if (pair_test->nb_processes < new_pair->nb_processes) {
+ pair_test = (simgrid::mc::VisitedPair*) xbt_dynar_get_as(acceptance_pairs, index, simgrid::mc::VisitedPair*);
+ if (pair_test->nb_processes < new_pair->nb_processes)
- } else {
- if (pair_test->heap_bytes_used < new_pair->heap_bytes_used)
- xbt_dynar_insert_at(acceptance_pairs, index + 1, &new_pair);
- else
- xbt_dynar_insert_at(acceptance_pairs, index, &new_pair);
- }
+ else if (pair_test->heap_bytes_used < new_pair->heap_bytes_used)
+ xbt_dynar_insert_at(acceptance_pairs, index + 1, &new_pair);
+ else
+ xbt_dynar_insert_at(acceptance_pairs, index, &new_pair);
- xbt_automaton_propositional_symbol_t p = NULL;
- xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, p) {
- if (strcmp(xbt_automaton_propositional_symbol_get_name(p), l->u.predicat) == 0)
+ xbt_automaton_propositional_symbol_t p = nullptr;
+ xbt_dynar_foreach(simgrid::mc::property_automaton->propositional_symbols, cursor, p) {
+ if (std::strcmp(xbt_automaton_propositional_symbol_get_name(p), l->u.predicat) == 0)
initial_pair->automaton_state = automaton_state;
initial_pair->graph_state = MC_state_new();
initial_pair->atomic_propositions = get_atomic_propositions_values();
initial_pair->depth = 1;
/* Get enabled processes and insert them in the interleave set of the graph_state */
initial_pair->automaton_state = automaton_state;
initial_pair->graph_state = MC_state_new();
initial_pair->atomic_propositions = get_atomic_propositions_values();
initial_pair->depth = 1;
/* Get enabled processes and insert them in the interleave set of the graph_state */
- MC_EACH_SIMIX_PROCESS(process,
- if (MC_process_is_enabled(process)) {
- MC_state_interleave_process(initial_pair->graph_state, process);
- }
- );
+ for (auto& p : mc_model_checker->process().simix_processes())
+ if (simgrid::mc::process_is_enabled(&p.copy))
+ MC_state_interleave_process(initial_pair->graph_state, &p.copy);
initial_pair->requests = MC_state_interleave_size(initial_pair->graph_state);
initial_pair->search_cycle = 0;
initial_pair->requests = MC_state_interleave_size(initial_pair->graph_state);
initial_pair->search_cycle = 0;
- mc_pair_t next_pair = NULL;
- xbt_dynar_t prop_values = NULL;
- mc_visited_pair_t reached_pair = NULL;
+ simgrid::mc::Pair* next_pair = nullptr;
+ xbt_dynar_t prop_values = nullptr;
+ simgrid::mc::VisitedPair* reached_pair = nullptr;
XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d, interleave size = %d, pair_num = %d, requests = %d)",
current_pair->depth, current_pair->search_cycle,
XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d, interleave size = %d, pair_num = %d, requests = %d)",
current_pair->depth, current_pair->search_cycle,
if (current_pair->automaton_state->type == 1 && current_pair->exploration_started == 0) {
/* If new acceptance pair, return new pair */
if (current_pair->automaton_state->type == 1 && current_pair->exploration_started == 0) {
/* If new acceptance pair, return new pair */
int counter_example_depth = current_pair->depth;
XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
XBT_INFO("| ACCEPTANCE CYCLE |");
XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
XBT_INFO("Counter-example that violates formula :");
MC_record_dump_path(mc_stack);
int counter_example_depth = current_pair->depth;
XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
XBT_INFO("| ACCEPTANCE CYCLE |");
XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
XBT_INFO("Counter-example that violates formula :");
MC_record_dump_path(mc_stack);
MC_print_statistics(mc_stats);
XBT_INFO("Counter-example depth : %d", counter_example_depth);
return SIMGRID_MC_EXIT_LIVENESS;
MC_print_statistics(mc_stats);
XBT_INFO("Counter-example depth : %d", counter_example_depth);
return SIMGRID_MC_EXIT_LIVENESS;
- if ((current_pair->exploration_started == 0) && (visited_num = is_visited_pair(reached_pair, current_pair)) != -1) {
+ if ((current_pair->exploration_started == 0)
+ && (visited_num = simgrid::mc::is_visited_pair(
+ reached_pair, current_pair)) != -1) {
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, visited_num, initial_global_state->prev_req);
fflush(dot_output);
}
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, visited_num, initial_global_state->prev_req);
fflush(dot_output);
}
if (initial_global_state->prev_pair != 0 && initial_global_state->prev_pair != current_pair->num) {
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, current_pair->num, initial_global_state->prev_req);
xbt_free(initial_global_state->prev_req);
}
initial_global_state->prev_pair = current_pair->num;
if (initial_global_state->prev_pair != 0 && initial_global_state->prev_pair != current_pair->num) {
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, current_pair->num, initial_global_state->prev_req);
xbt_free(initial_global_state->prev_req);
}
initial_global_state->prev_pair = current_pair->num;
if (current_pair->search_cycle)
fprintf(dot_output, "%d [shape=doublecircle];\n", current_pair->num);
fflush(dot_output);
}
if (current_pair->search_cycle)
fprintf(dot_output, "%d [shape=doublecircle];\n", current_pair->num);
fflush(dot_output);
}
transition_succ = (xbt_automaton_transition_t)xbt_dynar_get_as(current_pair->automaton_state->out, cursor, xbt_automaton_transition_t);
res = MC_automaton_evaluate_label(transition_succ->label, prop_values);
if (res == 1 || res == 2) { /* 1 = True transition (always enabled), 2 = enabled transition according to atomic prop values */
transition_succ = (xbt_automaton_transition_t)xbt_dynar_get_as(current_pair->automaton_state->out, cursor, xbt_automaton_transition_t);
res = MC_automaton_evaluate_label(transition_succ->label, prop_values);
if (res == 1 || res == 2) { /* 1 = True transition (always enabled), 2 = enabled transition according to atomic prop values */
next_pair->graph_state = MC_state_new();
next_pair->automaton_state = transition_succ->dst;
next_pair->atomic_propositions = get_atomic_propositions_values();
next_pair->depth = current_pair->depth + 1;
/* Get enabled processes and insert them in the interleave set of the next graph_state */
next_pair->graph_state = MC_state_new();
next_pair->automaton_state = transition_succ->dst;
next_pair->atomic_propositions = get_atomic_propositions_values();
next_pair->depth = current_pair->depth + 1;
/* Get enabled processes and insert them in the interleave set of the next graph_state */
- MC_EACH_SIMIX_PROCESS(process,
- if (MC_process_is_enabled(process)) {
- MC_state_interleave_process(next_pair->graph_state, process);
- }
- );
+ for (auto& p : mc_model_checker->process().simix_processes())
+ if (simgrid::mc::process_is_enabled(&p.copy))
+ MC_state_interleave_process(next_pair->graph_state, &p.copy);
/* Traverse the stack backwards until a pair with a non empty interleave
set is found, deleting all the pairs that have it empty in the way. */
/* Traverse the stack backwards until a pair with a non empty interleave
set is found, deleting all the pairs that have it empty in the way. */
if (current_pair->requests > 0) {
/* We found a backtracking point */
XBT_DEBUG("Backtracking to depth %d", current_pair->depth);
if (current_pair->requests > 0) {
/* We found a backtracking point */
XBT_DEBUG("Backtracking to depth %d", current_pair->depth);
XBT_DEBUG("Delete pair %d at depth %d", current_pair->num, current_pair->depth);
if (current_pair->automaton_state->type == 1)
remove_acceptance_pair(current_pair->num);
XBT_DEBUG("Delete pair %d at depth %d", current_pair->num, current_pair->depth);
if (current_pair->automaton_state->type == 1)
remove_acceptance_pair(current_pair->num);