From: Gabriel Corona Date: Mon, 7 Mar 2016 08:48:04 +0000 (+0100) Subject: [mc] Remove more useless braces X-Git-Tag: v3_13~500^2~4^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6bc71102f9c6ad0e9bb98c6a8c08f3556b636d3d [mc] Remove more useless braces --- diff --git a/src/mc/mc_checkpoint.cpp b/src/mc/mc_checkpoint.cpp index 38b4e444ba..c8311007f4 100644 --- a/src/mc/mc_checkpoint.cpp +++ b/src/mc/mc_checkpoint.cpp @@ -155,13 +155,11 @@ static void get_memory_regions(simgrid::mc::Process* process, mc_snapshot_t snap const size_t n = process->object_infos.size(); snapshot->snapshot_regions.resize(n + 1); int i = 0; - for (auto const& object_info : process->object_infos) { - add_region(i, snapshot, simgrid::mc::RegionType::Data, + for (auto const& object_info : process->object_infos) + add_region(i++, snapshot, simgrid::mc::RegionType::Data, object_info.get(), object_info->start_rw, object_info->start_rw, object_info->end_rw - object_info->start_rw); - ++i; - } xbt_mheap_t heap = process->get_heap(); void *start_heap = heap->base; @@ -175,16 +173,14 @@ static void get_memory_regions(simgrid::mc::Process* process, mc_snapshot_t snap process->get_malloc_info()); #ifdef HAVE_SMPI - if (mc_model_checker->process().privatized() && MC_smpi_process_count()) { + if (mc_model_checker->process().privatized() && MC_smpi_process_count()) // snapshot->privatization_index = smpi_loaded_page mc_model_checker->process().read_variable( "smpi_loaded_page", &snapshot->privatization_index, sizeof(snapshot->privatization_index)); - } else + else #endif - { snapshot->privatization_index = simgrid::mc::ProcessIndexMissing; - } } /** \brief Fills the position of the segments (executable, read-only, read/write). @@ -211,9 +207,8 @@ void find_object_address( // .bss is usually after the .data: simgrid::xbt::VmMap const& next = maps[i + 1]; if (next.pathname.empty() && (next.prot & PROT_WRITE) - && next.start_addr == reg.end_addr) { + && next.start_addr == reg.end_addr) result->end_rw = (char*) maps[i + 1].end_addr; - } } else if ((reg.prot & PROT_READ) && (reg.prot & PROT_EXEC)) { xbt_assert(!result->start_exec, "Multiple executable segments for %s, not supported", @@ -300,9 +295,9 @@ static void fill_local_variables_values(mc_stack_frame_t stack_frame, new_var.region = region_type; new_var.address = nullptr; - if (current_variable.address != nullptr) { + if (current_variable.address != nullptr) new_var.address = current_variable.address; - } else if (!current_variable.location_list.empty()) { + else if (!current_variable.location_list.empty()) { simgrid::dwarf::Location location = simgrid::dwarf::resolve( current_variable.location_list, @@ -315,9 +310,8 @@ static void fill_local_variables_values(mc_stack_frame_t stack_frame, xbt_die("Cannot handle non-address variable"); new_var.address = location.address(); - } else { + } else xbt_die("No address"); - } result.push_back(std::move(new_var)); } @@ -345,11 +339,9 @@ static std::vector unwind_stack_frames(mc_unw_context_t stac unw_cursor_t c; // TODO, check condition check (unw_init_local==0 means end of frame) - if (mc_unw_init_cursor(&c, stack_context) != 0) { - + if (mc_unw_init_cursor(&c, stack_context) != 0) xbt_die("Could not initialize stack unwinding"); - } else while (1) { s_mc_stack_frame_t stack_frame; @@ -386,11 +378,10 @@ static std::vector unwind_stack_frames(mc_unw_context_t stac break; int ret = unw_step(&c); - if (ret == 0) { + if (ret == 0) xbt_die("Unexpected end of stack."); - } else if (ret < 0) { + else if (ret < 0) xbt_die("Error while unwinding stack"); - } } if (result.empty()) { @@ -414,9 +405,9 @@ static std::vector take_snapshot_stacks(mc_snapshot_t * s &context, sizeof(context), remote(stack.context)); if (mc_unw_init_context(&st.context, &mc_model_checker->process(), - &context) < 0) { + &context) < 0) xbt_die("Could not initialise the libunwind context."); - } + st.stack_frames = unwind_stack_frames(&st.context); st.local_variables = get_local_variables_values(st.stack_frames, stack.process_index); st.process_index = stack.process_index; @@ -451,9 +442,8 @@ static void snapshot_handle_ignore(mc_snapshot_t snapshot) } // Zero the memory: - for(auto const& region : mc_model_checker->process().ignored_regions()) { + for(auto const& region : mc_model_checker->process().ignored_regions()) snapshot->process()->clear_bytes(remote(region.addr), region.size); - } } @@ -500,12 +490,12 @@ static std::vector get_current_fds(pid_t pid) const size_t link_size = 200; char link[200]; res = readlink(source, link, link_size); - if (res<0) { + + if (res<0) xbt_die("Could not read link for %s", source); - } - if (res==200) { + if (res==200) xbt_die("Buffer to small for link of %s", source); - } + link[res] = '\0'; #ifdef HAVE_SMPI @@ -574,14 +564,12 @@ mc_snapshot_t take_snapshot(int num_state) if (_sg_mc_visited > 0 || strcmp(_sg_mc_property_file, "")) { snapshot->stacks = take_snapshot_stacks(&snapshot); - if (_sg_mc_hash) { + if (_sg_mc_hash) snapshot->hash = simgrid::mc::hash(*snapshot); - } else { + else snapshot->hash = 0; - } - } else { + } else snapshot->hash = 0; - } snapshot_ignore_restore(snapshot); if (use_soft_dirty) @@ -619,10 +607,9 @@ void restore_snapshot_fds(mc_snapshot_t snapshot) for (auto const& fd : snapshot->current_fds) { int new_fd = open(fd.filename.c_str(), fd.flags); - if (new_fd < 0) { + if (new_fd < 0) xbt_die("Could not reopen the file %s fo restoring the file descriptor", fd.filename.c_str()); - } if (new_fd != fd.number) { dup2(new_fd, fd.number); close(new_fd); diff --git a/src/mc/mc_comm_determinism.cpp b/src/mc/mc_comm_determinism.cpp index d499d1b8b6..623365919e 100644 --- a/src/mc/mc_comm_determinism.cpp +++ b/src/mc/mc_comm_determinism.cpp @@ -54,9 +54,8 @@ static e_mc_comm_pattern_difference_t compare_comm_pattern(mc_comm_pattern_t com if (!memcmp(comm1->data, comm2->data, comm1->data_size)) return NONE_DIFF; return DATA_DIFF; - }else{ + } else return DATA_DIFF; - } return NONE_DIFF; } @@ -249,9 +248,8 @@ void MC_get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, e_mc_call_type pattern->rdv = mc_model_checker->process().read_string(remote_name); pattern->dst_proc = MC_smx_resolve_process(synchro.comm.dst_proc)->pid; pattern->dst_host = MC_smx_process_get_host_name(issuer); - } else { + } else xbt_die("Unexpected call_type %i", (int) call_type); - } xbt_dynar_push( xbt_dynar_get_as(incomplete_communications_pattern, issuer->pid, xbt_dynar_t), @@ -267,7 +265,7 @@ void MC_complete_comm_pattern(xbt_dynar_t list, smx_synchro_t comm_addr, unsigne int completed = 0; /* Complete comm pattern */ - xbt_dynar_foreach(xbt_dynar_get_as(incomplete_communications_pattern, issuer, xbt_dynar_t), cursor, current_comm_pattern) { + xbt_dynar_foreach(xbt_dynar_get_as(incomplete_communications_pattern, issuer, xbt_dynar_t), cursor, current_comm_pattern) if (current_comm_pattern->comm_addr == comm_addr) { update_comm_pattern(current_comm_pattern, comm_addr); completed = 1; @@ -277,17 +275,17 @@ void MC_complete_comm_pattern(xbt_dynar_t list, smx_synchro_t comm_addr, unsigne XBT_DEBUG("Remove incomplete comm pattern for process %u at cursor %u", issuer, cursor); break; } - } + if(!completed) xbt_die("Corresponding communication not found!"); mc_list_comm_pattern_t pattern = xbt_dynar_get_as( initial_communications_pattern, issuer, mc_list_comm_pattern_t); - if (!initial_global_state->initial_communications_pattern_done) { + if (!initial_global_state->initial_communications_pattern_done) /* Store comm pattern */ xbt_dynar_push(pattern->list, &comm_pattern); - } else { + else { /* Evaluate comm determinism */ deterministic_comm_pattern(issuer, comm_pattern, backtracking); pattern->index_comm++; @@ -369,18 +367,16 @@ static int MC_modelcheck_comm_determinism_main(void) XBT_DEBUG("Execute: %s", req_str); xbt_free(req_str); - if (dot_output != nullptr) { + if (dot_output != nullptr) req_str = MC_request_get_dot_output(req, value); - } MC_state_set_executed_request(state, req, value); mc_stats->executed_transitions++; /* TODO : handle test and testany simcalls */ e_mc_call_type_t call = MC_CALL_TYPE_NONE; - if (_sg_mc_comms_determinism || _sg_mc_send_determinism) { + if (_sg_mc_comms_determinism || _sg_mc_send_determinism) call = MC_get_call_type(req); - } /* Answer the request */ MC_simcall_handle(req, value); /* After this call req is no longer useful */ @@ -406,12 +402,9 @@ static int MC_modelcheck_comm_determinism_main(void) if (dot_output != nullptr) fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", state->num, next_state->num, req_str); - } else { - - 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); - - } + } else 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); @@ -420,13 +413,12 @@ static int MC_modelcheck_comm_determinism_main(void) } else { - if (xbt_fifo_size(mc_stack) > _sg_mc_max_depth) { + if (xbt_fifo_size(mc_stack) > _sg_mc_max_depth) XBT_WARN("/!\\ Max depth reached ! /!\\ "); - } else if (visited_state != nullptr) { + 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 { + else XBT_DEBUG("There are no more processes to interleave. (depth %d)", xbt_fifo_size(mc_stack)); - } if (!initial_global_state->initial_communications_pattern_done) initial_global_state->initial_communications_pattern_done = 1; @@ -444,7 +436,7 @@ static int MC_modelcheck_comm_determinism_main(void) return SIMGRID_MC_EXIT_DEADLOCK; } - while ((state = (mc_state_t) xbt_fifo_shift(mc_stack)) != nullptr) { + 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); @@ -459,7 +451,7 @@ static int MC_modelcheck_comm_determinism_main(void) 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); } - } + } } @@ -473,10 +465,9 @@ int MC_modelcheck_comm_determinism(void) mc_reduce_kind = e_mc_reduce_none; mc_model_checker->wait_for_requests(); - if (mc_mode == MC_MODE_CLIENT) { + if (mc_mode == MC_MODE_CLIENT) // This will move somehwere else: MC_client_handle_messages(); - } /* Create exploration stack */ mc_stack = xbt_fifo_new(); diff --git a/src/mc/mc_comm_pattern.cpp b/src/mc/mc_comm_pattern.cpp index 857bee8d10..0a5ff5eda9 100644 --- a/src/mc/mc_comm_pattern.cpp +++ b/src/mc/mc_comm_pattern.cpp @@ -75,16 +75,14 @@ void MC_restore_communications_pattern(mc_state_t state) mc_list_comm_pattern_t list_process_comm; unsigned int cursor; - xbt_dynar_foreach(initial_communications_pattern, cursor, list_process_comm){ + xbt_dynar_foreach(initial_communications_pattern, cursor, list_process_comm) list_process_comm->index_comm = (int)xbt_dynar_get_as(state->index_comm, cursor, int); - } - for (unsigned i = 0; i < MC_smx_get_maxpid(); i++) { + for (unsigned i = 0; i < MC_smx_get_maxpid(); i++) MC_patterns_copy( xbt_dynar_get_as(incomplete_communications_pattern, i, xbt_dynar_t), xbt_dynar_get_as(state->incomplete_comm_pattern, i, xbt_dynar_t) ); - } } void MC_state_copy_incomplete_communications_pattern(mc_state_t state) @@ -103,9 +101,8 @@ void MC_state_copy_index_communications_pattern(mc_state_t state) 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){ + xbt_dynar_foreach(initial_communications_pattern, cursor, list_process_comm) xbt_dynar_push_as(state->index_comm, unsigned int, list_process_comm->index_comm); - } } void MC_handle_comm_pattern( diff --git a/src/mc/mc_compare.cpp b/src/mc/mc_compare.cpp index 00ead0e05b..634402e219 100644 --- a/src/mc/mc_compare.cpp +++ b/src/mc/mc_compare.cpp @@ -150,19 +150,17 @@ static int compare_areas_with_type(ComparisonState& state, void* addr_pointed1 = MC_region_read_pointer(region1, real_area1); void* addr_pointed2 = MC_region_read_pointer(region2, real_area2); - if (type->subtype && type->subtype->type == DW_TAG_subroutine_type) { + if (type->subtype && type->subtype->type == DW_TAG_subroutine_type) return (addr_pointed1 != addr_pointed2); - } else { - - if (addr_pointed1 == nullptr && addr_pointed2 == NULL) - return 0; - if (addr_pointed1 == nullptr || addr_pointed2 == NULL) - return 1; - if (!state.compared_pointers.insert( - std::make_pair(addr_pointed1, addr_pointed2)).second) - return 0; + if (addr_pointed1 == nullptr && addr_pointed2 == NULL) + return 0; + if (addr_pointed1 == nullptr || addr_pointed2 == NULL) + return 1; + if (!state.compared_pointers.insert( + std::make_pair(addr_pointed1, addr_pointed2)).second) + return 0; - pointer_level++; + pointer_level++; // Some cases are not handled here: // * the pointers lead to different areas (one to the heap, the other to the RW segment ...); @@ -186,21 +184,19 @@ static int compare_areas_with_type(ComparisonState& state, return 1; if (!type->type_id) return (addr_pointed1 != addr_pointed2); - else { + else return compare_areas_with_type(state, process_index, addr_pointed1, snapshot1, region1, addr_pointed2, snapshot2, region2, type->subtype, pointer_level); - } } // TODO, We do not handle very well the case where // it belongs to a different (non-heap) region from the current one. - else { + else return (addr_pointed1 != addr_pointed2); - } - } + break; } case DW_TAG_structure_type: @@ -243,9 +239,8 @@ static int compare_global_variables(simgrid::mc::ObjectInformation* object_info, #ifdef HAVE_SMPI if (r1->storage_type() == simgrid::mc::StorageType::Privatized) { xbt_assert(process_index >= 0); - if (r2->storage_type() != simgrid::mc::StorageType::Privatized) { + if (r2->storage_type() != simgrid::mc::StorageType::Privatized) return 1; - } size_t process_count = MC_smpi_process_count(); xbt_assert(process_count == r1->privatized_data().size() @@ -309,7 +304,8 @@ static int compare_local_variables(int process_index, if (stack1->local_variables.size() != stack2->local_variables.size()) { XBT_VERB("Different number of local variables"); return 1; - } else { + } + unsigned int cursor = 0; local_variable_t current_var1, current_var2; int res; @@ -353,7 +349,6 @@ static int compare_local_variables(int process_index, cursor++; } return 0; - } } int snapshot_compare(void *state1, void *state2) @@ -392,9 +387,8 @@ int snapshot_compare(void *state1, void *state2) #ifndef MC_DEBUG return 1; #endif - } else { + } else XBT_VERB("(%d - %d) Same hash : 0x%" PRIx64, num1, num2, s1->hash); - } } /* Compare enabled processes */ diff --git a/src/mc/mc_config.cpp b/src/mc/mc_config.cpp index cae53203e5..244b4a0046 100644 --- a/src/mc/mc_config.cpp +++ b/src/mc/mc_config.cpp @@ -38,10 +38,10 @@ int _sg_mc_timeout = 0; void _mc_cfg_cb_timeout(const char *name, int pos) { - if (_sg_cfg_init_status && !(_sg_do_model_check || MC_record_path)) { + if (_sg_cfg_init_status && !(_sg_do_model_check || MC_record_path)) xbt_die ("You are specifying a value to enable/disable timeout for wait requests after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_timeout = xbt_cfg_get_boolean(_sg_cfg_set, name); } @@ -66,34 +66,33 @@ int _sg_mc_termination = 0; void _mc_cfg_cb_reduce(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die ("You are specifying a reduction strategy after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + char *val = xbt_cfg_get_string(_sg_cfg_set, name); - if (!strcasecmp(val, "none")) { + if (!strcasecmp(val, "none")) mc_reduce_kind = e_mc_reduce_none; - } else if (!strcasecmp(val, "dpor")) { + else if (!strcasecmp(val, "dpor")) mc_reduce_kind = e_mc_reduce_dpor; - } else { + else xbt_die("configuration option %s can only take 'none' or 'dpor' as a value", name); - } } void _mc_cfg_cb_checkpoint(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die ("You are specifying a checkpointing value after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_checkpoint = xbt_cfg_get_int(_sg_cfg_set, name); } void _mc_cfg_cb_sparse_checkpoint(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die("You are specifying a checkpointing value after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_sparse_checkpoint = xbt_cfg_get_boolean(_sg_cfg_set, name); } @@ -103,6 +102,7 @@ void _mc_cfg_cb_soft_dirty(const char *name, int pos) { "(through MSG_config?), but model-checking was not activated " "at config time (through --cfg=model-check:1). " "This won't work, sorry."); + _sg_mc_soft_dirty = xbt_cfg_get_boolean(_sg_cfg_set, name); } @@ -110,87 +110,88 @@ void _mc_cfg_cb_ksm(const char *name, int pos) { if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die("You are specifying a KSM value after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry."); + _sg_mc_ksm = xbt_cfg_get_boolean(_sg_cfg_set, name); } void _mc_cfg_cb_property(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die ("You are specifying a property after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_property_file = xbt_cfg_get_string(_sg_cfg_set, name); } void _mc_cfg_cb_hash(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die ("You are specifying a value to enable/disable the use of global hash to speedup state comparaison, but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_hash = xbt_cfg_get_boolean(_sg_cfg_set, name); } void _mc_cfg_cb_snapshot_fds(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die ("You are specifying a value to enable/disable the use of FD snapshoting, but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_snapshot_fds = xbt_cfg_get_boolean(_sg_cfg_set, name); } void _mc_cfg_cb_max_depth(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die ("You are specifying a max depth value after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_max_depth = xbt_cfg_get_int(_sg_cfg_set, name); } void _mc_cfg_cb_visited(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die ("You are specifying a number of stored visited states after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_visited = xbt_cfg_get_int(_sg_cfg_set, name); } void _mc_cfg_cb_dot_output(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die ("You are specifying a file name for a dot output of graph state after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_dot_output_file = xbt_cfg_get_string(_sg_cfg_set, name); } void _mc_cfg_cb_comms_determinism(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die ("You are specifying a value to enable/disable the detection of determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_comms_determinism = xbt_cfg_get_boolean(_sg_cfg_set, name); } void _mc_cfg_cb_send_determinism(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die ("You are specifying a value to enable/disable the detection of send-determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_send_determinism = xbt_cfg_get_boolean(_sg_cfg_set, name); } void _mc_cfg_cb_termination(const char *name, int pos) { - if (_sg_cfg_init_status && !_sg_do_model_check) { + if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die ("You are specifying a value to enable/disable the detection of non progressive cycles after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - } + _sg_mc_termination = xbt_cfg_get_boolean(_sg_cfg_set, name); } diff --git a/src/mc/mc_diff.cpp b/src/mc/mc_diff.cpp index 1490675bac..f7e1e8eb1a 100644 --- a/src/mc/mc_diff.cpp +++ b/src/mc/mc_diff.cpp @@ -86,12 +86,11 @@ static int is_new_heap_area_pair(xbt_dynar_t list, int block1, int fragment1, unsigned int cursor = 0; heap_area_pair_t current_pair; - xbt_dynar_foreach(list, cursor, current_pair) { + xbt_dynar_foreach(list, cursor, current_pair) if (current_pair->block1 == block1 && current_pair->block2 == block2 && current_pair->fragment1 == fragment1 && current_pair->fragment2 == fragment2) return 0; - } return 1; } @@ -160,7 +159,7 @@ static void match_equals(struct s_mc_diff *state, xbt_dynar_t list) unsigned int cursor = 0; heap_area_pair_t current_pair; - xbt_dynar_foreach(list, cursor, current_pair) { + xbt_dynar_foreach(list, cursor, current_pair) if (current_pair->fragment1 != -1) { @@ -178,7 +177,6 @@ static void match_equals(struct s_mc_diff *state, xbt_dynar_t list) } - } } /** Check whether two blocks are known to be matching @@ -715,14 +713,12 @@ static int compare_heap_area_without_type(struct s_mc_diff *state, int process_i res_compare = compare_heap_area(process_index, addr_pointed1, addr_pointed2, snapshot1, snapshot2, previous, nullptr, 0); - if (res_compare == 1) { + if (res_compare == 1) return res_compare; - } i = pointer_align + sizeof(void *); continue; - } else { + } else return 1; - } } @@ -770,9 +766,8 @@ top: && ((ignore1 = heap_comparison_ignore_size(state->to_ignore1, real_area1)) > 0) && ((ignore2 = heap_comparison_ignore_size(state->to_ignore2, real_area2)) - == ignore1)) { + == ignore1)) return 0; - } simgrid::mc::Type *subtype, *subsubtype; int res, elm_size; @@ -794,9 +789,8 @@ top: } else { if (area_size != -1 && type->byte_size != area_size) return -1; - else { + else return (MC_snapshot_region_memcmp(real_area1, heap_region1, real_area2, heap_region2, type->byte_size) != 0); - } } break; case DW_TAG_enumeration_type: @@ -917,9 +911,8 @@ top: if (res == 1) return res; } - } else { + } else return -1; - } } else { for(simgrid::mc::Member& member : type->members) { // TODO, optimize this? (for the offset case) @@ -932,9 +925,8 @@ top: snapshot1, snapshot2, previous, member.type, -1, check_ignore, 0); - if (res == 1) { + if (res == 1) return res; - } } } break; @@ -1075,9 +1067,8 @@ int compare_heap_area(int process_index, const void *area1, const void *area2, m || (block1 > (ssize_t) state->heapsize1) || (block1 < 1) || ((char *) area2 < (char *) state->std_heap_copy.heapbase) || (block2 > (ssize_t) state->heapsize2) || (block2 < 1)) { - if (match_pairs) { + if (match_pairs) xbt_dynar_free(&previous); - } return 1; } @@ -1158,17 +1149,15 @@ int compare_heap_area(int process_index, const void *area1, const void *area2, m if (heapinfo1->busy_block.size != heapinfo2->busy_block.size) { - if (match_pairs) { + if (match_pairs) xbt_dynar_free(&previous); - } return 1; } if (heapinfo1->busy_block.busy_size != heapinfo2->busy_block.busy_size) { - if (match_pairs) { + if (match_pairs) xbt_dynar_free(&previous); - } return 1; } @@ -1184,12 +1173,10 @@ int compare_heap_area(int process_index, const void *area1, const void *area2, m // Remember (basic) type inference. // The current data structure only allows us to do this for the whole block. - if (type != nullptr && area1 == real_addr_block1) { + if (type != nullptr && area1 == real_addr_block1) state->types1_(block1, 0) = type; - } - if (type != nullptr && area2 == real_addr_block2) { + if (type != nullptr && area2 == real_addr_block2) state->types2_(block2, 0) = type; - } if (size <= 0) { if (match_pairs) { @@ -1265,9 +1252,8 @@ int compare_heap_area(int process_index, const void *area1, const void *area2, m } return -1; } else { - if (match_pairs) { + if (match_pairs) xbt_dynar_free(&previous); - } return 1; } } @@ -1277,12 +1263,11 @@ int compare_heap_area(int process_index, const void *area1, const void *area2, m // Remember (basic) type inference. // The current data structure only allows us to do this for the whole fragment. - if (type != nullptr && area1 == real_addr_frag1) { + if (type != nullptr && area1 == real_addr_frag1) state->types1_(block1, frag1) = type; - } - if (type != nullptr && area2 == real_addr_frag2) { + if (type != nullptr && area2 == real_addr_frag2) state->types2_(block2, frag2) = type; - } + // The type of the variable is already known: if (type) { new_type1 = type; @@ -1351,15 +1336,14 @@ int compare_heap_area(int process_index, const void *area1, const void *area2, m size = new_size1; } - if (offset1 == 0 && offset2 == 0) { - if (!add_heap_area_pair(previous, block1, frag1, block2, frag2)) { + if (offset1 == 0 && offset2 == 0 + && !add_heap_area_pair(previous, block1, frag1, block2, frag2)) { if (match_pairs) { match_equals(state, previous); xbt_dynar_free(&previous); } return 0; } - } if (size <= 0) { if (match_pairs) { @@ -1376,25 +1360,24 @@ int compare_heap_area(int process_index, const void *area1, const void *area2, m } else { - if (match_pairs) { + if (match_pairs) xbt_dynar_free(&previous); - } return 1; } /* Start comparison */ - if (type) { + if (type) res_compare = compare_heap_area_with_type(state, process_index, area1, area2, snapshot1, snapshot2, previous, type, size, check_ignore, pointer_level); - } else { + else res_compare = compare_heap_area_without_type(state, process_index, area1, area2, snapshot1, snapshot2, previous, size, check_ignore); - } + if (res_compare == 1) { if (match_pairs) xbt_dynar_free(&previous); @@ -1439,13 +1422,13 @@ static int get_pointed_area_size(void *area, int heap) if (heapinfo[block].type == MMALLOC_TYPE_FREE || heapinfo[block].type == MMALLOC_TYPE_HEAPINFO) { /* Free block */ return -1; - } else if (heapinfo[block].type == MMALLOC_TYPE_UNFRAGMENTED) { /* Complete block */ + else if (heapinfo[block].type == MMALLOC_TYPE_UNFRAGMENTED) /* Complete block */ return (int) heapinfo[block].busy_block.busy_size; - } else { + else frag = ((uintptr_t) (ADDR2UINT(area) % (BLOCKSIZE))) >> heapinfo[block].type; return (int) heapinfo[block].busy_frag.frag_size[frag]; - } + } #ifndef max diff --git a/src/mc/mc_dwarf.cpp b/src/mc/mc_dwarf.cpp index 38c7d3a0ca..5e1b5e5f7b 100644 --- a/src/mc/mc_dwarf.cpp +++ b/src/mc/mc_dwarf.cpp @@ -257,11 +257,10 @@ static const char *MC_dwarf_attr_integrate_string(Dwarf_Die * die, int attribute) { Dwarf_Attribute attr; - if (!dwarf_attr_integrate(die, attribute, &attr)) { + if (!dwarf_attr_integrate(die, attribute, &attr)) return nullptr; - } else { + else return dwarf_formstring(&attr); - } } /** \brief Get the linkage name of a DIE. @@ -867,9 +866,8 @@ static void MC_dwarf_handle_scope_die(simgrid::mc::ObjectInformation* info, Dwar if (low_pc) { // DW_AT_high_pc: Dwarf_Attribute attr; - if (!dwarf_attr_integrate(die, DW_AT_high_pc, &attr)) { + if (!dwarf_attr_integrate(die, DW_AT_high_pc, &attr)) xbt_die("Missing DW_AT_high_pc matching with DW_AT_low_pc"); - } Dwarf_Sword offset; Dwarf_Addr high_pc; @@ -941,9 +939,8 @@ static void MC_dwarf_handle_children(simgrid::mc::ObjectInformation* info, Dwarf Dwarf_Die child; int res; for (res = dwarf_child(die, &child); res == 0; - res = dwarf_siblingof(&child, &child)) { + res = dwarf_siblingof(&child, &child)) MC_dwarf_handle_die(info, &child, unit, frame, ns); - } } static void MC_dwarf_handle_die(simgrid::mc::ObjectInformation* info, Dwarf_Die * die, @@ -1176,7 +1173,7 @@ void MC_post_process_object_info(simgrid::mc::Process* process, simgrid::mc::Obj break; // Resolve full_type: - if (!subtype->name.empty() && subtype->byte_size == 0) { + if (!subtype->name.empty() && subtype->byte_size == 0) for (auto const& object_info : process->object_infos) { auto i = object_info->full_types_by_name.find(subtype->name); if (i != object_info->full_types_by_name.end() @@ -1185,7 +1182,7 @@ void MC_post_process_object_info(simgrid::mc::Process* process, simgrid::mc::Obj break; } } - } else type->full_type = subtype; + else type->full_type = subtype; } } diff --git a/src/mc/mc_global.cpp b/src/mc/mc_global.cpp index fa37b30ace..a77c61404c 100644 --- a/src/mc/mc_global.cpp +++ b/src/mc/mc_global.cpp @@ -148,16 +148,14 @@ int MC_deadlock_check() ssize_t s = mc_model_checker->process().receive_message(message); if (s == -1) xbt_die("Could not receive message"); - else if (s != sizeof(message) || message.type != MC_MESSAGE_DEADLOCK_CHECK_REPLY) { + if (s != sizeof(message) || message.type != MC_MESSAGE_DEADLOCK_CHECK_REPLY) xbt_die("%s received unexpected message %s (%i, size=%i) " "expected MC_MESSAGE_DEADLOCK_CHECK_REPLY (%i, size=%i)", MC_mode_name(mc_mode), MC_message_type_name(message.type), (int) message.type, (int) s, (int) MC_MESSAGE_DEADLOCK_CHECK_REPLY, (int) sizeof(message) ); - } - else - return message.value; + return message.value; } int deadlock = FALSE; @@ -507,13 +505,11 @@ static void MC_dump_stacks(FILE* file) double MC_process_clock_get(smx_process_t process) { - if (mc_time) { - if (process != nullptr) - return mc_time[process->pid]; - else - return -1; - } else + if (!mc_time) return 0; + if (process != nullptr) + return mc_time[process->pid]; + return -1; } void MC_process_clock_add(smx_process_t process, double amount)