X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b8ba0bc2f48c6b9b96dfedd8fd383b941d5fdd0b..dda93e7e3c8844b68b25ce1172d9fe1b6fcb8d37:/src/mc/mc_liveness.c diff --git a/src/mc/mc_liveness.c b/src/mc/mc_liveness.c index 4b4a00c7d2..ae15bbfcef 100644 --- a/src/mc/mc_liveness.c +++ b/src/mc/mc_liveness.c @@ -33,11 +33,105 @@ unsigned int hash_region(char *str, int str_len){ } -int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){ +const char* get_memory_map_addr(void *addr){ + + FILE *fp; /* File pointer to process's proc maps file */ + char *line = NULL; /* Temporal storage for each line that is readed */ + ssize_t read; /* Number of bytes readed */ + size_t n = 0; /* Amount of bytes to read by getline */ + + fp = fopen("/proc/self/maps", "r"); + + if(fp == NULL) + perror("fopen failed"); + + if(addr == NULL) + return "nil"; + + char *lfields[6], *start, *end, *endptr; + int i; + void *start_addr; + void *end_addr; + + while ((read = getline(&line, &n, fp)) != -1) { + + line[read - 1] = '\0'; + + lfields[0] = strtok(line, " "); + + for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) { + lfields[i] = strtok(NULL, " "); + } + + start = strtok(lfields[0], "-"); + start_addr = (void *) strtoul(start, &endptr, 16); + + if(start_addr == std_heap) + lfields[5] = strdup("std_heap"); + if(start_addr == raw_heap) + lfields[5] = strdup("raw_heap"); + end = strtok(NULL, "-"); + end_addr = (void *) strtoul(end, &endptr, 16); + + if((addr > start_addr) && ( addr < end_addr)){ + free(line); + fclose(fp); + if(lfields[5] != NULL){ + return lfields[5]; + }else{ + return "Anonymous"; + } + } + + } + + return "Unknown area"; + +} + +int data_program_region_compare(void *d1, void *d2, size_t size){ + int distance = 0; + int pointer_align; + int i; + + for(i=0; inum_reg != s2->num_reg){ - XBT_DEBUG("Different num_reg (s1 = %d, s2 = %d)", s1->num_reg, s2->num_reg); + XBT_DEBUG("Different num_reg (s1 = %u, s2 = %u)", s1->num_reg, s2->num_reg); return 1; } @@ -73,7 +167,7 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){ return 1; } } - if(mmalloc_compare_heap(s1->regions[i]->data, s2->regions[i]->data, std_heap)){ + if(mmalloc_compare_heap(s1->regions[i]->data, s2->regions[i]->data, s_heap, r_heap)){ if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){ XBT_DEBUG("Different heap (mmalloc_compare)"); errors++; @@ -82,7 +176,7 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){ } } break; - /*case 1 : + case 1 : if(s1->regions[i]->size != s2->regions[i]->size){ if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){ XBT_DEBUG("Different size of libsimgrid (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size); @@ -99,16 +193,41 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){ return 1; } } - if(memcmp(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){ + if(data_program_region_compare(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){ + if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){ + XBT_DEBUG("Different memcmp for data in libsimgrid"); + errors++; + }else{ + return 1; + } + } + break; + case 2 : + if(s1->regions[i]->size != s2->regions[i]->size){ + if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){ + XBT_DEBUG("Different size of data program (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size); + errors++; + }else{ + return 1; + } + } + if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){ + if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){ + XBT_DEBUG("Different start addr of data program (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr); + errors++; + }else{ + return 1; + } + } + if(data_libsimgrid_region_compare(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){ if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){ XBT_DEBUG("Different memcmp for data in libsimgrid"); - XBT_DEBUG("Size : %zu", s1->regions[i]->size); errors++; }else{ return 1; } } - break;*/ + break; default: break; } @@ -116,7 +235,6 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){ return (errors > 0); - } int reached(xbt_state_t st){ @@ -135,13 +253,13 @@ int reached(xbt_state_t st){ xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL); int res; - int (*f)(); + int_f_void_t f; /* Get values of propositional symbols */ unsigned int cursor = 0; xbt_propositional_symbol_t ps = NULL; xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){ - f = ps->function; + f = (int_f_void_t)ps->function; res = (*f)(); xbt_dynar_push_as(prop_ato, int, res); } @@ -152,13 +270,13 @@ int reached(xbt_state_t st){ //xbt_dict_t current_rdv_points = SIMIX_get_rdv_points(); xbt_dynar_foreach(reached_pairs, cursor, pair_test){ - XBT_DEBUG("Pair reached #%d", cursor+1); + XBT_DEBUG("Pair reached #%u", cursor+1); if(automaton_state_compare(pair_test->automaton_state, st) == 0){ if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){ //XBT_DEBUG("Rdv points size %d - %d", xbt_dict_length(pair_test->rdv_points), xbt_dict_length(current_rdv_points)); //if(xbt_dict_length(pair_test->rdv_points) == xbt_dict_length(current_rdv_points)){ //if(rdv_points_compare(pair_test->rdv_points, current_rdv_points) == 0){ - if(snapshot_compare(pair_test->system_state, sn) == 0){ + if(snapshot_compare(pair_test->system_state, sn, std_heap, raw_heap) == 0){ MC_free_snapshot(sn); xbt_dynar_reset(prop_ato); xbt_free(prop_ato); @@ -244,7 +362,7 @@ int rdv_points_compare(xbt_dict_t d1, xbt_dict_t d2){ /* d1 = pair_test, d2 = cu req2 = (smx_simcall_t) xbt_fifo_get_item_content(item_req2); if(req1->call != req2->call){ - XBT_DEBUG("Different simcall call in simcalls of action (%d - %d)", req1->call, req2->call); + XBT_DEBUG("Different simcall call in simcalls of action (%d - %d)", (int)req1->call, (int)req2->call); return 1; } if(req1->issuer->pid != req2->issuer->pid){ @@ -364,10 +482,10 @@ void set_pair_reached(xbt_state_t st){ unsigned int cursor = 0; xbt_propositional_symbol_t ps = NULL; int res; - int (*f)(); + int_f_void_t f; xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){ - f = ps->function; + f = (int_f_void_t)ps->function; res = (*f)(); xbt_dynar_push_as(pair->prop_ato, int, res); } @@ -429,10 +547,10 @@ int reached_hash(xbt_state_t st){ unsigned int cursor = 0; xbt_propositional_symbol_t ps = NULL; int res; - int (*f)(); + int_f_void_t f; xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){ - f = ps->function; + f = (int_f_void_t)ps->function; res = (*f)(); xbt_dynar_push_as(prop_ato, int, res); } @@ -503,10 +621,10 @@ void set_pair_reached_hash(xbt_state_t st){ unsigned int cursor = 0; xbt_propositional_symbol_t ps = NULL; int res; - int (*f)(); + int_f_void_t f; xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){ - f = ps->function; + f = (int_f_void_t)ps->function; res = (*f)(); xbt_dynar_push_as(pair->prop_ato, int, res); } @@ -540,10 +658,10 @@ int visited(xbt_state_t st, int sc){ unsigned int cursor = 0; xbt_propositional_symbol_t ps = NULL; int res; - int (*f)(); + int_f_void_t f; xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){ - f = ps->function; + f = (int_f_void_t)ps->function; res = (*f)(); xbt_dynar_push_as(prop_ato, int, res); } @@ -555,7 +673,7 @@ int visited(xbt_state_t st, int sc){ if(pair_test->search_cycle == sc) { if(automaton_state_compare(pair_test->automaton_state, st) == 0){ if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){ - if(snapshot_compare(pair_test->system_state, sn) == 0){ + if(snapshot_compare(pair_test->system_state, sn, std_heap, raw_heap) == 0){ MC_free_snapshot(sn); xbt_dynar_reset(prop_ato); @@ -615,10 +733,10 @@ int visited_hash(xbt_state_t st, int sc){ unsigned int cursor = 0; xbt_propositional_symbol_t ps = NULL; int res; - int (*f)(); + int_f_void_t f; xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){ - f = ps->function; + f = (int_f_void_t)ps->function; res = (*f)(); xbt_dynar_push_as(prop_ato, int, res); } @@ -645,16 +763,16 @@ int visited_hash(xbt_state_t st, int sc){ MC_UNSET_RAW_MEM; return 1; }else{ - XBT_DEBUG("Different snapshot"); + //XBT_DEBUG("Different snapshot"); } }else{ - XBT_DEBUG("Different values of propositional symbols"); + //XBT_DEBUG("Different values of propositional symbols"); } }else{ - XBT_DEBUG("Different automaton state"); + //XBT_DEBUG("Different automaton state"); } }else{ - XBT_DEBUG("Different value of search_cycle"); + //XBT_DEBUG("Different value of search_cycle"); } region_diff = 0; @@ -693,10 +811,10 @@ void set_pair_visited_hash(xbt_state_t st, int sc){ unsigned int cursor = 0; xbt_propositional_symbol_t ps = NULL; int res; - int (*f)(); + int_f_void_t f; xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){ - f = ps->function; + f = (int_f_void_t)ps->function; res = (*f)(); xbt_dynar_push_as(pair->prop_ato, int, res); } @@ -727,10 +845,10 @@ void set_pair_visited(xbt_state_t st, int sc){ unsigned int cursor = 0; xbt_propositional_symbol_t ps = NULL; int res; - int (*f)(); + int_f_void_t f; xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){ - f = ps->function; + f = (int_f_void_t)ps->function; res = (*f)(); xbt_dynar_push_as(pair->prop_ato, int, res); } @@ -757,39 +875,33 @@ int MC_automaton_evaluate_label(xbt_exp_label_t l){ int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp); int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp); return (left_res || right_res); - break; } case 1 : { int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp); int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp); return (left_res && right_res); - break; } case 2 : { int res = MC_automaton_evaluate_label(l->u.exp_not); return (!res); - break; } case 3 : { unsigned int cursor = 0; xbt_propositional_symbol_t p = NULL; - int (*f)(); + int_f_void_t f; xbt_dynar_foreach(automaton->propositional_symbols, cursor, p){ if(strcmp(p->pred, l->u.predicat) == 0){ - f = p->function; + f = (int_f_void_t)p->function; return (*f)(); } } return -1; - break; } case 4 : { return 2; - break; } default : return -1; - break; } } @@ -818,9 +930,13 @@ void MC_ddfs_init(void){ XBT_DEBUG("Double-DFS init"); XBT_DEBUG("**************************************************"); + XBT_DEBUG("Std heap : %p", std_heap); + XBT_DEBUG("Raw heap : %p", raw_heap); + mc_pair_stateless_t mc_initial_pair = NULL; mc_state_t initial_graph_state = NULL; smx_process_t process; + MC_wait_for_requests(); @@ -909,7 +1025,7 @@ void MC_ddfs(int search_cycle){ mc_stats_pair->visited_pairs++; - sleep(1); + //sleep(1); int value; mc_state_t next_graph_state = NULL; @@ -1008,7 +1124,7 @@ void MC_ddfs(int search_cycle){ if(reached(pair_succ->automaton_state)){ //if(reached_hash(pair_succ->automaton_state)){ - XBT_DEBUG("Next pair (depth = %d, %d interleave) already reached !", xbt_fifo_size(mc_stack_liveness) + 1, MC_state_interleave_size(pair_succ->graph_state)); + XBT_DEBUG("Next pair (depth = %d, %u interleave) already reached !", xbt_fifo_size(mc_stack_liveness) + 1, MC_state_interleave_size(pair_succ->graph_state)); XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"); XBT_INFO("| ACCEPTANCE CYCLE |"); @@ -1098,7 +1214,7 @@ void MC_ddfs(int search_cycle){ } if(MC_state_interleave_size(current_pair->graph_state) > 0){ - XBT_DEBUG("Backtracking to depth %u", xbt_fifo_size(mc_stack_liveness)); + XBT_DEBUG("Backtracking to depth %d", xbt_fifo_size(mc_stack_liveness)); MC_replay_liveness(mc_stack_liveness, 0); } } @@ -1251,9 +1367,9 @@ void MC_ddfs(int search_cycle){ } if(xbt_fifo_size(mc_stack_liveness) == MAX_DEPTH_LIVENESS ){ - XBT_DEBUG("Pair (graph=%p, automaton =%p, search_cycle = %u, depth = %d) shifted in stack, maximum depth reached", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) ); + XBT_DEBUG("Pair (graph=%p, automaton =%p, search_cycle = %d, depth = %d) shifted in stack, maximum depth reached", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) ); }else{ - XBT_DEBUG("Pair (graph=%p, automaton =%p, search_cycle = %u, depth = %d) shifted in stack", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) ); + XBT_DEBUG("Pair (graph=%p, automaton =%p, search_cycle = %d, depth = %d) shifted in stack", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) ); }