#include <xbt/log.h>
#include <xbt/sysdep.h>
#include <xbt/mmalloc.h>
+#include <xbt/swag.h>
+
+#include <simgrid/modelchecker.h>
#include "src/internal_config.h"
if (client_)
return client_.get();
- // Check and set the mode:
- if (mc_mode != MC_MODE_NONE)
- abort();
- mc_mode = MC_MODE_CLIENT;
+ _sg_do_model_check = 1;
// Fetch socket from MC_ENV_SOCKET_FD:
char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
client_ = std::unique_ptr<Client>(new simgrid::mc::Client(fd));
// Wait for the model-checker:
- if (ptrace(PTRACE_TRACEME, 0, nullptr, NULL) == -1 || raise(SIGSTOP) != 0)
+ errno = 0;
+#if defined __linux__
+ ptrace(PTRACE_TRACEME, 0, nullptr, nullptr);
+#elif defined BSD
+ ptrace(PT_TRACE_ME, 0, nullptr, 0);
+#else
+# error "no ptrace equivalent coded for this platform"
+#endif
+ if(errno != 0 || raise(SIGSTOP) != 0)
xbt_die("Could not wait for the model-checker");
client_->handleMessages();
{
// Check deadlock:
bool deadlock = false;
- smx_process_t process;
+ smx_actor_t process;
if (xbt_swag_size(simix_global->process_list)) {
deadlock = true;
xbt_swag_foreach(process, simix_global->process_list)
if (s != sizeof(message))
xbt_die("Unexpected size for SIMCALL_HANDLE");
memcpy(&message, message_buffer, sizeof(message));
- smx_process_t process = SIMIX_process_from_PID(message.pid);
+ smx_actor_t process = SIMIX_process_from_PID(message.pid);
if (!process)
xbt_die("Invalid pid %lu", (unsigned long) message.pid);
SIMIX_simcall_handle(&process->simcall, message.value);
if (s != sizeof(message))
xbt_die("Unexpected size for SIMCALL_HANDLE");
memcpy(&message, message_buffer, sizeof(message));
+#if HAVE_SMPI
smpi_really_switch_data_segment(message.index);
+#endif
}
break;
default:
- xbt_die("%s received unexpected message %s (%i)",
- MC_mode_name(mc_mode),
+ xbt_die("Received unexpected message %s (%i)",
MC_message_type_name(message.type),
message.type
);
void Client::mainLoop(void)
{
while (1) {
+ simgrid::mc::wait_for_requests();
if (channel_.send(MC_MESSAGE_WAITING))
xbt_die("Could not send WAITING mesage to model-checker");
this->handleMessages();
- simgrid::mc::wait_for_requests();
}
}
xbt_die("Could send REGISTER_SYMBOL message to model-checker");
}
-void Client::declareStack(void *stack, size_t size, smx_process_t process, ucontext_t* context)
+void Client::declareStack(void *stack, size_t size, smx_actor_t process, ucontext_t* context)
{
xbt_mheap_t heap = mmalloc_get_current_heap();