struct pollfd fds_[2];
/** String pool for host names */
// TODO, use std::unordered_set with heterogeneous comparison lookup (C++14)
- xbt_dict_t /* <hostname, NULL> */ hostnames_;
+ xbt_dict_t /* <hostname, nullptr> */ hostnames_;
// This is the parent snapshot of the current state:
PageStore page_store_;
std::unique_ptr<Process> process_;
return nullptr;
void *result = this->start_exec;
- if (this->start_rw != NULL && result > (void *) this->start_rw)
+ if (this->start_rw != nullptr && result > (void *) this->start_rw)
result = this->start_rw;
- if (this->start_ro != NULL && result > (void *) this->start_ro)
+ if (this->start_ro != nullptr && result > (void *) this->start_ro)
result = this->start_ro;
return result;
}
* name.
*
* \param var_name Name of the local variable (or parameter to ignore)
- * \param subprogram_name Name of the subprogram fo ignore (NULL for any)
+ * \param subprogram_name Name of the subprogram fo ignore (nullptr for any)
* \param subprogram (possibly inlined) Subprogram of the scope
* \param scope Current scope
*/
// ***** snapshot_page_manager
PageStore::PageStore(size_t size) :
- memory_(NULL), capacity_(0), top_index_(0)
+ memory_(nullptr), capacity_(0), top_index_(0)
{
// Using mmap in order to be able to expand the region
// by relocating it somewhere else in the virtual memory
// space:
- void* memory = ::mmap(NULL, size << xbt_pagebits, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, -1, 0);
+ void* memory = ::mmap(nullptr, size << xbt_pagebits, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, -1, 0);
if (memory == MAP_FAILED) {
xbt_die("Could not mmap initial snapshot pages.");
}
static void* getpage()
{
- return mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ return mmap(nullptr, getpagesize(), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
}
XBT_TEST_SUITE("mc_page_store", "Page store");
regmatch_t match;
if(regexec(&res->so_re, map_basename, 1, &match, 0))
- return NULL;
+ return nullptr;
char* libname = strndup(map_basename, match.rm_so);
int fd = open("/dev/zero", O_RDONLY);
if (fd<0)
xbt_die("Could not open /dev/zero");
- zero_buffer = mmap(NULL, zero_buffer_size, PROT_READ, MAP_SHARED, fd, 0);
+ zero_buffer = mmap(nullptr, zero_buffer_size, PROT_READ, MAP_SHARED, fd, 0);
if (zero_buffer == MAP_FAILED)
xbt_die("Could not map the zero buffer");
close(fd);
unw_destroy_addr_space(this->unw_underlying_addr_space);
_UPT_destroy(this->unw_underlying_context);
}
- this->unw_underlying_context = NULL;
- this->unw_underlying_addr_space = NULL;
+ this->unw_underlying_context = nullptr;
+ this->unw_underlying_addr_space = nullptr;
unw_destroy_addr_space(this->unw_addr_space);
- this->unw_addr_space = NULL;
+ this->unw_addr_space = nullptr;
this->cache_flags = MC_PROCESS_CACHE_FLAG_NONE;
this->maestro_stack_start_ = nullptr;
this->maestro_stack_end_ = nullptr;
this->object_infos.resize(0);
- this->binary_info = NULL;
- this->libsimgrid_info = NULL;
+ this->binary_info = nullptr;
+ this->libsimgrid_info = nullptr;
struct s_mc_memory_map_re res;
std::vector<simgrid::xbt::VmMap> const& maps = this->memory_map_;
- const char* current_name = NULL;
+ const char* current_name = nullptr;
this->object_infos.resize(0);
// Nothing to do
if (maps[i].pathname.empty()) {
- current_name = NULL;
+ current_name = nullptr;
continue;
}
this->maestro_stack_start_ = remote(reg.start_addr);
this->maestro_stack_end_ = remote(reg.end_addr);
}
- current_name = NULL;
+ current_name = nullptr;
continue;
}
continue;
const bool is_executable = !i;
- char* libname = NULL;
+ char* libname = nullptr;
if (!is_executable) {
libname = MC_get_lib_name(pathname, &res);
if(!libname)
return object_info;
}
}
- return NULL;
+ return nullptr;
}
std::shared_ptr<ObjectInformation> Process::find_object_info_exec(remote_ptr<void> addr) const
return var;
}
- return NULL;
+ return nullptr;
}
void Process::read_variable(const char* name, void* target, size_t size) const
char* Process::read_string(remote_ptr<void> address) const
{
if (!address)
- return NULL;
+ return nullptr;
off_t len = 128;
char* res = (char*) malloc(len);
RegionSnapshot const* ref_region)
{
simgrid::mc::Process* process = &mc_model_checker->process();
- assert(process != NULL);
+ assert(process != nullptr);
bool use_soft_dirty = _sg_mc_sparse_checkpoint && _sg_mc_soft_dirty
&& ref_region != nullptr
return TRUE;
} else {
/* On the other hand if it hasn't a timeout, check if the comm is ready.*/
- if (act->comm.detached && act->comm.src_proc == NULL
+ if (act->comm.detached && act->comm.src_proc == nullptr
&& act->comm.type == SIMIX_COMM_READY)
- return (act->comm.dst_proc != NULL);
+ return (act->comm.dst_proc != nullptr);
}
return (act->comm.src_proc && act->comm.dst_proc);
mutex = &temp_mutex;
}
#endif
- if(mutex->owner == NULL)
+ if(mutex->owner == nullptr)
return TRUE;
else
#ifdef HAVE_MC
}
unsigned i;
- mc_smx_process_info_t pi = NULL;
+ mc_smx_process_info_t pi = nullptr;
xbt_dynar_foreach_ptr(mc_model_checker->process().smx_process_infos, i, pi) {
if (req == &pi->copy.simcall) {
void *start_heap = heap->base;
void *end_heap = heap->breakval;
- add_region(n, snapshot, simgrid::mc::RegionType::Heap, NULL,
+ add_region(n, snapshot, simgrid::mc::RegionType::Heap, nullptr,
start_heap, start_heap,
(char *) end_heap - (char *) start_heap);
snapshot->heap_bytes_used = mmalloc_get_bytes_used_remote(
new_var.region = region_type;
new_var.address = nullptr;
- if (current_variable.address != NULL) {
+ if (current_variable.address != nullptr) {
new_var.address = current_variable.address;
} else if (!current_variable.location_list.empty()) {
simgrid::dwarf::Location location =
xbt_die("Unexpected buffer is too small for fd_dir_path");
DIR* fd_dir = opendir(fd_dir_path);
- if (fd_dir == NULL)
+ if (fd_dir == nullptr)
xbt_die("Cannot open directory '/proc/self/fd'\n");
std::vector<s_fd_infos_t> fds;
continue;
// If dot_output enabled, do not handle the corresponding file
- if (dot_output != NULL && strcmp(xbt_basename(link), _sg_mc_dot_output_file) == 0)
+ if (dot_output != nullptr && strcmp(xbt_basename(link), _sg_mc_dot_output_file) == 0)
continue;
// This is probably a shared memory used by lttng-ust:
mc_client->active = 1;
// Waiting for the model-checker:
- if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) == -1 || raise(SIGSTOP) != 0)
+ if (ptrace(PTRACE_TRACEME, 0, nullptr, NULL) == -1 || raise(SIGSTOP) != 0)
xbt_die("Could not wait for the model-checker");
MC_client_handle_messages();
}
return TAG_DIFF;
if (comm1->data_size != comm2->data_size)
return DATA_SIZE_DIFF;
- if(comm1->data == NULL && comm2->data == NULL)
+ if(comm1->data == nullptr && comm2->data == NULL)
return NONE_DIFF;
- if(comm1->data != NULL && comm2->data !=NULL) {
+ if(comm1->data != nullptr && comm2->data !=NULL) {
if (!memcmp(comm1->data, comm2->data, comm1->data_size))
return NONE_DIFF;
return DATA_DIFF;
res = bprintf("%s\n Different data for communication #%d", type, cursor);
break;
default:
- res = NULL;
+ res = nullptr;
break;
}
comm_pattern->dst_proc = dst_proc->pid;
comm_pattern->src_host = MC_smx_process_get_host_name(src_proc);
comm_pattern->dst_host = MC_smx_process_get_host_name(dst_proc);
- if (comm_pattern->data_size == -1 && comm.comm.src_buff != NULL) {
+ if (comm_pattern->data_size == -1 && comm.comm.src_buff != nullptr) {
size_t buff_size;
mc_model_checker->process().read(
&buff_size, remote(comm.comm.dst_buff_size));
if (diff != NONE_DIFF) {
if (comm->type == SIMIX_COMM_SEND){
initial_global_state->send_deterministic = 0;
- if(initial_global_state->send_diff != NULL)
+ if(initial_global_state->send_diff != nullptr)
xbt_free(initial_global_state->send_diff);
initial_global_state->send_diff = print_determinism_result(diff, process, comm, list->index_comm + 1);
}else{
initial_global_state->recv_deterministic = 0;
- if(initial_global_state->recv_diff != NULL)
+ if(initial_global_state->recv_diff != nullptr)
xbt_free(initial_global_state->recv_diff);
initial_global_state->recv_diff = print_determinism_result(diff, process, comm, list->index_comm + 1);
}
XBT_INFO("*********************************************************");
XBT_INFO("%s", initial_global_state->send_diff);
xbt_free(initial_global_state->send_diff);
- initial_global_state->send_diff = NULL;
+ initial_global_state->send_diff = nullptr;
MC_print_statistics(mc_stats);
mc_model_checker->exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
}else if(_sg_mc_comms_determinism && (!initial_global_state->send_deterministic && !initial_global_state->recv_deterministic)) {
XBT_INFO("%s", initial_global_state->send_diff);
XBT_INFO("%s", initial_global_state->recv_diff);
xbt_free(initial_global_state->send_diff);
- initial_global_state->send_diff = NULL;
+ initial_global_state->send_diff = nullptr;
xbt_free(initial_global_state->recv_diff);
- initial_global_state->recv_diff = NULL;
+ initial_global_state->recv_diff = nullptr;
MC_print_statistics(mc_stats);
mc_model_checker->exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
}
mc_comm_pattern_t pattern = xbt_new0(s_mc_comm_pattern_t, 1);
pattern->data_size = -1;
- pattern->data = NULL;
+ pattern->data = nullptr;
pattern->index =
initial_pattern->index_comm + xbt_dynar_length(incomplete_pattern);
(std::uint64_t) simcall_comm_isend__get__data(request));
pattern->tag = mpi_request.tag;
- if(synchro.comm.src_buff != NULL){
+ if(synchro.comm.src_buff != nullptr){
pattern->data_size = synchro.comm.src_buff_size;
pattern->data = xbt_malloc0(pattern->data_size);
mc_model_checker->process().read_bytes(
static void MC_pre_modelcheck_comm_determinism(void)
{
- mc_state_t initial_state = NULL;
+ mc_state_t initial_state = nullptr;
smx_process_t process;
int i;
const int maxpid = MC_smx_get_maxpid();
// Create incomplete_communications_pattern elements:
incomplete_communications_pattern = xbt_dynar_new(sizeof(xbt_dynar_t), xbt_dynar_free_voidp);
for (i=0; i < maxpid; i++){
- xbt_dynar_t process_pattern = xbt_dynar_new(sizeof(mc_comm_pattern_t), NULL);
+ xbt_dynar_t process_pattern = xbt_dynar_new(sizeof(mc_comm_pattern_t), nullptr);
xbt_dynar_insert_at(incomplete_communications_pattern, i, &process_pattern);
}
static int MC_modelcheck_comm_determinism_main(void)
{
- char *req_str = NULL;
+ char *req_str = nullptr;
int value;
- mc_visited_state_t visited_state = NULL;
- smx_simcall_t req = NULL;
- smx_process_t process = NULL;
- mc_state_t state = NULL, next_state = NULL;
+ mc_visited_state_t visited_state = nullptr;
+ smx_simcall_t req = nullptr;
+ smx_process_t process = nullptr;
+ mc_state_t state = nullptr, next_state = NULL;
while (xbt_fifo_size(mc_stack) > 0) {
if ((xbt_fifo_size(mc_stack) <= _sg_mc_max_depth)
&& (req = MC_state_get_request(state, &value))
- && (visited_state == NULL)) {
+ && (visited_state == nullptr)) {
req_str = MC_request_to_string(req, value, MC_REQUEST_SIMIX);
XBT_DEBUG("Execute: %s", req_str);
xbt_free(req_str);
- if (dot_output != NULL) {
+ if (dot_output != nullptr) {
req_str = MC_request_get_dot_output(req, value);
}
if(!initial_global_state->initial_communications_pattern_done)
MC_handle_comm_pattern(call, req, value, initial_communications_pattern, 0);
else
- MC_handle_comm_pattern(call, req, value, NULL, 0);
+ MC_handle_comm_pattern(call, req, value, nullptr, 0);
/* Wait for requests (schedules processes) */
mc_model_checker->wait_for_requests();
/* Create the new expanded state */
next_state = MC_state_new();
- if ((visited_state = is_visited_state(next_state)) == NULL) {
+ if ((visited_state = is_visited_state(next_state)) == nullptr) {
/* Get enabled processes and insert them in the interleave set of the next state */
MC_EACH_SIMIX_PROCESS(process,
}
);
- if (dot_output != NULL)
+ if (dot_output != nullptr)
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", state->num, next_state->num, req_str);
} else {
- if (dot_output != NULL)
+ if (dot_output != nullptr)
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", state->num, visited_state->other_num == -1 ? visited_state->num : visited_state->other_num, req_str);
}
xbt_fifo_unshift(mc_stack, next_state);
- if (dot_output != NULL)
+ if (dot_output != nullptr)
xbt_free(req_str);
} else {
if (xbt_fifo_size(mc_stack) > _sg_mc_max_depth) {
XBT_WARN("/!\\ Max depth reached ! /!\\ ");
- } else if (visited_state != NULL) {
+ } else if (visited_state != nullptr) {
XBT_DEBUG("State already visited (equal to state %d), exploration stopped on this path.", visited_state->other_num == -1 ? visited_state->num : visited_state->other_num);
} else {
XBT_DEBUG("There are no more processes to interleave. (depth %d)", xbt_fifo_size(mc_stack));
MC_state_delete(state, !state->in_visited_states ? 1 : 0);
XBT_DEBUG("Delete state %d at depth %d", state->num, xbt_fifo_size(mc_stack) + 1);
- visited_state = NULL;
+ visited_state = nullptr;
/* Check for deadlocks */
if (MC_deadlock_check()) {
- MC_show_deadlock(NULL);
+ MC_show_deadlock(nullptr);
return SIMGRID_MC_EXIT_DEADLOCK;
}
- while ((state = (mc_state_t) xbt_fifo_shift(mc_stack)) != NULL) {
+ while ((state = (mc_state_t) xbt_fifo_shift(mc_stack)) != nullptr) {
if (MC_state_interleave_size(state) && xbt_fifo_size(mc_stack) < _sg_mc_max_depth) {
/* We found a back-tracking point, let's loop */
XBT_DEBUG("Back-tracking to state %d at depth %d", state->num, xbt_fifo_size(mc_stack) + 1);
initial_global_state->initial_communications_pattern_done = 0;
initial_global_state->recv_deterministic = 1;
initial_global_state->send_deterministic = 1;
- initial_global_state->recv_diff = NULL;
- initial_global_state->send_diff = NULL;
+ initial_global_state->recv_diff = nullptr;
+ initial_global_state->send_diff = nullptr;
return MC_modelcheck_comm_determinism_main();
}
res->comm_addr = comm->comm_addr;
res->rdv = xbt_strdup(comm->rdv);
res->data_size = -1;
- res->data = NULL;
+ res->data = nullptr;
if (comm->type == SIMIX_COMM_SEND) {
res->src_proc = comm->src_proc;
res->src_host = comm->src_host;
- if (comm->data != NULL) {
+ if (comm->data != nullptr) {
res->data_size = comm->data_size;
res->data = xbt_malloc0(comm->data_size);
memcpy(res->data, comm->data, comm->data_size);
void MC_state_copy_index_communications_pattern(mc_state_t state)
{
- state->index_comm = xbt_dynar_new(sizeof(unsigned int), NULL);
+ state->index_comm = xbt_dynar_new(sizeof(unsigned int), nullptr);
mc_list_comm_pattern_t list_process_comm;
unsigned int cursor;
xbt_dynar_foreach(initial_communications_pattern, cursor, list_process_comm){
case MC_CALL_TYPE_WAIT:
case MC_CALL_TYPE_WAITANY:
{
- smx_synchro_t comm_addr = NULL;
+ smx_synchro_t comm_addr = nullptr;
if (call_type == MC_CALL_TYPE_WAIT)
comm_addr = simcall_comm_wait__get__comm(req);
else
xbt_free(p->rdv);
xbt_free(p->data);
xbt_free(p);
- p = NULL;
+ p = nullptr;
}
static void MC_list_comm_pattern_free(mc_list_comm_pattern_t l)
{
xbt_dynar_free(&(l->list));
xbt_free(l);
- l = NULL;
+ l = nullptr;
}
void MC_comm_pattern_free_voidp(void *p)
return (addr_pointed1 != addr_pointed2);
} else {
- if (addr_pointed1 == NULL && addr_pointed2 == NULL)
+ if (addr_pointed1 == nullptr && addr_pointed2 == NULL)
return 0;
- if (addr_pointed1 == NULL || addr_pointed2 == NULL)
+ if (addr_pointed1 == nullptr || addr_pointed2 == NULL)
return 1;
if (!state.compared_pointers.insert(
std::make_pair(addr_pointed1, addr_pointed2)).second)
return 1;
// The pointers are both in the heap:
return compare_heap_area(process_index, addr_pointed1, addr_pointed2, snapshot1,
- snapshot2, NULL, type->subtype, pointer_level);
+ snapshot2, nullptr, type->subtype, pointer_level);
}
// The pointers are both in the current object R/W segment:
int _sg_mc_sparse_checkpoint = 0;
int _sg_mc_soft_dirty = 0;
int _sg_mc_ksm = 0;
-char *_sg_mc_property_file = NULL;
+char *_sg_mc_property_file = nullptr;
int _sg_mc_hash = 0;
int _sg_mc_max_depth = 1000;
int _sg_mc_visited = 0;
-char *_sg_mc_dot_output_file = NULL;
+char *_sg_mc_dot_output_file = nullptr;
int _sg_mc_comms_determinism = 0;
int _sg_mc_send_determinism = 0;
int _sg_mc_safety = 0;
static void heap_area_pair_free(heap_area_pair_t pair)
{
xbt_free(pair);
- pair = NULL;
+ pair = nullptr;
}
static void heap_area_pair_free_voidp(void *d)
static void heap_area_free(heap_area_t area)
{
xbt_free(area);
- area = NULL;
+ area = nullptr;
}
/************************************************************************************/
{
if (is_new_heap_area_pair(list, block1, fragment1, block2, fragment2)) {
- heap_area_pair_t pair = NULL;
+ heap_area_pair_t pair = nullptr;
pair = xbt_new0(s_heap_area_pair_t, 1);
pair->block1 = block1;
pair->fragment1 = fragment1;
std::vector<simgrid::mc::IgnoredHeapRegion>* i1,
std::vector<simgrid::mc::IgnoredHeapRegion>* i2)
{
- if (mc_diff_info == NULL) {
+ if (mc_diff_info == nullptr) {
mc_diff_info = xbt_new0(struct s_mc_diff, 1);
- mc_diff_info->equals_to1 = NULL;
- mc_diff_info->equals_to2 = NULL;
- mc_diff_info->types1 = NULL;
- mc_diff_info->types2 = NULL;
+ mc_diff_info->equals_to1 = nullptr;
+ mc_diff_info->equals_to2 = nullptr;
+ mc_diff_info->types1 = nullptr;
+ mc_diff_info->types2 = nullptr;
}
struct s_mc_diff *state = mc_diff_info;
res_compare =
compare_heap_area(simgrid::mc::ProcessIndexMissing, addr_block1, addr_block2, snapshot1, snapshot2,
- NULL, NULL, 0);
+ nullptr, NULL, 0);
if (res_compare != 1) {
for (k = 1; k < heapinfo2->busy_block.size; k++)
res_compare =
compare_heap_area(simgrid::mc::ProcessIndexMissing, addr_block1, addr_block2, snapshot1, snapshot2,
- NULL, NULL, 0);
+ nullptr, NULL, 0);
if (res_compare != 1) {
for (k = 1; k < heapinfo2b->busy_block.size; k++)
res_compare =
compare_heap_area(simgrid::mc::ProcessIndexMissing, addr_frag1, addr_frag2, snapshot1, snapshot2,
- NULL, NULL, 0);
+ nullptr, NULL, 0);
if (res_compare != 1)
equal = 1;
res_compare =
compare_heap_area(simgrid::mc::ProcessIndexMissing, addr_frag1, addr_frag2, snapshot2, snapshot2,
- NULL, NULL, 0);
+ nullptr, NULL, 0);
if (res_compare != 1) {
equal = 1;
// Both addreses are in the heap:
res_compare =
compare_heap_area(process_index, addr_pointed1, addr_pointed2, snapshot1,
- snapshot2, previous, NULL, 0);
+ snapshot2, previous, nullptr, 0);
if (res_compare == 1) {
return res_compare;
}
if (area_size > type->byte_size && area_size % type->byte_size == 0)
return type;
else
- return NULL;
+ return nullptr;
} else {
for(simgrid::mc::Member& member : type->members) {
}
}
- return NULL;
+ return nullptr;
}
break;
default:
/* FIXME : other cases ? */
- return NULL;
+ return nullptr;
break;
}
}
* @param area2 Process address for state 2
* @param snapshot1 Snapshot of state 1
* @param snapshot2 Snapshot of state 2
- * @param previous Pairs of blocks already compared on the current path (or NULL)
+ * @param previous Pairs of blocks already compared on the current path (or nullptr)
* @param type_id Type of variable
* @param pointer_level
* @return 0 (same), 1 (different), -1
int type_size = -1;
int offset1 = 0, offset2 = 0;
int new_size1 = -1, new_size2 = -1;
- simgrid::mc::Type *new_type1 = NULL, *new_type2 = NULL;
+ simgrid::mc::Type *new_type1 = nullptr, *new_type2 = NULL;
int match_pairs = 0;
malloc_info heapinfo_temp1, heapinfo_temp2;
- if (previous == NULL) {
+ if (previous == nullptr) {
previous =
xbt_dynar_new(sizeof(heap_area_pair_t), heap_area_pair_free_voidp);
match_pairs = 1;
type = type->full_type;
// This assume that for "boring" types (volatile ...) byte_size is absent:
- while (type->byte_size == 0 && type->subtype != NULL)
+ while (type->byte_size == 0 && type->subtype != nullptr)
type = type->subtype;
// Find type_size:
// Remember (basic) type inference.
// The current data structure only allows us to do this for the whole block.
- if (type != NULL && area1 == real_addr_block1) {
+ if (type != nullptr && area1 == real_addr_block1) {
state->types1_(block1, 0) = type;
}
- if (type != NULL && area2 == real_addr_block2) {
+ if (type != nullptr && area2 == real_addr_block2) {
state->types2_(block2, 0) = type;
}
// Remember (basic) type inference.
// The current data structure only allows us to do this for the whole fragment.
- if (type != NULL && area1 == real_addr_frag1) {
+ if (type != nullptr && area1 == real_addr_frag1) {
state->types1_(block1, frag1) = type;
}
- if (type != NULL && area2 == real_addr_frag2) {
+ if (type != nullptr && area2 == real_addr_frag2) {
state->types2_(block2, frag2) = type;
}
// The type of the variable is already known:
new_type2 = type;
}
// Type inference from the block type.
- else if (state->types1_(block1, frag1) != NULL
- || state->types2_(block2, frag2) != NULL) {
+ else if (state->types1_(block1, frag1) != nullptr
+ || state->types2_(block2, frag2) != nullptr) {
offset1 = (char *) area1 - (char *) real_addr_frag1;
offset2 = (char *) area2 - (char *) real_addr_frag2;
- if (state->types1_(block1, frag1) != NULL
- && state->types2_(block2, frag2) != NULL) {
+ if (state->types1_(block1, frag1) != nullptr
+ && state->types2_(block2, frag2) != nullptr) {
new_type1 =
get_offset_type(real_addr_frag1, state->types1_(block1, frag1),
offset1, size, snapshot1, process_index);
new_type2 =
get_offset_type(real_addr_frag2, state->types2_(block2, frag2),
offset1, size, snapshot2, process_index);
- } else if (state->types1_(block1, frag1) != NULL) {
+ } else if (state->types1_(block1, frag1) != nullptr) {
new_type1 =
get_offset_type(real_addr_frag1, state->types1_(block1, frag1),
offset1, size, snapshot1, process_index);
new_type2 =
get_offset_type(real_addr_frag2, state->types1_(block1, frag1),
offset2, size, snapshot2, process_index);
- } else if (state->types2_(block2, frag2) != NULL) {
+ } else if (state->types2_(block2, frag2) != nullptr) {
new_type1 =
get_offset_type(real_addr_frag1, state->types2_(block2, frag2),
offset1, size, snapshot1, process_index);
return -1;
}
- if (new_type1 != NULL && new_type2 != NULL && new_type1 != new_type2) {
+ if (new_type1 != nullptr && new_type2 != NULL && new_type1 != new_type2) {
type = new_type1;
- while (type->byte_size == 0 && type->subtype != NULL)
+ while (type->byte_size == 0 && type->subtype != nullptr)
type = type->subtype;
new_size1 = type->byte_size;
type = new_type2;
- while (type->byte_size == 0 && type->subtype != NULL)
+ while (type->byte_size == 0 && type->subtype != nullptr)
type = type->subtype;
new_size2 = type->byte_size;
struct s_mc_diff *state = mc_diff_info;
- if (heap1 == NULL && heap1 == NULL) {
+ if (heap1 == nullptr && heap1 == NULL) {
XBT_DEBUG("Malloc descriptors null");
return 0;
}
/** \brief Get the DW_TAG_type of the DIE
*
* \param die DIE
- * \return DW_TAG_type attribute as a new string (NULL if none)
+ * \return DW_TAG_type attribute as a new string (nullptr if none)
*/
static std::uint64_t MC_dwarf_at_type(Dwarf_Die * die);
{
Dwarf_Attribute attr;
if (!dwarf_attr_integrate(die, attribute, &attr)) {
- return NULL;
+ return nullptr;
} else {
return dwarf_formstring(&attr);
}
* DW_AT_MIPS_linkage_name is used (at least by GCC).
*
* \param the DIE
- * \return linkage name of the given DIE (or NULL)
+ * \return linkage name of the given DIE (or nullptr)
* */
static const char *MC_dwarf_at_linkage_name(Dwarf_Die * die)
{
return 0;
dwarf_attr_integrate(die, attribute, &attr);
Dwarf_Die subtype_die;
- if (dwarf_formref_die(&attr, &subtype_die) == NULL)
+ if (dwarf_formref_die(&attr, &subtype_die) == nullptr)
xbt_die("Could not find DIE");
return dwarf_dieoffset(&subtype_die);
}
return 0;
dwarf_attr_integrate(die, DW_AT_type, &attr);
Dwarf_Die subtype_die;
- if (dwarf_formref_die(&attr, &subtype_die) == NULL)
+ if (dwarf_formref_die(&attr, &subtype_die) == nullptr)
xbt_die("Could not find DIE");
return dwarf_dieoffset(&subtype_die);
}
/** \brief Find the type/subtype (DW_AT_type) for a DIE
*
* \param dit the DIE
- * \return DW_AT_type reference as a global offset in hexadecimal (or NULL)
+ * \return DW_AT_type reference as a global offset in hexadecimal (or nullptr)
*/
static
std::uint64_t MC_dwarf_at_type(Dwarf_Die * die)
static uint64_t MC_dwarf_attr_integrate_addr(Dwarf_Die * die, int attribute)
{
Dwarf_Attribute attr;
- if (dwarf_attr_integrate(die, attribute, &attr) == NULL)
+ if (dwarf_attr_integrate(die, attribute, &attr) == nullptr)
return 0;
Dwarf_Addr value;
if (dwarf_formaddr(&attr, &value) == 0)
uint64_t default_value)
{
Dwarf_Attribute attr;
- if (dwarf_attr_integrate(die, attribute, &attr) == NULL)
+ if (dwarf_attr_integrate(die, attribute, &attr) == nullptr)
return default_value;
Dwarf_Word value;
return dwarf_formudata(dwarf_attr_integrate(die, attribute, &attr),
}
const char *name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
- if (name != NULL) {
+ if (name != nullptr) {
char* full_name = ns ? bprintf("%s%s::%s", prefix, ns, name) :
bprintf("%s%s", prefix, name);
type.name = std::string(full_name);
case DW_TAG_union_type:
case DW_TAG_class_type:
MC_dwarf_add_members(info, die, unit, &type);
- char *new_ns = ns == NULL ? xbt_strdup(type.name.c_str())
+ char *new_ns = ns == nullptr ? xbt_strdup(type.name.c_str())
: bprintf("%s::%s", ns, name);
MC_dwarf_handle_children(info, die, unit, frame, new_ns);
free(new_ns);
return nullptr;
Dwarf_Attribute attr_location;
- if (dwarf_attr(die, DW_AT_location, &attr_location) == NULL)
+ if (dwarf_attr(die, DW_AT_location, &attr_location) == nullptr)
// No location: do not add it ?
return nullptr;
std::unique_ptr<simgrid::mc::Variable> variable =
std::unique_ptr<simgrid::mc::Variable>(new simgrid::mc::Variable());
variable->dwarf_offset = dwarf_dieoffset(die);
- variable->global = frame == NULL; // Can be override base on DW_AT_location
+ variable->global = frame == nullptr; // Can be override base on DW_AT_location
variable->object_info = info;
const char *name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
default:
xbt_die
("Unhandled form 0x%x, class 0x%X for DW_AT_start_scope of variable %s",
- form, (int) form_class, name == NULL ? "?" : name);
+ form, (int) form_class, name == nullptr ? "?" : name);
}
}
const char *name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
if (frame)
xbt_die("Unexpected namespace in a subprogram");
- char *new_ns = ns == NULL ? xbt_strdup(name)
+ char *new_ns = ns == nullptr ? xbt_strdup(name)
: bprintf("%s::%s", ns, name);
MC_dwarf_handle_children(info, die, unit, frame, new_ns);
xbt_free(new_ns);
if (fd < 0)
xbt_die("Could not open file %s", info->file_name.c_str());
Dwarf *dwarf = dwarf_begin(fd, DWARF_C_READ);
- if (dwarf == NULL)
+ if (dwarf == nullptr)
xbt_die("Missing debugging information in %s\n"
"Your program and its dependencies must have debugging information.\n"
"You might want to recompile with -g or install the suitable debugging package.\n",
Dwarf_Off next_offset = 0;
size_t length;
- while (dwarf_nextcu(dwarf, offset, &next_offset, &length, NULL, NULL, NULL) ==
+ while (dwarf_nextcu(dwarf, offset, &next_offset, &length, nullptr, NULL, NULL) ==
0) {
Dwarf_Die unit_die;
- if (dwarf_offdie(dwarf, offset + length, &unit_die) != NULL)
- MC_dwarf_handle_children(info, &unit_die, &unit_die, NULL, NULL);
+ if (dwarf_offdie(dwarf, offset + length, &unit_die) != nullptr)
+ MC_dwarf_handle_children(info, &unit_die, &unit_die, nullptr, NULL);
offset = next_offset;
}
e_mc_mode_t mc_mode;
-double *mc_time = NULL;
+double *mc_time = nullptr;
#ifdef HAVE_MC
int user_max_depth_reached = 0;
/* MC global data structures */
-mc_state_t mc_current_state = NULL;
+mc_state_t mc_current_state = nullptr;
char mc_replay_mode = FALSE;
-mc_stats_t mc_stats = NULL;
-mc_global_t initial_global_state = NULL;
-xbt_fifo_t mc_stack = NULL;
+mc_stats_t mc_stats = nullptr;
+mc_global_t initial_global_state = nullptr;
+xbt_fifo_t mc_stack = nullptr;
/* Liveness */
-xbt_automaton_t _mc_property_automaton = NULL;
+xbt_automaton_t _mc_property_automaton = nullptr;
/* Dot output */
-FILE *dot_output = NULL;
+FILE *dot_output = nullptr;
const char *colors[13];
dot_output = fopen(_sg_mc_dot_output_file, "w");
- if (dot_output == NULL) {
+ if (dot_output == nullptr) {
perror("Error open dot output file");
xbt_abort();
}
{
int value, count = 1;
char *req_str;
- smx_simcall_t req = NULL, saved_req = NULL;
+ smx_simcall_t req = nullptr, saved_req = NULL;
xbt_fifo_item_t item, start_item;
mc_state_t state;
MC_simcall_handle(req, value);
if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
- MC_handle_comm_pattern(call, req, value, NULL, 1);
+ MC_handle_comm_pattern(call, req, value, nullptr, 1);
mc_model_checker->wait_for_requests();
void MC_replay_liveness(xbt_fifo_t stack)
{
xbt_fifo_item_t item;
- mc_pair_t pair = NULL;
- mc_state_t state = NULL;
- smx_simcall_t req = NULL, saved_req = NULL;
+ mc_pair_t pair = nullptr;
+ mc_state_t state = nullptr;
+ smx_simcall_t req = nullptr, saved_req = NULL;
int value, depth = 1;
char *req_str;
saved_req = MC_state_get_executed_request(state, &value);
- if (saved_req != NULL) {
+ if (saved_req != nullptr) {
/* because we got a copy of the executed request, we have to fetch the
real one, pointed by the request field of the issuer process */
const smx_process_t issuer = MC_smx_simcall_get_issuer(saved_req);
mc_state_t state;
- while ((state = (mc_state_t) xbt_fifo_pop(stack)) != NULL)
+ while ((state = (mc_state_t) xbt_fifo_pop(stack)) != nullptr)
MC_state_delete(state, !state->in_visited_states ? 1 : 0);
}
mc_state_t state;
xbt_fifo_item_t item;
smx_simcall_t req;
- char *req_str = NULL;
+ char *req_str = nullptr;
for (item = xbt_fifo_get_last_item(stack);
item; item = xbt_fifo_get_prev_item(item)) {
void MC_show_deadlock(smx_simcall_t req)
{
- /*char *req_str = NULL; */
+ /*char *req_str = nullptr; */
XBT_INFO("**************************");
XBT_INFO("*** DEAD-LOCK DETECTED ***");
XBT_INFO("**************************");
mc_pair_t pair;
xbt_fifo_item_t item;
smx_simcall_t req;
- char *req_str = NULL;
+ char *req_str = nullptr;
for (item = xbt_fifo_get_last_item(stack);
item; item = xbt_fifo_get_prev_item(item)) {
void MC_dump_stack_liveness(xbt_fifo_t stack)
{
mc_pair_t pair;
- while ((pair = (mc_pair_t) xbt_fifo_pop(stack)) != NULL)
+ while ((pair = (mc_pair_t) xbt_fifo_pop(stack)) != nullptr)
MC_pair_delete(pair);
}
XBT_INFO("Visited pairs = %lu", stats->visited_pairs);
}
XBT_INFO("Executed transitions = %lu", stats->executed_transitions);
- if ((_sg_mc_dot_output_file != NULL) && (_sg_mc_dot_output_file[0] != '\0')) {
+ if ((_sg_mc_dot_output_file != nullptr) && (_sg_mc_dot_output_file[0] != '\0')) {
fprintf(dot_output, "}\n");
fclose(dot_output);
}
- if (initial_global_state != NULL && (_sg_mc_comms_determinism || _sg_mc_send_determinism)) {
+ if (initial_global_state != nullptr && (_sg_mc_comms_determinism || _sg_mc_send_determinism)) {
XBT_INFO("Send-deterministic : %s", !initial_global_state->send_deterministic ? "No" : "Yes");
if (_sg_mc_comms_determinism)
XBT_INFO("Recv-deterministic : %s", !initial_global_state->recv_deterministic ? "No" : "Yes");
void MC_automaton_load(const char *file)
{
- if (_mc_property_automaton == NULL)
+ if (_mc_property_automaton == nullptr)
_mc_property_automaton = xbt_automaton_new();
xbt_automaton_load(_mc_property_automaton, file);
double MC_process_clock_get(smx_process_t process)
{
if (mc_time) {
- if (process != NULL)
+ if (process != nullptr)
return mc_time[process->pid];
else
return -1;
static xbt_dynar_t get_atomic_propositions_values()
{
unsigned int cursor = 0;
- xbt_automaton_propositional_symbol_t ps = NULL;
- xbt_dynar_t values = xbt_dynar_new(sizeof(int), NULL);
+ xbt_automaton_propositional_symbol_t ps = nullptr;
+ xbt_dynar_t values = xbt_dynar_new(sizeof(int), nullptr);
xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps) {
int res = xbt_automaton_propositional_symbol_evaluate(ps);
xbt_dynar_push_as(values, int, res);
static mc_visited_pair_t is_reached_acceptance_pair(mc_pair_t pair)
{
- mc_visited_pair_t new_pair = NULL;
+ mc_visited_pair_t new_pair = nullptr;
new_pair = MC_visited_pair_new(pair->num, pair->automaton_state, pair->atomic_propositions, pair->graph_state);
new_pair->acceptance_pair = 1;
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 (dot_output != NULL)
+ 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 NULL;
+ return nullptr;
}
}
}
static void remove_acceptance_pair(int pair_num)
{
unsigned int cursor = 0;
- mc_visited_pair_t pair_test = NULL;
+ mc_visited_pair_t pair_test = nullptr;
int pair_found = 0;
xbt_dynar_foreach(acceptance_pairs, cursor, pair_test) {
}
case 3:{
unsigned int cursor = 0;
- xbt_automaton_propositional_symbol_t p = NULL;
+ xbt_automaton_propositional_symbol_t p = nullptr;
xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, p) {
if (std::strcmp(xbt_automaton_propositional_symbol_get_name(p), l->u.predicat) == 0)
return (int) xbt_dynar_get_as(atomic_propositions_values, cursor, int);
static void MC_pre_modelcheck_liveness(void)
{
- mc_pair_t initial_pair = NULL;
+ mc_pair_t initial_pair = nullptr;
smx_process_t process;
mc_model_checker->wait_for_requests();
- acceptance_pairs = xbt_dynar_new(sizeof(mc_visited_pair_t), NULL);
+ acceptance_pairs = xbt_dynar_new(sizeof(mc_visited_pair_t), nullptr);
if(_sg_mc_visited > 0)
- visited_pairs = xbt_dynar_new(sizeof(mc_visited_pair_t), NULL);
+ visited_pairs = xbt_dynar_new(sizeof(mc_visited_pair_t), nullptr);
initial_global_state->snapshot = simgrid::mc::take_snapshot(0);
initial_global_state->prev_pair = 0;
static int MC_modelcheck_liveness_main(void)
{
- smx_process_t process = NULL;
- mc_pair_t current_pair = NULL;
+ smx_process_t process = nullptr;
+ mc_pair_t current_pair = nullptr;
int value, res, visited_num = -1;
- smx_simcall_t req = NULL;
- xbt_automaton_transition_t transition_succ = NULL;
+ smx_simcall_t req = nullptr;
+ xbt_automaton_transition_t transition_succ = nullptr;
int cursor = 0;
- mc_pair_t next_pair = NULL;
- xbt_dynar_t prop_values = NULL;
- mc_visited_pair_t reached_pair = NULL;
+ mc_pair_t next_pair = nullptr;
+ xbt_dynar_t prop_values = nullptr;
+ mc_visited_pair_t reached_pair = nullptr;
while(xbt_fifo_size(mc_stack) > 0){
if (current_pair->automaton_state->type == 1 && current_pair->exploration_started == 0) {
/* If new acceptance pair, return new pair */
- if ((reached_pair = is_reached_acceptance_pair(current_pair)) == NULL) {
+ if ((reached_pair = is_reached_acceptance_pair(current_pair)) == nullptr) {
int counter_example_depth = current_pair->depth;
XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
XBT_INFO("| ACCEPTANCE CYCLE |");
/* Pair already visited ? stop the exploration on the current path */
if ((current_pair->exploration_started == 0) && (visited_num = is_visited_pair(reached_pair, current_pair)) != -1) {
- if (dot_output != NULL){
+ if (dot_output != nullptr){
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, visited_num, initial_global_state->prev_req);
fflush(dot_output);
}
req = MC_state_get_request(current_pair->graph_state, &value);
- if (dot_output != NULL) {
+ if (dot_output != nullptr) {
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);
/* 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 = (mc_pair_t) xbt_fifo_shift(mc_stack)) != NULL) {
+ while ((current_pair = (mc_pair_t) xbt_fifo_shift(mc_stack)) != nullptr) {
if (current_pair->requests > 0) {
/* We found a backtracking point */
XBT_DEBUG("Backtracking to depth %d", current_pair->depth);
* @param object Process address of the struct/class
* @param type Type of the struct/class
* @param member Member description
- * @param snapshot Snapshot (or NULL)
+ * @param snapshot Snapshot (or nullptr)
* @return Process address of the given member of the 'object' struct/class
*/
void *resolve_member(
return ((char *) base) + member->offset();
ExpressionContext state;
- state.frame_base = NULL;
- state.cursor = NULL;
+ state.frame_base = nullptr;
+ state.cursor = nullptr;
state.address_space = address_space;
state.process_index = process_index;
mc_pair_t MC_pair_new()
{
- mc_pair_t p = NULL;
+ mc_pair_t p = nullptr;
p = xbt_new0(s_mc_pair_t, 1);
p->num = ++mc_stats->expanded_pairs;
p->exploration_started = 0;
void MC_pair_delete(mc_pair_t p)
{
- p->automaton_state = NULL;
+ p->automaton_state = nullptr;
if(p->visited_pair_removed)
MC_state_delete(p->graph_state, 1);
xbt_dynar_free(&(p->atomic_propositions));
xbt_free(p);
- p = NULL;
+ p = nullptr;
}
}
if (r1->call == SIMCALL_COMM_WAIT
&& (r2->call == SIMCALL_COMM_WAIT || r2->call == SIMCALL_COMM_TEST)
- && (synchro1->comm.src_proc == NULL || synchro1->comm.dst_proc == NULL))
+ && (synchro1->comm.src_proc == nullptr || synchro1->comm.dst_proc == NULL))
return FALSE;
if (r1->call == SIMCALL_COMM_TEST &&
- (simcall_comm_test__get__comm(r1) == NULL
- || synchro1->comm.src_buff == NULL
- || synchro1->comm.dst_buff == NULL))
+ (simcall_comm_test__get__comm(r1) == nullptr
+ || synchro1->comm.src_buff == nullptr
+ || synchro1->comm.dst_buff == nullptr))
return FALSE;
if (r1->call == SIMCALL_COMM_TEST && r2->call == SIMCALL_COMM_WAIT
return FALSE;
if (r1->call == SIMCALL_COMM_WAIT && r2->call == SIMCALL_COMM_TEST
- && synchro1->comm.src_buff != NULL
- && synchro1->comm.dst_buff != NULL
- && synchro2->comm.src_buff != NULL
- && synchro2->comm.dst_buff != NULL
+ && synchro1->comm.src_buff != nullptr
+ && synchro1->comm.dst_buff != nullptr
+ && synchro2->comm.src_buff != nullptr
+ && synchro2->comm.dst_buff != nullptr
&& synchro1->comm.dst_buff != synchro2->comm.src_buff
&& synchro1->comm.dst_buff != synchro2->comm.dst_buff
&& synchro2->comm.dst_buff != synchro1->comm.src_buff)
if (synchro1->comm.src_buff == synchro2->comm.src_buff
&& synchro1->comm.dst_buff == synchro2->comm.dst_buff)
return FALSE;
- else if (synchro1->comm.src_buff != NULL
- && synchro1->comm.dst_buff != NULL
- && synchro2->comm.src_buff != NULL
- && synchro2->comm.dst_buff != NULL
+ else if (synchro1->comm.src_buff != nullptr
+ && synchro1->comm.dst_buff != nullptr
+ && synchro2->comm.src_buff != nullptr
+ && synchro2->comm.dst_buff != nullptr
&& synchro1->comm.dst_buff != synchro2->comm.src_buff
&& synchro1->comm.dst_buff != synchro2->comm.dst_buff
&& synchro2->comm.dst_buff != synchro1->comm.src_buff)
break;
}
- const char* type = NULL;
- char *args = NULL;
+ const char* type = nullptr;
+ char *args = nullptr;
smx_process_t issuer = MC_smx_simcall_get_issuer(req);
act = remote_act;
char* p;
- if (act->comm.src_proc == NULL || act->comm.dst_proc == NULL) {
+ if (act->comm.src_proc == nullptr || act->comm.dst_proc == NULL) {
type = "Test FALSE";
p = pointer_to_string(remote_act);
args = bprintf("comm=%s", p);
args = bprintf("locked = %d, owner = %d, sleeping = %d",
mutex.locked,
- mutex.owner != NULL ? (int) MC_smx_resolve_process(mutex.owner)->pid : -1,
+ mutex.owner != nullptr ? (int) MC_smx_resolve_process(mutex.owner)->pid : -1,
mutex_sleeping.count);
break;
}
case SIMCALL_MC_SNAPSHOT:
type = "MC_SNAPSHOT";
- args = NULL;
+ args = nullptr;
break;
case SIMCALL_MC_COMPARE_SNAPSHOTS:
type = "MC_COMPARE_SNAPSHOTS";
- args = NULL;
+ args = nullptr;
break;
case SIMCALL_MC_RANDOM:
}
char* str;
- if (args != NULL) {
+ if (args != nullptr) {
str =
bprintf("[(%lu)%s (%s)] %s(%s)", issuer->pid,
MC_smx_process_get_host_name(issuer),
for (cursor=0; cursor != comms.used; ++cursor) {
// Get the element:
- smx_synchro_t remote_action = NULL;
+ smx_synchro_t remote_action = nullptr;
memcpy(&remote_action, buffer + comms.elmsize * cursor, sizeof(remote_action));
// Dereference the pointer:
int MC_request_is_enabled_by_idx(smx_simcall_t req, unsigned int idx)
{
- smx_synchro_t remote_act = NULL;
+ smx_synchro_t remote_act = nullptr;
switch (req->call) {
case SIMCALL_COMM_WAIT:
char *MC_request_get_dot_output(smx_simcall_t req, int value)
{
- char *label = NULL;
+ char *label = nullptr;
const smx_process_t issuer = MC_smx_simcall_get_issuer(req);
s_smx_synchro_t synchro;
mc_model_checker->process().read_bytes(&synchro,
sizeof(synchro), remote(remote_act));
- if (synchro.comm.src_proc == NULL || synchro.comm.dst_proc == NULL) {
+ if (synchro.comm.src_proc == nullptr || synchro.comm.dst_proc == NULL) {
if (issuer->host)
label =
bprintf("[(%lu)%s] Test FALSE", issuer->pid,
xbt_fifo_item_t item;
mc_state_t stack_state;
- for(item = xbt_fifo_get_first_item(mc_stack); item != NULL; item = xbt_fifo_get_next_item(item)) {
+ for(item = xbt_fifo_get_first_item(mc_stack); item != nullptr; item = xbt_fifo_get_next_item(item)) {
stack_state = (mc_state_t) xbt_fifo_get_item_content(item);
if(snapshot_compare(stack_state, current_state) == 0){
XBT_INFO("Non-progressive cycle : state %d -> state %d", stack_state->num, current_state->num);
{
MC_modelcheck_safety_init();
- char *req_str = NULL;
+ char *req_str = nullptr;
int value;
- smx_simcall_t req = NULL;
- mc_state_t state = NULL, prev_state = NULL, next_state = NULL;
- xbt_fifo_item_t item = NULL;
- mc_visited_state_t visited_state = NULL;
+ smx_simcall_t req = nullptr;
+ mc_state_t state = nullptr, prev_state = NULL, next_state = NULL;
+ xbt_fifo_item_t item = nullptr;
+ mc_visited_state_t visited_state = nullptr;
while (xbt_fifo_size(mc_stack) > 0) {
/* If there are processes to interleave and the maximum depth has not been reached
then perform one step of the exploration algorithm */
if (xbt_fifo_size(mc_stack) <= _sg_mc_max_depth && !user_max_depth_reached
- && (req = MC_state_get_request(state, &value)) && visited_state == NULL) {
+ && (req = MC_state_get_request(state, &value)) && visited_state == nullptr) {
req_str = MC_request_to_string(req, value, MC_REQUEST_SIMIX);
XBT_DEBUG("Execute: %s", req_str);
xbt_free(req_str);
- if (dot_output != NULL) {
+ if (dot_output != nullptr) {
req_str = MC_request_get_dot_output(req, value);
}
return SIMGRID_MC_EXIT_NON_TERMINATION;
}
- if ((visited_state = is_visited_state(next_state)) == NULL) {
+ if ((visited_state = is_visited_state(next_state)) == nullptr) {
/* Get an enabled process and insert it in the interleave set of the next state */
- smx_process_t process = NULL;
+ smx_process_t process = nullptr;
MC_EACH_SIMIX_PROCESS(process,
if (MC_process_is_enabled(process)) {
MC_state_interleave_process(next_state, process);
}
);
- if (dot_output != NULL)
+ if (dot_output != nullptr)
std::fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", state->num, next_state->num, req_str);
} else {
- if (dot_output != NULL)
+ if (dot_output != nullptr)
std::fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", state->num, visited_state->other_num == -1 ? visited_state->num : visited_state->other_num, req_str);
}
xbt_fifo_unshift(mc_stack, next_state);
- if (dot_output != NULL)
+ if (dot_output != nullptr)
xbt_free(req_str);
/* Let's loop again */
/* The interleave set is empty or the maximum depth is reached, let's back-track */
} else {
- if ((xbt_fifo_size(mc_stack) > _sg_mc_max_depth) || user_max_depth_reached || visited_state != NULL) {
+ if ((xbt_fifo_size(mc_stack) > _sg_mc_max_depth) || user_max_depth_reached || visited_state != nullptr) {
- if (user_max_depth_reached && visited_state == NULL)
+ if (user_max_depth_reached && visited_state == nullptr)
XBT_DEBUG("User max depth reached !");
- else if (visited_state == NULL)
+ else if (visited_state == nullptr)
XBT_WARN("/!\\ Max depth reached ! /!\\ ");
else
XBT_DEBUG("State already visited (equal to state %d), exploration stopped on this path.", visited_state->other_num == -1 ? visited_state->num : visited_state->other_num);
XBT_DEBUG("Delete state %d at depth %d", state->num, xbt_fifo_size(mc_stack) + 1);
MC_state_delete(state, !state->in_visited_states ? 1 : 0);
- visited_state = NULL;
+ visited_state = nullptr;
/* Check for deadlocks */
if (MC_deadlock_check()) {
- MC_show_deadlock(NULL);
+ MC_show_deadlock(nullptr);
return SIMGRID_MC_EXIT_DEADLOCK;
}
static
void MC_smx_process_info_clear(mc_smx_process_info_t p)
{
- p->hostname = NULL;
+ p->hostname = nullptr;
free(p->name);
- p->name = NULL;
+ p->name = nullptr;
}
xbt_dynar_t MC_smx_process_info_list_new(void)
s_mc_smx_process_info_t info;
info.address = p;
- info.name = NULL;
- info.hostname = NULL;
+ info.name = nullptr;
+ info.hostname = nullptr;
process->read_bytes(&info.copy, sizeof(info.copy), remote(p));
xbt_dynar_push(target, &info);
smx_process_t MC_smx_resolve_process(smx_process_t process_remote_address)
{
if (!process_remote_address)
- return NULL;
+ return nullptr;
if (mc_mode == MC_MODE_CLIENT)
return process_remote_address;
if (process_info)
return &process_info->copy;
else
- return NULL;
+ return nullptr;
}
mc_smx_process_info_t MC_smx_resolve_process_info(smx_process_t process_remote_address)
if (mc_mode == MC_MODE_CLIENT)
return p->name;
if (!p->name)
- return NULL;
+ return nullptr;
mc_smx_process_info_t info = MC_smx_process_get_info(p);
if (!info->name) {
* @param addr Pointer
* @param snapshot Snapshot
* @param Snapshot region in the snapshot this pointer belongs to
- * (or NULL if it does not belong to any snapshot region)
+ * (or nullptr if it does not belong to any snapshot region)
* */
mc_mem_region_t mc_get_snapshot_region(
const void* addr, const simgrid::mc::Snapshot* snapshot, int process_index)
return region;
}
- return NULL;
+ return nullptr;
}
/** @brief Read memory from a snapshot region broken across fragmented pages
void* end = (char*) addr + size - 1;
// Page of the last byte of the memory area:
- size_t page_end = mc_page_number(NULL, end);
+ size_t page_end = mc_page_number(nullptr, end);
void* dest = target;
- if (dest==NULL) {
+ if (dest==nullptr) {
xbt_die("Missing destination buffer for fragmented memory access");
}
// Read each page:
- while (mc_page_number(NULL, addr) != page_end) {
+ while (mc_page_number(nullptr, addr) != page_end) {
void* snapshot_addr = mc_translate_address_region_chunked((uintptr_t) addr, region);
- void* next_page = mc_page_from_number(NULL, mc_page_number(NULL, addr) + 1);
+ void* next_page = mc_page_from_number(nullptr, mc_page_number(NULL, addr) + 1);
size_t readable = (char*) next_page - (char*) addr;
memcpy(dest, snapshot_addr, readable);
addr = (char*) addr + readable;
// Using alloca() for large allocations may trigger stack overflow:
// use malloc if the buffer is too big.
bool stack_alloc = size < 64;
- const bool region1_need_buffer = region1==NULL || region1->storage_type()==simgrid::mc::StorageType::Flat;
- const bool region2_need_buffer = region2==NULL || region2->storage_type()==simgrid::mc::StorageType::Flat;
- void* buffer1a = region1_need_buffer ? NULL : stack_alloc ? alloca(size) : malloc(size);
- void* buffer2a = region2_need_buffer ? NULL : stack_alloc ? alloca(size) : malloc(size);
+ const bool region1_need_buffer = region1==nullptr || region1->storage_type()==simgrid::mc::StorageType::Flat;
+ const bool region2_need_buffer = region2==nullptr || region2->storage_type()==simgrid::mc::StorageType::Flat;
+ void* buffer1a = region1_need_buffer ? nullptr : stack_alloc ? alloca(size) : malloc(size);
+ void* buffer2a = region2_need_buffer ? nullptr : stack_alloc ? alloca(size) : malloc(size);
const void* buffer1 = MC_region_read(region1, buffer1a, addr1, size);
const void* buffer2 = MC_region_read(region2, buffer2a, addr2, size);
int res;
// Store region page(s):
size_t byte_size = n * xbt_pagesize;
- void* source = mmap(NULL, byte_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ void* source = mmap(nullptr, byte_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
xbt_assert(source!=MAP_FAILED, "Could not allocate source memory");
// Init memory and take snapshots:
simgrid::mc::RegionSnapshot region = simgrid::mc::sparse_region(
simgrid::mc::RegionType::Unknown, source, source, byte_size, nullptr);
- void* destination = mmap(NULL, byte_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ void* destination = mmap(nullptr, byte_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
xbt_assert(source!=MAP_FAILED, "Could not allocate destination memory");
xbt_test_add("Reading whole region data for %i page(s)", n);
}
delete mc_model_checker;
- mc_model_checker = NULL;
+ mc_model_checker = nullptr;
}
#endif /* SIMGRID_TEST */
state->max_pid = MC_smx_get_maxpid();
state->proc_status = xbt_new0(s_mc_procstate_t, state->max_pid);
- state->system_state = NULL;
+ state->system_state = nullptr;
state->num = ++mc_stats->expanded_states;
state->in_visited_states = 0;
- state->incomplete_comm_pattern = NULL;
+ state->incomplete_comm_pattern = nullptr;
/* Stateful model checking */
if((_sg_mc_checkpoint > 0 && (mc_stats->expanded_states % _sg_mc_checkpoint == 0)) || _sg_mc_termination){
state->system_state = simgrid::mc::take_snapshot(state->num);
state->executed_req = *req;
state->req_num = value;
- smx_process_t process = NULL;
+ smx_process_t process = nullptr;
/* The waitany and testany request are transformed into a wait or test request over the
* corresponding communication action so it can be treated later by the dependence
if (procstate->state != MC_INTERLEAVE
&& procstate->state != MC_MORE_INTERLEAVE)
- return NULL;
+ return nullptr;
if (!MC_process_is_enabled(process))
- return NULL;
+ return nullptr;
switch (process->simcall.call) {
if (act.comm.src_proc && act.comm.dst_proc) {
*value = 0;
} else {
- if (act.comm.src_proc == NULL && act.comm.type == SIMIX_COMM_READY
+ if (act.comm.src_proc == nullptr && act.comm.type == SIMIX_COMM_READY
&& act.comm.detached == 1)
*value = 0;
else
*value = 0;
return &process->simcall;
}
- return NULL;
+ return nullptr;
}
smx_simcall_t MC_state_get_request(mc_state_t state, int *value)
{
- smx_process_t process = NULL;
+ smx_process_t process = nullptr;
MC_EACH_SIMIX_PROCESS(process,
smx_simcall_t res = MC_state_get_request_for_process(state, value, process);
if (res)
return res;
);
- return NULL;
+ return nullptr;
}
}
case UNW_X86_64_R14: return &mcontext->gregs[REG_R14];
case UNW_X86_64_R15: return &mcontext->gregs[REG_R15];
case UNW_X86_64_RIP: return &mcontext->gregs[REG_RIP];
- default: return NULL;
+ default: return nullptr;
}
#else
- return NULL;
+ return nullptr;
#endif
}
mc_visited_pair_t MC_visited_pair_new(int pair_num, xbt_automaton_state_t automaton_state, xbt_dynar_t atomic_propositions, mc_state_t graph_state)
{
simgrid::mc::Process* process = &(mc_model_checker->process());
- mc_visited_pair_t pair = NULL;
+ mc_visited_pair_t pair = nullptr;
pair = xbt_new0(s_mc_visited_pair_t, 1);
pair->graph_state = graph_state;
- if(pair->graph_state->system_state == NULL)
+ if(pair->graph_state->system_state == nullptr)
pair->graph_state->system_state = simgrid::mc::take_snapshot(pair_num);
pair->heap_bytes_used = mmalloc_get_bytes_used_remote(
process->get_heap()->heaplimit,
pair->acceptance_removed = 0;
pair->visited_removed = 0;
pair->acceptance_pair = 0;
- pair->atomic_propositions = xbt_dynar_new(sizeof(int), NULL);
+ pair->atomic_propositions = xbt_dynar_new(sizeof(int), nullptr);
unsigned int cursor = 0;
int value;
xbt_dynar_foreach(atomic_propositions, cursor, value)
void MC_visited_pair_delete(mc_visited_pair_t p)
{
- p->automaton_state = NULL;
+ p->automaton_state = nullptr;
if( !is_exploration_stack_pair(p))
MC_state_delete(p->graph_state, 1);
xbt_dynar_free(&(p->atomic_propositions));
xbt_free(p);
- p = NULL;
+ p = nullptr;
}
/**
else
new_state->other_num = state_test->other_num;
- if (dot_output == NULL)
+ if (dot_output == nullptr)
XBT_DEBUG("State %d already visited ! (equal to state %d)",
new_state->num, state_test->num);
else
/* Replace the old state with the new one (with a bigger num)
(when the max number of visited states is reached, the oldest
one is removed according to its number (= with the min number) */
- xbt_dynar_remove_at(visited_states, cursor, NULL);
+ xbt_dynar_remove_at(visited_states, cursor, nullptr);
xbt_dynar_insert_at(visited_states, cursor, &new_state);
XBT_DEBUG("Replace visited state %d with the new visited state %d",
state_test->num, new_state->num);
{
if (_sg_mc_visited == 0)
- return NULL;
+ return nullptr;
/* If comm determinism verification, we cannot stop the exploration if some
communications are not finished (at least, data are transfered). These communications
if (xbt_dynar_is_empty(visited_states)) {
xbt_dynar_push(visited_states, &new_state);
- return NULL;
+ return nullptr;
} else {
new_state->other_num = state_test->num;
else
new_state->other_num = state_test->other_num;
- if(dot_output == NULL)
+ if(dot_output == nullptr)
XBT_DEBUG("State %d already visited ! (equal to state %d)", new_state->num, state_test->num);
else
XBT_DEBUG("State %d already visited ! (equal to state %d (state %d in dot_output))", new_state->num, state_test->num, new_state->other_num);
- xbt_dynar_remove_at(visited_states, (min + res) - 1, NULL);
+ xbt_dynar_remove_at(visited_states, (min + res) - 1, nullptr);
xbt_dynar_insert_at(visited_states, (min+res) - 1, &new_state);
return new_state->other_num;
} */
}
// and drop it:
- xbt_dynar_remove_at(visited_states, index2, NULL);
+ xbt_dynar_remove_at(visited_states, index2, nullptr);
XBT_DEBUG("Remove visited state (maximum number of stored states reached)");
}
- return NULL;
+ return nullptr;
}
}
if (_sg_mc_visited == 0)
return -1;
- mc_visited_pair_t new_visited_pair = NULL;
+ mc_visited_pair_t new_visited_pair = nullptr;
- if (visited_pair == NULL) {
+ if (visited_pair == nullptr) {
new_visited_pair = MC_visited_pair_new(pair->num, pair->automaton_state, pair->atomic_propositions, pair->graph_state);
} else {
new_visited_pair = visited_pair;
pair->other_num = pair_test->num;
else
pair->other_num = pair_test->other_num;
- if(dot_output == NULL)
+ if(dot_output == nullptr)
XBT_DEBUG("Pair %d already visited ! (equal to pair %d)", pair->num, pair_test->num);
else
XBT_DEBUG("Pair %d already visited ! (equal to pair %d (pair %d in dot_output))", pair->num, pair_test->num, pair->other_num);
- xbt_dynar_remove_at(visited_pairs, (min + res) - 1, NULL);
+ xbt_dynar_remove_at(visited_pairs, (min + res) - 1, nullptr);
xbt_dynar_insert_at(visited_pairs, (min+res) - 1, &pair);
pair_test->visited_removed = 1;
if(pair_test->stack_removed && pair_test->visited_removed){
new_visited_pair->other_num = pair_test->num;
else
new_visited_pair->other_num = pair_test->other_num;
- if (dot_output == NULL)
+ if (dot_output == nullptr)
XBT_DEBUG("Pair %d already visited ! (equal to pair %d)", new_visited_pair->num, pair_test->num);
else
XBT_DEBUG("Pair %d already visited ! (equal to pair %d (pair %d in dot_output))", new_visited_pair->num, pair_test->num, new_visited_pair->other_num);
{
char** argv_copy = xbt_new(char*, argc+1);
std::memcpy(argv_copy, argv, sizeof(char*) * argc);
- argv_copy[argc] = NULL;
+ argv_copy[argc] = nullptr;
return argv_copy;
}