/********* Global variables *********/
xbt_dynar_t acceptance_pairs;
+static xbt_fifo_t liveness_stack;
/********* Static functions *********/
}
static int is_exploration_stack_pair(simgrid::mc::VisitedPair* pair){
- xbt_fifo_item_t item = xbt_fifo_get_first_item(mc_stack);
+ xbt_fifo_item_t item = xbt_fifo_get_first_item(liveness_stack);
while (item) {
if (((simgrid::mc::Pair*)xbt_fifo_get_item_content(item))->num == pair->num){
((simgrid::mc::Pair*)xbt_fifo_get_item_content(item))->visited_pair_removed = 1;
MC_state_delete(this->graph_state, 1);
}
-void LivenessChecker::showStack(xbt_fifo_t stack)
-{
- int value;
- simgrid::mc::Pair* pair;
- xbt_fifo_item_t item;
- smx_simcall_t req;
- char *req_str = nullptr;
-
- for (item = xbt_fifo_get_last_item(stack);
- item; item = xbt_fifo_get_prev_item(item)) {
- pair = (simgrid::mc::Pair*) xbt_fifo_get_item_content(item);
- req = MC_state_get_executed_request(pair->graph_state, &value);
- if (req && req->call != SIMCALL_NONE) {
- req_str = simgrid::mc::request_to_string(req, value, simgrid::mc::RequestType::executed);
- XBT_INFO("%s", req_str);
- xbt_free(req_str);
- }
- }
-}
-
-void LivenessChecker::dumpStack(xbt_fifo_t stack)
-{
- simgrid::mc::Pair* pair;
- while ((pair = (simgrid::mc::Pair*) xbt_fifo_pop(stack)) != nullptr)
- delete pair;
-}
-
simgrid::xbt::unique_ptr<s_xbt_dynar_t> LivenessChecker::getPropositionValues()
{
unsigned int cursor = 0;
new_pair->atomic_propositions.get()) == 0) {
if (this->compare(pair_test, new_pair.get()) == 0) {
XBT_INFO("Pair %d already reached (equal to pair %d) !", new_pair->num, pair_test->num);
- xbt_fifo_shift(mc_stack);
+ xbt_fifo_shift(liveness_stack);
if (dot_output != nullptr)
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, pair_test->num, initial_global_state->prev_req);
return nullptr;
initial_pair->requests = MC_state_interleave_size(initial_pair->graph_state);
initial_pair->search_cycle = 0;
- xbt_fifo_unshift(mc_stack, initial_pair);
+ xbt_fifo_unshift(liveness_stack, initial_pair);
}
}
}
{
}
+RecordTrace LivenessChecker::getRecordTrace() // override
+{
+ RecordTrace res;
+
+ xbt_fifo_item_t start = xbt_fifo_get_last_item(liveness_stack);
+ for (xbt_fifo_item_t item = start; item; item = xbt_fifo_get_prev_item(item)) {
+ simgrid::mc::Pair* pair = (simgrid::mc::Pair*) xbt_fifo_get_item_content(item);
+ int value;
+ smx_simcall_t req = MC_state_get_executed_request(pair->graph_state, &value);
+ if (req && req->call != SIMCALL_NONE) {
+ smx_process_t issuer = MC_smx_simcall_get_issuer(req);
+ const int pid = issuer->pid;
+
+ // Serialization the (pid, value) pair:
+ res.push_back(RecordTraceElement(pid, value));
+ }
+ }
+
+ return std::move(res);
+}
+
void LivenessChecker::showAcceptanceCycle(std::size_t depth)
{
XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
XBT_INFO("| ACCEPTANCE CYCLE |");
XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
XBT_INFO("Counter-example that violates formula :");
- MC_record_dump_path(mc_stack);
- this->showStack(mc_stack);
- this->dumpStack(mc_stack);
+ simgrid::mc::dumpRecordPath();
+ for (auto& s : this->getTextualTrace())
+ XBT_INFO("%s", s.c_str());
MC_print_statistics(mc_stats);
XBT_INFO("Counter-example depth : %zd", depth);
}
+std::vector<std::string> LivenessChecker::getTextualTrace() // override
+{
+ std::vector<std::string> trace;
+ for (xbt_fifo_item_t item = xbt_fifo_get_last_item(liveness_stack);
+ item; item = xbt_fifo_get_prev_item(item)) {
+ simgrid::mc::Pair* pair = (simgrid::mc::Pair*) xbt_fifo_get_item_content(item);
+ int value;
+ smx_simcall_t req = MC_state_get_executed_request(pair->graph_state, &value);
+ if (req && req->call != SIMCALL_NONE) {
+ char* req_str = simgrid::mc::request_to_string(req, value, simgrid::mc::RequestType::executed);
+ trace.push_back(std::string(req_str));
+ xbt_free(req_str);
+ }
+ }
+ return std::move(trace);
+}
+
int LivenessChecker::main(void)
{
simgrid::mc::Pair* current_pair = nullptr;
simgrid::xbt::unique_ptr<s_xbt_dynar_t> prop_values;
simgrid::mc::VisitedPair* reached_pair = nullptr;
- while(xbt_fifo_size(mc_stack) > 0){
+ while(xbt_fifo_size(liveness_stack) > 0){
/* Get current pair */
- current_pair = (simgrid::mc::Pair*) xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ current_pair = (simgrid::mc::Pair*) xbt_fifo_get_item_content(xbt_fifo_get_first_item(liveness_stack));
/* Update current state in buchi automaton */
simgrid::mc::property_automaton->current_state = current_pair->automaton_state;
next_pair->search_cycle = 1;
/* Add new pair to the exploration stack */
- xbt_fifo_unshift(mc_stack, next_pair);
+ xbt_fifo_unshift(liveness_stack, next_pair);
}
cursor--;
/* 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. */
- while ((current_pair = (simgrid::mc::Pair*) xbt_fifo_shift(mc_stack)) != nullptr) {
+ while ((current_pair = (simgrid::mc::Pair*) xbt_fifo_shift(liveness_stack)) != nullptr) {
if (current_pair->requests > 0) {
/* We found a backtracking point */
XBT_DEBUG("Backtracking to depth %d", current_pair->depth);
- xbt_fifo_unshift(mc_stack, current_pair);
- this->replay(mc_stack);
+ xbt_fifo_unshift(liveness_stack, current_pair);
+ this->replay(liveness_stack);
XBT_DEBUG("Backtracking done");
break;
}else{
} /* End of if (current_pair->requests > 0) else ... */
- } /* End of while(xbt_fifo_size(mc_stack) > 0) */
+ } /* End of while(xbt_fifo_size(liveness_stack) > 0) */
XBT_INFO("No property violation found.");
MC_print_statistics(mc_stats);
_sg_mc_liveness = 1;
/* Create exploration stack */
- mc_stack = xbt_fifo_new();
+ liveness_stack = xbt_fifo_new();
/* Create the initial state */
initial_global_state = xbt_new0(s_mc_global_t, 1);