From: Gabriel Corona Date: Mon, 27 Apr 2015 08:33:01 +0000 (+0200) Subject: Merge branch 'master' into mc X-Git-Tag: v3_12~732^2~50 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d13b1659a0c2551ee41b287a269e391bb2d7bc8a?hp=-c Merge branch 'master' into mc Conflicts: buildtools/Cmake/DefinePackages.cmake src/mc/mc_request.cpp --- d13b1659a0c2551ee41b287a269e391bb2d7bc8a diff --combined buildtools/Cmake/DefinePackages.cmake index b08922fe1f,79652e1ad5..d62ea0c557 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@@ -6,7 -6,7 +6,7 @@@ set(EXTRA_DIS src/include/mc/datatypes.h src/include/mc/mc.h src/mc/mc_mmu.h - src/mc/mc_page_store.h + src/mc/PageStore.hpp src/mc/mc_record.h src/include/simgrid/platf_interface.h src/include/simgrid/sg_config.h @@@ -579,72 -579,74 +579,73 @@@ set(JEDULE_SR ) set(MC_SRC_BASE - src/mc/mc_base.c + src/mc/mc_base.cpp src/mc/mc_base.h src/mc/mc_record.h - src/mc/mc_record.c - src/mc/mc_config.c - src/mc/mc_global.c + src/mc/mc_replay.h + src/mc/mc_record.cpp + src/mc/mc_config.cpp + src/mc/mc_global.cpp ) set(MC_SRC src/mc/mc_address_space.h - src/mc/mc_address_space.c + src/mc/mc_address_space.cpp src/mc/mc_forward.h src/mc/mc_process.h - src/mc/mc_process.c + src/mc/mc_process.cpp src/mc/mc_unw.h - src/mc/mc_unw.c - src/mc/mc_unw_vmread.c + src/mc/mc_unw.cpp + src/mc/mc_unw_vmread.cpp src/mc/mc_mmalloc.h - src/mc/mc_model_checker.h - src/mc/mc_model_checker.c + src/mc/ModelChecker.hpp + src/mc/ModelChecker.cpp src/mc/mc_object_info.h - src/mc/mc_object_info.c - src/mc/mc_checkpoint.c + src/mc/mc_object_info.cpp + src/mc/mc_checkpoint.cpp src/mc/mc_snapshot.h - src/mc/mc_snapshot.c - src/mc/mc_page_store.h - src/mc/mc_page_store.cpp + src/mc/mc_snapshot.cpp + src/mc/PageStore.hpp + src/mc/PageStore.cpp src/mc/mc_page_snapshot.cpp src/mc/mc_comm_pattern.h - src/mc/mc_comm_pattern.c - src/mc/mc_comm_determinism.c + src/mc/mc_comm_pattern.cpp + src/mc/mc_comm_determinism.cpp src/mc/mc_compare.cpp - src/mc/mc_diff.c - src/mc/mc_dwarf.c + src/mc/mc_diff.cpp + src/mc/mc_dwarf.cpp src/mc/mc_dwarf_attrnames.h - src/mc/mc_dwarf_expression.c + src/mc/mc_dwarf_expression.cpp src/mc/mc_dwarf_tagnames.h - src/mc/mc_hash.c - src/mc/mc_ignore.c + src/mc/mc_hash.cpp + src/mc/mc_ignore.cpp + src/mc/mc_ignore.h - src/mc/mc_interface.h src/mc/mc_liveness.h src/mc/mc_location.h - src/mc/mc_liveness.c - src/mc/mc_record.c - src/mc/mc_member.c - src/mc/mc_memory.c - src/mc/mc_pair.c + src/mc/mc_liveness.cpp + src/mc/mc_record.cpp + src/mc/mc_member.cpp + src/mc/mc_memory.cpp + src/mc/mc_pair.cpp src/mc/mc_private.h src/mc/mc_request.h - src/mc/mc_request.c + src/mc/mc_request.cpp src/mc/mc_safety.h - src/mc/mc_safety.c - src/mc/mc_set.cpp + src/mc/mc_safety.cpp src/mc/mc_state.h - src/mc/mc_state.c - src/mc/mc_visited.c + src/mc/mc_state.cpp + src/mc/mc_visited.cpp src/mc/mc_memory_map.h - src/mc/memory_map.c - src/mc/mc_client.c - src/mc/mc_client_api.c + src/mc/memory_map.cpp + src/mc/mc_client.cpp + src/mc/mc_client_api.cpp src/mc/mc_client.h src/mc/mc_protocol.h - src/mc/mc_protocol.c + src/mc/mc_protocol.cpp src/mc/mc_server.cpp src/mc/mc_server.h src/mc/mc_smx.h - src/mc/mc_smx.c + src/mc/mc_smx.cpp ) set(MC_SIMGRID_MC_SRC diff --combined src/mc/mc_request.cpp index c3de6850aa,2af0bdbf38..4d0ebf46c1 --- a/src/mc/mc_request.cpp +++ b/src/mc/mc_request.cpp @@@ -11,8 -11,6 +11,8 @@@ #include "mc_private.h" #include "mc_smx.h" +extern "C" { + XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_request, mc, "Logging specific to MC (request)"); @@@ -42,7 -40,7 +42,7 @@@ int MC_request_depend(smx_simcall_t r1 // Those are internal requests, we do not need indirection // because those objects are copies: - smx_synchro_t synchro1= NULL, synchro2=NULL; + smx_synchro_t synchro1 = NULL, synchro2 = NULL; if (r1->call == SIMCALL_COMM_WAIT) { synchro1 = simcall_comm_wait__get__comm(r1); } @@@ -232,7 -230,7 +232,7 @@@ static char *buff_size_to_string(size_ char *MC_request_to_string(smx_simcall_t req, int value, e_mc_request_type_t request_type) { - bool use_remote_comm = false; + bool use_remote_comm = true; switch(request_type) { case MC_REQUEST_SIMIX: use_remote_comm = true; @@@ -275,7 -273,7 +275,7 @@@ // size_t size = size_pointer ? *size_pointer : 0; size_t size = 0; if (remote_size) - MC_process_read_simple(&mc_model_checker->process, &size, + MC_process_read_simple(&mc_model_checker->process(), &size, remote_size, sizeof(size)); type = "iRecv"; @@@ -311,7 -309,7 +311,7 @@@ s_smx_synchro_t synchro; smx_synchro_t act; if (use_remote_comm) { - MC_process_read_simple(&mc_model_checker->process, &synchro, + MC_process_read_simple(&mc_model_checker->process(), &synchro, remote_act, sizeof(synchro)); act = &synchro; } else @@@ -336,7 -334,7 +336,7 @@@ s_smx_synchro_t synchro; smx_synchro_t act; if (use_remote_comm) { - MC_process_read_simple(&mc_model_checker->process, &synchro, + MC_process_read_simple(&mc_model_checker->process(), &synchro, remote_act, sizeof(synchro)); act = &synchro; } else @@@ -368,11 -366,11 +368,11 @@@ case SIMCALL_COMM_WAITANY: { type = "WaitAny"; s_xbt_dynar_t comms; - MC_process_read_simple(&mc_model_checker->process, + MC_process_read_simple(&mc_model_checker->process(), &comms, simcall_comm_waitany__get__comms(req), sizeof(comms)); if (!xbt_dynar_is_empty(&comms)) { smx_synchro_t remote_sync; - MC_process_read_dynar_element(&mc_model_checker->process, + MC_process_read_dynar_element(&mc_model_checker->process(), &remote_sync, simcall_comm_waitany__get__comms(req), value, sizeof(remote_sync)); char* p = pointer_to_string(remote_sync); @@@ -393,7 -391,7 +393,7 @@@ type = "TestAny"; args = bprintf("(%d of %lu)", value + 1, - MC_process_read_dynar_length(&mc_model_checker->process, + MC_process_read_dynar_length(&mc_model_checker->process(), simcall_comm_testany__get__comms(req))); } break; @@@ -402,10 -400,10 +402,10 @@@ type = "Mutex LOCK"; s_smx_mutex_t mutex; - MC_process_read_simple(&mc_model_checker->process, &mutex, + MC_process_read_simple(&mc_model_checker->process(), &mutex, simcall_mutex_lock__get__mutex(req), sizeof(mutex)); s_xbt_swag_t mutex_sleeping; - MC_process_read_simple(&mc_model_checker->process, &mutex_sleeping, + MC_process_read_simple(&mc_model_checker->process(), &mutex_sleeping, mutex.sleeping, sizeof(mutex_sleeping)); args = bprintf("locked = %d, owner = %d, sleeping = %d", @@@ -458,13 -456,13 +458,13 @@@ unsigned int MC_request_testany_fail(sm // Read the dynar: s_xbt_dynar_t comms; - MC_process_read_simple(&mc_model_checker->process, + MC_process_read_simple(&mc_model_checker->process(), &comms, simcall_comm_testany__get__comms(req), sizeof(comms)); // Read ther dynar buffer: size_t buffer_size = comms.elmsize * comms.used; char buffer[buffer_size]; - MC_process_read_simple(&mc_model_checker->process, + MC_process_read_simple(&mc_model_checker->process(), buffer, comms.data, buffer_size); // Iterate over the elements: @@@ -473,12 -471,12 +473,12 @@@ for (cursor=0; cursor != comms.used; ++cursor) { // Get the element: - smx_synchro_t remote_action; + smx_synchro_t remote_action = NULL; - memcpy(buffer + comms.elmsize * cursor, &remote_action, sizeof(remote_action)); + memcpy(&remote_action, buffer + comms.elmsize * cursor, sizeof(remote_action)); // Dereference the pointer: s_smx_synchro_t action; - MC_process_read_simple(&mc_model_checker->process, + MC_process_read_simple(&mc_model_checker->process(), &action, remote_action, sizeof(action)); // Finally so something useful about it: @@@ -501,14 -499,14 +501,14 @@@ int MC_request_is_enabled_by_idx(smx_si case SIMCALL_COMM_WAITANY: { MC_process_read_dynar_element( - &mc_model_checker->process, &remote_act, simcall_comm_waitany__get__comms(req), + &mc_model_checker->process(), &remote_act, simcall_comm_waitany__get__comms(req), idx, sizeof(remote_act)); } break; case SIMCALL_COMM_TESTANY: { MC_process_read_dynar_element( - &mc_model_checker->process, &remote_act, simcall_comm_testany__get__comms(req), + &mc_model_checker->process(), &remote_act, simcall_comm_testany__get__comms(req), idx, sizeof(remote_act)); } break; @@@ -518,7 -516,7 +518,7 @@@ } s_smx_synchro_t synchro; - MC_process_read_simple(&mc_model_checker->process, + MC_process_read_simple(&mc_model_checker->process(), &synchro, remote_act, sizeof(synchro)); return synchro.comm.src_proc && synchro.comm.dst_proc; } @@@ -564,7 -562,7 +564,7 @@@ char *MC_request_get_dot_output(smx_sim } else { smx_synchro_t remote_act = simcall_comm_wait__get__comm(req); s_smx_synchro_t synchro; - MC_process_read_simple(&mc_model_checker->process, &synchro, + MC_process_read_simple(&mc_model_checker->process(), &synchro, remote_act, sizeof(synchro)); smx_process_t src_proc = MC_smx_resolve_process(synchro.comm.src_proc); @@@ -587,7 -585,7 +587,7 @@@ case SIMCALL_COMM_TEST: { smx_synchro_t remote_act = simcall_comm_test__get__comm(req); s_smx_synchro_t synchro; - MC_process_read_simple(&mc_model_checker->process, &synchro, + MC_process_read_simple(&mc_model_checker->process(), &synchro, remote_act, sizeof(synchro)); if (synchro.comm.src_proc == NULL || synchro.comm.dst_proc == NULL) { if (issuer->smx_host) @@@ -609,7 -607,7 +609,7 @@@ case SIMCALL_COMM_WAITANY: { unsigned long comms_size = MC_process_read_dynar_length( - &mc_model_checker->process, simcall_comm_waitany__get__comms(req)); + &mc_model_checker->process(), simcall_comm_waitany__get__comms(req)); if (issuer->smx_host) label = bprintf("[(%lu)%s] WaitAny [%d of %lu]", issuer->pid, @@@ -686,5 -684,3 +686,5 @@@ return str; } + +} diff --combined src/mc/mc_unw_vmread.cpp index 55e348155b,2d7cb1e243..a4e567771c --- a/src/mc/mc_unw_vmread.cpp +++ b/src/mc/mc_unw_vmread.cpp @@@ -1,8 -1,4 +1,8 @@@ -#define _GNU_SOURCE +/* Copyright (c) 2015. The SimGrid Team. + * All rights reserved. */ + +/* 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. */ #include #include @@@ -12,8 -8,6 +12,8 @@@ #include "mc_unw.h" +extern "C" { + /** \file * Libunwind namespace implementation using process_vm_readv. *. @@@ -36,7 -30,7 +36,7 @@@ struct _UPT_info static inline pid_t _UPT_getpid(void* arg) { - struct _UPT_info* info = arg; + struct _UPT_info* info = (_UPT_info*) arg; return info->pid; } @@@ -48,7 -42,6 +48,6 @@@ static int access_mem(const unw_addr_sp { if (write) return - UNW_EINVAL; - ssize_t s; pid_t pid = _UPT_getpid(arg); size_t size = sizeof(unw_word_t); @@@ -58,9 -51,9 +57,9 @@@ struct iovec local = { valp, size }; struct iovec remote = { (void*) addr, size }; - s = process_vm_readv(pid, &local, 1, &remote, 1, 0); + ssize_t s = process_vm_readv(pid, &local, 1, &remote, 1, 0); if (s >= 0) { - if (s != size) + if ((size_t) s != size) return - UNW_EINVAL; else return 0; @@@ -112,5 -105,3 +111,5 @@@ unw_accessors_t mc_unw_vmread_accessor .resume = &_UPT_resume, .get_proc_name = &_UPT_get_proc_name }; + +} diff --combined src/simix/libsmx.c index 4ed7355718,f604cec2fd..9a182a1525 --- a/src/simix/libsmx.c +++ b/src/simix/libsmx.c @@@ -10,12 -10,10 +10,12 @@@ /* 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. */ +#include "mc/mc_replay.h" #include "smx_private.h" -#include "mc/mc_interface.h" +#include "mc/mc_forward.h" #include "xbt/ex.h" #include /* isfinite() */ +#include "mc/mc.h" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix); @@@ -739,7 -737,7 +739,7 @@@ void simcall_process_set_kill_time(smx_ if (simix_global->kill_process_function) { XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name, sg_host_name(process->smx_host)); - SIMIX_timer_set(kill_time, simix_global->kill_process_function, process); + process->kill_timer = SIMIX_timer_set(kill_time, simix_global->kill_process_function, process); } } } diff --combined src/simix/smx_global.c index 43b0787a3b,2689131134..afbc67c16b --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.c @@@ -13,11 -13,11 +13,11 @@@ #include "xbt/str.h" #include "xbt/ex.h" /* ex_backtrace_display */ #include "mc/mc.h" +#include "mc/mc_replay.h" #include "simgrid/sg_config.h" #ifdef HAVE_MC #include "mc/mc_private.h" -#include "mc/mc_model_checker.h" #include "mc/mc_protocol.h" #include "mc/mc_client.h" #endif @@@ -220,6 -220,8 +220,6 @@@ void SIMIX_global_init(int *argc, char MC_client_init(); MC_client_hello(); MC_client_handle_messages(); - } else { - mc_mode = MC_MODE_STANDALONE; } } #endif @@@ -514,7 -516,7 +514,7 @@@ void SIMIX_run(void * \param arg Parameters of the function * */ - XBT_INLINE void SIMIX_timer_set(double date, void *function, void *arg) + XBT_INLINE smx_timer_t SIMIX_timer_set(double date, void *function, void *arg) { smx_timer_t timer = xbt_new0(s_smx_timer_t, 1); @@@ -522,6 -524,16 +522,16 @@@ timer->func = function; timer->args = arg; xbt_heap_push(simix_timers, timer, date); + return timer; + } + /** @brief cancels a timer that was added earlier */ + XBT_INLINE void SIMIX_timer_remove(smx_timer_t timer) { + xbt_heap_rm_elm(simix_timers, timer, timer->date); + } + + /** @brief Returns the date at which the timer will trigger (or 0 if NULL timer) */ + XBT_INLINE double SIMIX_timer_get_date(smx_timer_t timer) { + return timer?timer->date:0; } /** diff --combined src/simix/smx_process.c index 8771f6ed32,d466c2c9d6..21a4ef8eb9 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@@ -9,7 -9,6 +9,7 @@@ #include "xbt/log.h" #include "xbt/dict.h" #include "mc/mc.h" +#include "mc/mc_replay.h" #include "mc/mc_client.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix, @@@ -50,6 -49,10 +50,10 @@@ void SIMIX_process_cleanup(smx_process_ SIMIX_process_on_exit_runall(process); + /* Unregister from the kill timer if any */ + if (process->kill_timer != NULL) + SIMIX_timer_remove(process->kill_timer); + /* cancel non-blocking communications */ smx_synchro_t synchro; while ((synchro = xbt_fifo_pop(process->comms))) { @@@ -158,7 -161,7 +162,7 @@@ void SIMIX_process_stop(smx_process_t a if (arg->auto_restart && !SIMIX_host_get_state(arg->smx_host)) { SIMIX_host_add_auto_restart_process(arg->smx_host,arg->name,arg->code, arg->data, sg_host_name(arg->smx_host), - arg->kill_time, + SIMIX_timer_get_date(arg->kill_timer), arg->argc,arg->argv,arg->properties, arg->auto_restart); } @@@ -261,7 -264,6 +265,6 @@@ void SIMIX_process_create(smx_process_ (*process)->code = code; (*process)->argc = argc; (*process)->argv = argv; - (*process)->kill_time = kill_time; XBT_VERB("Create context %s", (*process)->name); @@@ -291,7 -293,7 +294,7 @@@ if (kill_time > SIMIX_get_clock() && simix_global->kill_process_function) { XBT_DEBUG("Process %s(%s) will be kill at time %f", (*process)->name, sg_host_name((*process)->smx_host), kill_time); - SIMIX_timer_set(kill_time, simix_global->kill_process_function, *process); + (*process)->kill_timer = SIMIX_timer_set(kill_time, simix_global->kill_process_function, *process); } } } @@@ -953,18 -955,15 +956,15 @@@ void SIMIX_process_auto_restart_set(smx smx_process_t simcall_HANDLER_process_restart(smx_simcall_t simcall, smx_process_t process) { return SIMIX_process_restart(process, simcall->issuer); } - /** - * \brief Restart a process. - * Restart a process, starting it again from the beginning. - */ + /** @brief Restart a process, starting it again from the beginning. */ smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer) { XBT_DEBUG("Restarting process %s on %s", process->name, sg_host_name(process->smx_host)); //retrieve the arguments of the old process - //FIXME: Factorise this with SIMIX_host_add_auto_restart_process ? + //FIXME: Factorize this with SIMIX_host_add_auto_restart_process ? s_smx_process_arg_t arg; arg.code = process->code; arg.hostname = sg_host_name(process->smx_host); - arg.kill_time = process->kill_time; + arg.kill_time = SIMIX_timer_get_date(process->kill_timer); arg.argc = process->argc; arg.data = process->data; int i;