From: Gabriel Corona Date: Thu, 7 Apr 2016 09:27:49 +0000 (+0200) Subject: [mc] Add Factor some gorry code to State::getRecordElement() X-Git-Tag: v3_13~136 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/04d920dbbca9867f8440d85781e33d1f603978c7 [mc] Add Factor some gorry code to State::getRecordElement() Avoid using should-be-private-stuff oustside of State. --- diff --git a/src/mc/CommunicationDeterminismChecker.cpp b/src/mc/CommunicationDeterminismChecker.cpp index 3c0cd08bf2..6b6a3314d0 100644 --- a/src/mc/CommunicationDeterminismChecker.cpp +++ b/src/mc/CommunicationDeterminismChecker.cpp @@ -305,13 +305,8 @@ CommunicationDeterminismChecker::~CommunicationDeterminismChecker() RecordTrace CommunicationDeterminismChecker::getRecordTrace() // override { RecordTrace res; - for (auto const& state : stack_) { - int value = 0; - smx_simcall_t saved_req = MC_state_get_executed_request(state.get(), &value); - const smx_process_t issuer = MC_smx_simcall_get_issuer(saved_req); - const int pid = issuer->pid; - res.push_back(RecordTraceElement(pid, value)); - } + for (auto const& state : stack_) + res.push_back(state->getRecordElement()); return res; } diff --git a/src/mc/LivenessChecker.cpp b/src/mc/LivenessChecker.cpp index 8dcb3b92eb..2837d43498 100644 --- a/src/mc/LivenessChecker.cpp +++ b/src/mc/LivenessChecker.cpp @@ -296,15 +296,8 @@ LivenessChecker::~LivenessChecker() RecordTrace LivenessChecker::getRecordTrace() // override { RecordTrace res; - for (std::shared_ptr const& pair : explorationStack_) { - int value; - smx_simcall_t req = MC_state_get_executed_request(pair->graph_state.get(), &value); - if (req && req->call != SIMCALL_NONE) { - smx_process_t issuer = MC_smx_simcall_get_issuer(req); - const int pid = issuer->pid; - res.push_back(RecordTraceElement(pid, value)); - } - } + for (std::shared_ptr const& pair : explorationStack_) + res.push_back(pair->graph_state->getRecordElement()); return res; } diff --git a/src/mc/SafetyChecker.cpp b/src/mc/SafetyChecker.cpp index 62a4f5c177..7cdceede70 100644 --- a/src/mc/SafetyChecker.cpp +++ b/src/mc/SafetyChecker.cpp @@ -67,13 +67,8 @@ bool SafetyChecker::checkNonTermination(simgrid::mc::State* current_state) RecordTrace SafetyChecker::getRecordTrace() // override { RecordTrace res; - for (auto const& state : stack_) { - int value = 0; - smx_simcall_t saved_req = MC_state_get_executed_request(state.get(), &value); - const smx_process_t issuer = MC_smx_simcall_get_issuer(saved_req); - const int pid = issuer->pid; - res.push_back(RecordTraceElement(pid, value)); - } + for (auto const& state : stack_) + res.push_back(state->getRecordElement()); return res; } diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index b904885d9d..d17f2b08fd 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -111,7 +111,7 @@ void Process::refresh_simix() * @param process the MCed process * @param req the simcall (copied in the local process) */ -smx_process_t MC_smx_simcall_get_issuer(smx_simcall_t req) +smx_process_t MC_smx_simcall_get_issuer(s_smx_simcall_t const* req) { if (mc_mode == MC_MODE_CLIENT) return req->issuer; diff --git a/src/mc/mc_smx.h b/src/mc/mc_smx.h index ba19d94027..31534c0e71 100644 --- a/src/mc/mc_smx.h +++ b/src/mc/mc_smx.h @@ -52,7 +52,7 @@ XBT_PRIVATE void MC_process_smx_refresh(simgrid::mc::Process* process); * @param process the MCed process * @param req the simcall (copied in the local process) */ -XBT_PRIVATE smx_process_t MC_smx_simcall_get_issuer(smx_simcall_t req); +XBT_PRIVATE smx_process_t MC_smx_simcall_get_issuer(s_smx_simcall_t const* req); XBT_PRIVATE const char* MC_smx_process_get_name(smx_process_t p); XBT_PRIVATE const char* MC_smx_process_get_host_name(smx_process_t p); diff --git a/src/mc/mc_state.cpp b/src/mc/mc_state.cpp index 1a88fb1abb..7a164f8b00 100644 --- a/src/mc/mc_state.cpp +++ b/src/mc/mc_state.cpp @@ -59,6 +59,12 @@ std::size_t State::interleaveSize() const [](simgrid::mc::ProcessState const& state) { return state.isToInterleave(); }); } +RecordTraceElement State::getRecordElement() const +{ + smx_process_t issuer = MC_smx_simcall_get_issuer(&this->executed_req); + return RecordTraceElement(issuer->pid, this->req_num); +} + } } diff --git a/src/mc/mc_state.h b/src/mc/mc_state.h index fa5ddb98d7..c3d6190b5b 100644 --- a/src/mc/mc_state.h +++ b/src/mc/mc_state.h @@ -16,6 +16,7 @@ #include #include "src/simix/smx_private.h" #include "src/mc/mc_snapshot.h" +#include "src/mc/mc_record.h" namespace simgrid { namespace mc { @@ -156,6 +157,7 @@ struct XBT_PRIVATE State { { this->processStates[process->pid].interleave(); } + RecordTraceElement getRecordElement() const; }; XBT_PRIVATE void replay(std::list> const& stack);