X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d9b9d38da9e9f4cd8ee8cf4aaf3dda862f7b557f..3b83099adfbb07a89843ad15c9c1b8f8a62c4893:/src/xbt/mmalloc/mm_diff.c diff --git a/src/xbt/mmalloc/mm_diff.c b/src/xbt/mmalloc/mm_diff.c index cc06d0395f..a079804c63 100644 --- a/src/xbt/mmalloc/mm_diff.c +++ b/src/xbt/mmalloc/mm_diff.c @@ -134,14 +134,27 @@ static int compare_backtrace(int b1, int f1, int b2, int f2){ typedef char* type_name; struct s_mm_diff { - void *s_heap, *heapbase1, *heapbase2; + /** \brief Base address of the real heap */ + void *s_heap; + /** \brief Base address of the first heap snapshot */ + void *heapbase1; + /** \brief Base address of the second heap snapshot */ + void *heapbase2; malloc_info *heapinfo1, *heapinfo2; - size_t heaplimit, heapsize1, heapsize2; + size_t heaplimit; + // Number of blocks in the heaps: + size_t heapsize1, heapsize2; xbt_dynar_t to_ignore1, to_ignore2; - heap_area_t **equals_to1, **equals_to2; - type_name **types1, **types2; + s_heap_area_t *equals_to1, *equals_to2; + dw_type_t *types1, *types2; + size_t available; }; +#define equals_to1_(i,j) equals_to1[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)] +#define equals_to2_(i,j) equals_to2[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)] +#define types1_(i,j) types1[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)] +#define types2_(i,j) types2[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)] + __thread struct s_mm_diff* mm_diff_info = NULL; /*********************************** Free functions ************************************/ @@ -162,11 +175,11 @@ static void heap_area_free(heap_area_t area){ /************************************************************************************/ -static heap_area_t new_heap_area(int block, int fragment){ - heap_area_t area = NULL; - area = xbt_new0(s_heap_area_t, 1); - area->block = block; - area->fragment = fragment; +static s_heap_area_t make_heap_area(int block, int fragment){ + s_heap_area_t area; + area.valid = 1; + area.block = block; + area.fragment = fragment; return area; } @@ -251,65 +264,54 @@ static void match_equals(struct s_mm_diff *state, xbt_dynar_t list){ unsigned int cursor = 0; heap_area_pair_t current_pair; - heap_area_t previous_area; xbt_dynar_foreach(list, cursor, current_pair){ if(current_pair->fragment1 != -1){ - if(state->equals_to1[current_pair->block1][current_pair->fragment1] != NULL){ - previous_area = state->equals_to1[current_pair->block1][current_pair->fragment1]; - heap_area_free(state->equals_to2[previous_area->block][previous_area->fragment]); - state->equals_to2[previous_area->block][previous_area->fragment] = NULL; - heap_area_free(previous_area); - } - if(state->equals_to2[current_pair->block2][current_pair->fragment2] != NULL){ - previous_area = state->equals_to2[current_pair->block2][current_pair->fragment2]; - heap_area_free(state->equals_to1[previous_area->block][previous_area->fragment]); - state->equals_to1[previous_area->block][previous_area->fragment] = NULL; - heap_area_free(previous_area); - } - - state->equals_to1[current_pair->block1][current_pair->fragment1] = new_heap_area(current_pair->block2, current_pair->fragment2); - state->equals_to2[current_pair->block2][current_pair->fragment2] = new_heap_area(current_pair->block1, current_pair->fragment1); + state->equals_to1_(current_pair->block1,current_pair->fragment1) = make_heap_area(current_pair->block2, current_pair->fragment2); + state->equals_to2_(current_pair->block2,current_pair->fragment2) = make_heap_area(current_pair->block1, current_pair->fragment1); }else{ - if(state->equals_to1[current_pair->block1][0] != NULL){ - previous_area = state->equals_to1[current_pair->block1][0]; - heap_area_free(state->equals_to2[previous_area->block][0]); - state->equals_to2[previous_area->block][0] = NULL; - heap_area_free(previous_area); - } - if(state->equals_to2[current_pair->block2][0] != NULL){ - previous_area = state->equals_to2[current_pair->block2][0]; - heap_area_free(state->equals_to1[previous_area->block][0]); - state->equals_to1[previous_area->block][0] = NULL; - heap_area_free(previous_area); - } - - state->equals_to1[current_pair->block1][0] = new_heap_area(current_pair->block2, current_pair->fragment2); - state->equals_to2[current_pair->block2][0] = new_heap_area(current_pair->block1, current_pair->fragment1); + state->equals_to1_(current_pair->block1,0) = make_heap_area(current_pair->block2, current_pair->fragment2); + state->equals_to2_(current_pair->block2,0) = make_heap_area(current_pair->block1, current_pair->fragment1); } } } +/** Check whether two blocks are known to be matching + * + * @param state State used + * @param b1 Block of state 1 + * @param b2 Block of state 2 + * @return if the blocks are known to be matching + */ static int equal_blocks(struct s_mm_diff *state, int b1, int b2){ - if(state->equals_to1[b1][0]->block == b2 && state->equals_to2[b2][0]->block == b1) + if(state->equals_to1_(b1,0).block == b2 && state->equals_to2_(b2,0).block == b1) return 1; return 0; } +/** Check whether two fragments are known to be matching + * + * @param state State used + * @param b1 Block of state 1 + * @param f1 Fragment of state 1 + * @param b2 Block of state 2 + * @param f2 Fragment of state 2 + * @return if the fragments are known to be matching + */ static int equal_fragments(struct s_mm_diff *state, int b1, int f1, int b2, int f2){ - if(state->equals_to1[b1][f1]->block == b2 - && state->equals_to1[b1][f1]->fragment == f2 - && state->equals_to2[b2][f2]->block == b1 - && state->equals_to2[b2][f2]->fragment == f1) + if(state->equals_to1_(b1,f1).block == b2 + && state->equals_to1_(b1,f1).fragment == f2 + && state->equals_to2_(b2,f2).block == b1 + && state->equals_to2_(b2,f2).fragment == f1) return 1; return 0; @@ -318,6 +320,10 @@ static int equal_fragments(struct s_mm_diff *state, int b1, int f1, int b2, int int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t i1, xbt_dynar_t i2){ if(mm_diff_info==NULL) { mm_diff_info = xbt_new0(struct s_mm_diff, 1); + mm_diff_info->equals_to1 = NULL; + mm_diff_info->equals_to2 = NULL; + mm_diff_info->types1 = NULL; + mm_diff_info->types2 = NULL; } struct s_mm_diff *state = mm_diff_info; @@ -325,11 +331,12 @@ int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t i1, || ((((struct mdesc *)heap1)->heapsize != ((struct mdesc *)heap2)->heapsize) )) return -1; - int i, j; - state->heaplimit = ((struct mdesc *)heap1)->heaplimit; - state->s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - getpagesize(); + // Mamailloute in order to find the base address of the main heap: + // This heavily depends on the structure of MC: we need to move this code into MC. + // (STD_HEAP_SIZE comes from mc.h anyway) + state->s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - xbt_pagesize; state->heapbase1 = (char *)heap1 + BLOCKSIZE; state->heapbase2 = (char *)heap2 + BLOCKSIZE; @@ -343,27 +350,18 @@ int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t i1, state->to_ignore1 = i1; state-> to_ignore2 = i2; - state->equals_to1 = malloc(state->heaplimit * sizeof(heap_area_t *)); - state->types1 = malloc(state->heaplimit * sizeof(type_name *)); - for(i=0; i<=state->heaplimit; i++){ - state->equals_to1[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(heap_area_t)); - state->types1[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(type_name)); - for(j=0; jequals_to1[i][j] = NULL; - state->types1[i][j] = NULL; - } + if(state->heaplimit > state->available) { + state->equals_to1 = realloc(state->equals_to1, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t)); + state->types1 = realloc(state->types1, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *)); + state->equals_to2 = realloc(state->equals_to2, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t)); + state->types2 = realloc(state->types2, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *)); + state->available = state->heaplimit; } - state->equals_to2 = malloc(state->heaplimit * sizeof(heap_area_t *)); - state->types2 = malloc(state->heaplimit * sizeof(type_name *)); - for(i=0; i<=state->heaplimit; i++){ - state->equals_to2[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(heap_area_t)); - state->types2[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(type_name)); - for(j=0; jequals_to2[i][j] = NULL; - state->types2[i][j] = NULL; - } - } + memset(state->equals_to1, 0, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t)); + memset(state->equals_to2, 0, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t)); + memset(state->types1, 0, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *)); + memset(state->types2, 0, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *)); if(MC_is_active()){ MC_ignore_global_variable("mm_diff_info"); @@ -375,42 +373,9 @@ int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t i1, void reset_heap_information(){ - struct s_mm_diff *state = mm_diff_info; - - size_t i = 0, j; - - for(i=0; i<=state->heaplimit; i++){ - for(j=0; jequals_to1[i][j]); - state->equals_to1[i][j] = NULL; - heap_area_free(state->equals_to2[i][j]); - state-> equals_to2[i][j] = NULL; - xbt_free(state->types1[i][j]); - state->types1[i][j] = NULL; - xbt_free(state->types2[i][j]); - state->types2[i][j] = NULL; - } - free(state->equals_to1[i]); - free(state->equals_to2[i]); - free(state->types1[i]); - free(state->types2[i]); - } - - free(state->equals_to1); - free(state->equals_to2); - free(state->types1); - free(state->types2); - - state->s_heap = NULL, state->heapbase1 = NULL, state->heapbase2 = NULL; - state->heapinfo1 = NULL, state->heapinfo2 = NULL; - state->heaplimit = 0, state->heapsize1 = 0, state->heapsize2 = 0; - state->to_ignore1 = NULL, state->to_ignore2 = NULL; - state->equals_to1 = NULL, state->equals_to2 = NULL; - state->types1 = NULL, state->types2 = NULL; - } -int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_mheap_t heap1, xbt_mheap_t heap2, mc_object_info_t info, mc_object_info_t other_info){ +int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_mheap_t heap1, xbt_mheap_t heap2){ struct s_mm_diff *state = mm_diff_info; @@ -445,14 +410,14 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_m if(is_stack(addr_block1)){ for(k=0; k < state->heapinfo1[i1].busy_block.size; k++) - state->equals_to1[i1+k][0] = new_heap_area(i1, -1); + state->equals_to1_(i1+k,0) = make_heap_area(i1, -1); for(k=0; k < state->heapinfo2[i1].busy_block.size; k++) - state->equals_to2[i1+k][0] = new_heap_area(i1, -1); + state->equals_to2_(i1+k,0) = make_heap_area(i1, -1); i1 += state->heapinfo1[i1].busy_block.size; continue; } - if(state->equals_to1[i1][0] != NULL){ + if(state->equals_to1_(i1,0).valid){ i1++; continue; } @@ -464,17 +429,17 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_m /* Try first to associate to same block in the other heap */ if(state->heapinfo2[i1].type == state->heapinfo1[i1].type){ - if(state->equals_to2[i1][0] == NULL){ + if(state->equals_to2_(i1,0).valid == 0){ addr_block2 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase)); - res_compare = compare_heap_area(addr_block1, addr_block2, snapshot1, snapshot2, NULL, info, other_info, NULL, 0); + res_compare = compare_heap_area(addr_block1, addr_block2, snapshot1, snapshot2, NULL, NULL, 0); if(res_compare != 1){ for(k=1; k < state->heapinfo2[i1].busy_block.size; k++) - state->equals_to2[i1+k][0] = new_heap_area(i1, -1); + state->equals_to2_(i1+k,0) = make_heap_area(i1, -1); for(k=1; k < state->heapinfo1[i1].busy_block.size; k++) - state->equals_to1[i1+k][0] = new_heap_area(i1, -1); + state->equals_to1_(i1+k,0) = make_heap_area(i1, -1); equal = 1; i1 += state->heapinfo1[i1].busy_block.size; } @@ -499,18 +464,18 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_m continue; } - if(state->equals_to2[i2][0] != NULL){ + if(state->equals_to2_(i2,0).valid){ i2++; continue; } - res_compare = compare_heap_area(addr_block1, addr_block2, snapshot1, snapshot2, NULL, info, other_info, NULL, 0); + res_compare = compare_heap_area(addr_block1, addr_block2, snapshot1, snapshot2, NULL, NULL, 0); if(res_compare != 1 ){ for(k=1; k < state->heapinfo2[i2].busy_block.size; k++) - state->equals_to2[i2+k][0] = new_heap_area(i1, -1); + state->equals_to2_(i2+k,0) = make_heap_area(i1, -1); for(k=1; k < state->heapinfo1[i1].busy_block.size; k++) - state->equals_to1[i1+k][0] = new_heap_area(i2, -1); + state->equals_to1_(i1+k,0) = make_heap_area(i2, -1); equal = 1; i1 += state->heapinfo1[i1].busy_block.size; } @@ -535,7 +500,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_m if(state->heapinfo1[i1].busy_frag.frag_size[j1] == -1) /* Free fragment */ continue; - if(state->equals_to1[i1][j1] != NULL) + if(state->equals_to1_(i1,j1).valid) continue; addr_frag1 = (void*) ((char *)addr_block1 + (j1 << state->heapinfo1[i1].type)); @@ -546,12 +511,12 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_m /* Try first to associate to same fragment in the other heap */ if(state->heapinfo2[i1].type == state->heapinfo1[i1].type){ - if(state->equals_to2[i1][j1] == NULL){ + if(state->equals_to2_(i1,j1).valid == 0){ addr_block2 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase)); addr_frag2 = (void*) ((char *)addr_block2 + (j1 << ((xbt_mheap_t)state->s_heap)->heapinfo[i1].type)); - res_compare = compare_heap_area(addr_frag1, addr_frag2, snapshot1, snapshot2, NULL, info, other_info, NULL, 0); + res_compare = compare_heap_area(addr_frag1, addr_frag2, snapshot1, snapshot2, NULL, NULL, 0); if(res_compare != 1) equal = 1; @@ -574,13 +539,13 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_m if(i2 == i1 && j2 == j1) continue; - if(state->equals_to2[i2][j2] != NULL) + if(state->equals_to2_(i2,j2).valid) continue; addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase)); addr_frag2 = (void*) ((char *)addr_block2 + (j2 <<((xbt_mheap_t)state->s_heap)->heapinfo[i2].type)); - res_compare = compare_heap_area(addr_frag1, addr_frag2, snapshot2, snapshot2, NULL, info, other_info, NULL, 0); + res_compare = compare_heap_area(addr_frag1, addr_frag2, snapshot2, snapshot2, NULL, NULL, 0); if(res_compare != 1){ equal = 1; @@ -620,7 +585,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_m if(state->heapinfo1[i].type == 0){ if(i1 == state->heaplimit){ if(state->heapinfo1[i].busy_block.busy_size > 0){ - if(state->equals_to1[i][0] == NULL){ + if(state->equals_to1_(i,0).valid == 0){ if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){ addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)state->heapbase1)); XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i, addr_block1, state->heapinfo1[i].busy_block.busy_size); @@ -637,7 +602,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_m for(j=0; j < (size_t) (BLOCKSIZE >> state->heapinfo1[i].type); j++){ if(i1== state->heaplimit){ if(state->heapinfo1[i].busy_frag.frag_size[j] > 0){ - if(state->equals_to1[i][j] == NULL){ + if(state->equals_to1_(i,j).valid == 0){ if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){ addr_frag1 = (void*) ((char *)addr_block1 + (j << state->heapinfo1[i].type)); real_addr_frag1 = (void*) ((char *)real_addr_block1 + (j << ((struct mdesc *)state->s_heap)->heapinfo[i].type)); @@ -662,7 +627,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_m if(state->heapinfo2[i].type == 0){ if(i1 == state->heaplimit){ if(state->heapinfo2[i].busy_block.busy_size > 0){ - if(state->equals_to2[i][0] == NULL){ + if(state->equals_to2_(i,0).valid == 0){ if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){ addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)state->heapbase2)); XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i, addr_block2, state->heapinfo2[i].busy_block.busy_size); @@ -679,7 +644,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_m for(j=0; j < (size_t) (BLOCKSIZE >> state->heapinfo2[i].type); j++){ if(i1 == state->heaplimit){ if(state->heapinfo2[i].busy_frag.frag_size[j] > 0){ - if(state->equals_to2[i][j] == NULL){ + if(state->equals_to2_(i,j).valid == 0){ if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){ addr_frag2 = (void*) ((char *)addr_block2 + (j << state->heapinfo2[i].type)); real_addr_frag2 = (void*) ((char *)real_addr_block2 + (j << ((struct mdesc *)state->s_heap)->heapinfo[i].type)); @@ -704,7 +669,20 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_m return ((nb_diff1 > 0) || (nb_diff2 > 0)); } -static int compare_heap_area_without_type(struct s_mm_diff *state, void *real_area1, void *real_area2, void *area1, void *area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_dynar_t previous, mc_object_info_t info, mc_object_info_t other_info, int size, int check_ignore){ +/** + * + * @param state + * @param real_area1 Process address for state 1 + * @param real_area2 Process address for state 2 + * @param area1 Snapshot address for state 1 + * @param area2 Snapshot address for state 2 + * @param snapshot1 Snapshot of state 1 + * @param snapshot2 Snapshot of state 2 + * @param previous + * @param size + * @param check_ignore + */ +static int compare_heap_area_without_type(struct s_mm_diff *state, void *real_area1, void *real_area2, void *area1, void *area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_dynar_t previous, int size, int check_ignore){ int i = 0; void *addr_pointed1, *addr_pointed2; @@ -739,7 +717,7 @@ static int compare_heap_area_without_type(struct s_mm_diff *state, void *real_ar continue; }else if((addr_pointed1 > state->s_heap) && ((char *)addr_pointed1 < (char *)state->s_heap + STD_HEAP_SIZE) && (addr_pointed2 > state->s_heap) && ((char *)addr_pointed2 < (char *)state->s_heap + STD_HEAP_SIZE)){ - res_compare = compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, previous, info, other_info, NULL, 0); + res_compare = compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, previous, NULL, 0); if(res_compare == 1){ return res_compare; } @@ -759,10 +737,25 @@ static int compare_heap_area_without_type(struct s_mm_diff *state, void *real_ar } -// area_size is either a byte_size or an elements_count?& +/** + * + * @param state + * @param real_area1 Process address for state 1 + * @param real_area2 Process address for state 2 + * @param area1 Snapshot address for state 1 + * @param area2 Snapshot address for state 2 + * @param snapshot1 Snapshot of state 1 + * @param snapshot2 Snapshot of state 2 + * @param previous + * @param type_id + * @param area_size either a byte_size or an elements_count (?) + * @param check_ignore + * @param pointer_level + * @return 0 (same), 1 (different), -1 (unknown) + */ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1, void *real_area2, void *area1, void *area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, - xbt_dynar_t previous, mc_object_info_t info, mc_object_info_t other_info, char *type_id, + xbt_dynar_t previous, dw_type_t type, int area_size, int check_ignore, int pointer_level){ if(is_stack(real_area1) && is_stack(real_area2)) @@ -774,9 +767,8 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 return 0; } - dw_type_t type = xbt_dict_get_or_null(info->types, type_id); dw_type_t subtype, subsubtype; - int res, elm_size, i, switch_types = 0; + int res, elm_size, i; unsigned int cursor = 0; dw_type_t member; void *addr_pointed1, *addr_pointed2;; @@ -808,10 +800,10 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 case DW_TAG_typedef: case DW_TAG_const_type: case DW_TAG_volatile_type: - return compare_heap_area_with_type(state, real_area1, real_area2, area1, area2, snapshot1, snapshot2, previous, info, other_info, type->dw_type_id, area_size, check_ignore, pointer_level); + return compare_heap_area_with_type(state, real_area1, real_area2, area1, area2, snapshot1, snapshot2, previous, type->subtype, area_size, check_ignore, pointer_level); break; case DW_TAG_array_type: - subtype = xbt_dict_get_or_null(info->types, type->dw_type_id); + subtype = type->subtype; switch(subtype->type){ case DW_TAG_unspecified_type: return 1; @@ -824,10 +816,8 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 case DW_TAG_structure_type: case DW_TAG_class_type: case DW_TAG_union_type: - if(subtype->byte_size == 0){ /*declaration of the type, need the complete description */ - subtype = xbt_dict_get_or_null(other_info->types_by_name, subtype->name); - switch_types = 1; - } + if(subtype->full_type) + subtype = subtype->full_type; elm_size = subtype->byte_size; break; // TODO, just remove the type indirection? @@ -835,10 +825,8 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 case DW_TAG_typedef: case DW_TAG_volatile_type: subsubtype = subtype->subtype; - if(subsubtype->byte_size == 0){ /*declaration of the type, need the complete description */ - subsubtype = xbt_dict_get_or_null(other_info->types_by_name, subtype->name); - switch_types = 1; - } + if(subsubtype->full_type) + subsubtype = subsubtype->full_type; elm_size = subsubtype->byte_size; break; default : @@ -847,10 +835,7 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 } for(i=0; ielement_count; i++){ // TODO, add support for variable stride (DW_AT_byte_stride) - if(switch_types) - res = compare_heap_area_with_type(state, (char *)real_area1 + (i*elm_size), (char *)real_area2 + (i*elm_size), (char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), snapshot1, snapshot2, previous, other_info, info, type->dw_type_id, subtype->byte_size, check_ignore, pointer_level); - else - res = compare_heap_area_with_type(state, (char *)real_area1 + (i*elm_size), (char *)real_area2 + (i*elm_size), (char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), snapshot1, snapshot2, previous, info, other_info, type->dw_type_id, subtype->byte_size, check_ignore, pointer_level); + res = compare_heap_area_with_type(state, (char *)real_area1 + (i*elm_size), (char *)real_area2 + (i*elm_size), (char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), snapshot1, snapshot2, previous, type->subtype, subtype->byte_size, check_ignore, pointer_level); if(res == 1) return res; } @@ -858,7 +843,7 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 case DW_TAG_reference_type: case DW_TAG_rvalue_reference_type: case DW_TAG_pointer_type: - if(type->dw_type_id && ((dw_type_t)xbt_dict_get_or_null(info->types, type->dw_type_id))->type == DW_TAG_subroutine_type){ + if(type->subtype && type->subtype->type == DW_TAG_subroutine_type){ addr_pointed1 = *((void **)(area1)); addr_pointed2 = *((void **)(area2)); return (addr_pointed1 != addr_pointed2);; @@ -869,7 +854,7 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 addr_pointed1 = *((void **)((char *)area1 + (i*sizeof(void *)))); addr_pointed2 = *((void **)((char *)area2 + (i*sizeof(void *)))); if(addr_pointed1 > state->s_heap && (char *)addr_pointed1 < (char*) state->s_heap + STD_HEAP_SIZE && addr_pointed2 > state->s_heap && (char *)addr_pointed2 < (char*) state->s_heap + STD_HEAP_SIZE) - res = compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, previous, info, other_info, type->dw_type_id, pointer_level); + res = compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, previous, type->subtype, pointer_level); else res = (addr_pointed1 != addr_pointed2); if(res == 1) @@ -879,7 +864,7 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 addr_pointed1 = *((void **)(area1)); addr_pointed2 = *((void **)(area2)); if(addr_pointed1 > state->s_heap && (char *)addr_pointed1 < (char*) state->s_heap + STD_HEAP_SIZE && addr_pointed2 > state->s_heap && (char *)addr_pointed2 < (char*) state->s_heap + STD_HEAP_SIZE) - return compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, previous, info, other_info, type->dw_type_id, pointer_level); + return compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, previous, type->subtype, pointer_level); else return (addr_pointed1 != addr_pointed2); } @@ -887,22 +872,12 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 break; case DW_TAG_structure_type: case DW_TAG_class_type: - if(type->byte_size == 0){ /*declaration of the structure, need the complete description */ - dw_type_t full_type = xbt_dict_get_or_null(info->types_by_name, type->name); - if(full_type){ - type = full_type; - }else{ - type = xbt_dict_get_or_null(other_info->types_by_name, type->name); - switch_types = 1; - } - } + if(type->full_type) + type = type->full_type; if(area_size != -1 && type->byte_size != area_size){ if(area_size>type->byte_size && area_size%type->byte_size == 0){ for(i=0; i<(area_size/type->byte_size); i++){ - if(switch_types) - res = compare_heap_area_with_type(state, (char *)real_area1 + (i*type->byte_size), (char *)real_area2 + (i*type->byte_size), (char *)area1 + (i*type->byte_size), (char *)area2 + (i*type->byte_size), snapshot1, snapshot2, previous, other_info, info, type_id, -1, check_ignore, 0); - else - res = compare_heap_area_with_type(state, (char *)real_area1 + (i*type->byte_size), (char *)real_area2 + (i*type->byte_size), (char *)area1 + (i*type->byte_size), (char *)area2 + (i*type->byte_size), snapshot1, snapshot2, previous, info, other_info, type_id, -1, check_ignore, 0); + res = compare_heap_area_with_type(state, (char *)real_area1 + (i*type->byte_size), (char *)real_area2 + (i*type->byte_size), (char *)area1 + (i*type->byte_size), (char *)area2 + (i*type->byte_size), snapshot1, snapshot2, previous, type, -1, check_ignore, 0); if(res == 1) return res; } @@ -911,11 +886,13 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 } }else{ cursor = 0; - xbt_dynar_foreach(type->members, cursor, member){ - if(switch_types) - res = compare_heap_area_with_type(state, (char *)real_area1 + member->offset, (char *)real_area2 + member->offset, (char *)area1 + member->offset, (char *)area2 + member->offset, snapshot1, snapshot2, previous, other_info, info, member->dw_type_id, -1, check_ignore, 0); - else - res = compare_heap_area_with_type(state, (char *)real_area1 + member->offset, (char *)real_area2 + member->offset, (char *)area1 + member->offset, (char *)area2 + member->offset, snapshot1, snapshot2, previous, info, other_info, member->dw_type_id, -1, check_ignore, 0); + xbt_dynar_foreach(type->members, cursor, member){ + // TODO, optimize this? (for the offset case) + char* real_member1 = mc_member_resolve(real_area1, type, member, snapshot1); + char* real_member2 = mc_member_resolve(real_area2, type, member, snapshot2); + char* member1 = mc_translate_address((uintptr_t)real_member1, snapshot1); + char* member2 = mc_translate_address((uintptr_t)real_member2, snapshot2); + res = compare_heap_area_with_type(state, real_member1, real_member2, member1, member2, snapshot1, snapshot2, previous, member->subtype, -1, check_ignore, 0); if(res == 1){ return res; } @@ -923,7 +900,7 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 } break; case DW_TAG_union_type: - return compare_heap_area_without_type(state, real_area1, real_area2, area1, area2, snapshot1, snapshot2, previous, info, other_info, type->byte_size, check_ignore); + return compare_heap_area_without_type(state, real_area1, real_area2, area1, area2, snapshot1, snapshot2, previous, type->byte_size, check_ignore); break; default: break; @@ -933,46 +910,48 @@ static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1 } -static char* get_offset_type(char* type_id, int offset, mc_object_info_t info, mc_object_info_t other_info, int area_size, int *switch_type){ - dw_type_t type = xbt_dict_get_or_null(info->types, type_id); - if(type == NULL){ - type = xbt_dict_get_or_null(other_info->types, type_id); - *switch_type = 1; - } +/** Infer the type of a part of the block from the type of the block + * + * TODO, handle DW_TAG_array_type as well as arrays of the object ((*p)[5], p[5]) + * + * TODO, handle subfields ((*p).bar.foo, (*p)[5].bar…) + * + * @param type_id DWARF type ID of the root address + * @param area_size + * @return DWARF type ID for given offset + */ +static dw_type_t get_offset_type(void* real_base_address, dw_type_t type, int offset, int area_size, mc_snapshot_t snapshot){ + + // Beginning of the block, the infered variable type if the type of the block: + if(offset==0) + return type; + switch(type->type){ case DW_TAG_structure_type : case DW_TAG_class_type: - if(type->byte_size == 0){ /*declaration of the structure, need the complete description */ - if(*switch_type == 0){ - dw_type_t full_type = xbt_dict_get_or_null(info->types_by_name, type->name); - if(full_type){ - type = full_type; - }else{ - type = xbt_dict_get_or_null(other_info->types_by_name, type->name); - *switch_type = 1; - } - }else{ - dw_type_t full_type = xbt_dict_get_or_null(other_info->types_by_name, type->name); - if(full_type){ - type = full_type; - }else{ - type = xbt_dict_get_or_null(info->types_by_name, type->name); - *switch_type = 0; - } - } + if(type->full_type) + type = type->full_type; - } if(area_size != -1 && type->byte_size != area_size){ if(area_size>type->byte_size && area_size%type->byte_size == 0) - return type_id; + return type; else return NULL; }else{ unsigned int cursor = 0; dw_type_t member; xbt_dynar_foreach(type->members, cursor, member){ - if(member->offset == offset) - return member->dw_type_id; + + if(!member->location.size) { + // We have the offset, use it directly (shortcut): + if(member->offset == offset) + return member->subtype; + } else { + char* real_member = mc_member_resolve(real_base_address, type, member, snapshot); + if(real_member - (char*)real_base_address == offset) + return member->subtype; + } + } return NULL; } @@ -984,7 +963,18 @@ static char* get_offset_type(char* type_id, int offset, mc_object_info_t info, m } } -int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_dynar_t previous, mc_object_info_t info, mc_object_info_t other_info, char *type_id, int pointer_level){ +/** + * + * @param area1 Process address for state 1 + * @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 type_id Type of variable + * @param pointer_level + * @return 0 (same), 1 (different), -1 + */ +int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_dynar_t previous, dw_type_t type, int pointer_level){ struct s_mm_diff* state = mm_diff_info; @@ -995,12 +985,10 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2, *real_addr_block1, *real_addr_block2, *real_addr_frag1, *real_addr_frag2; void *area1_to_compare, *area2_to_compare; - dw_type_t type = NULL; int type_size = -1; int offset1 =0, offset2 = 0; int new_size1 = -1, new_size2 = -1; - char *new_type_id1 = NULL, *new_type_id2 = NULL; - int switch_type = 0; + dw_type_t new_type1 = NULL, new_type2 = NULL; int match_pairs = 0; @@ -1009,9 +997,11 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap match_pairs = 1; } + // Get block number: block1 = ((char*)area1 - (char*)((xbt_mheap_t)state->s_heap)->heapbase) / BLOCKSIZE + 1; block2 = ((char*)area2 - (char*)((xbt_mheap_t)state->s_heap)->heapbase) / BLOCKSIZE + 1; + // If either block is a stack block: if(is_block_stack((int)block1) && is_block_stack((int)block2)){ add_heap_area_pair(previous, block1, -1, block2, -1); if(match_pairs){ @@ -1021,36 +1011,38 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap return 0; } - if(((char *)area1 < (char*)((xbt_mheap_t)state->s_heap)->heapbase) || (block1 > state->heapsize1) || (block1 < 1) || ((char *)area2 < (char*)((xbt_mheap_t)state->s_heap)->heapbase) || (block2 > state->heapsize2) || (block2 < 1)){ + // If either block is not in the expected area of memory: + if(((char *)area1 < (char*)((xbt_mheap_t)state->s_heap)->heapbase) || (block1 > state->heapsize1) || (block1 < 1) + || ((char *)area2 < (char*)((xbt_mheap_t)state->s_heap)->heapbase) || (block2 > state->heapsize2) || (block2 < 1)){ if(match_pairs){ xbt_dynar_free(&previous); } return 1; } + // Snapshot address of the block: addr_block1 = ((void*) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE + (char*)state->heapbase1)); addr_block2 = ((void*) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE + (char*)state->heapbase2)); + // Process address of the block: real_addr_block1 = ((void*) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase)); real_addr_block2 = ((void*) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase)); - if(type_id){ - type = xbt_dict_get_or_null(info->types, type_id); - if(type->byte_size == 0){ - if(type->subtype == NULL){ - dw_type_t full_type = xbt_dict_get_or_null(info->types_by_name, type->name); - if(full_type) - type = full_type; - else - type = xbt_dict_get_or_null(other_info->types_by_name, type->name); - }else{ - type = type->subtype; - } - } + if(type){ + + if(type->full_type) + type = type->full_type; + + // This assume that for "boring" types (volatile ...) byte_size is absent: + while(type->byte_size == 0 && type->subtype!=NULL) + type = type->subtype; + + // Find type_size: if((type->type == DW_TAG_pointer_type) || ((type->type == DW_TAG_base_type) && type->name!=NULL && (!strcmp(type->name, "char")))) type_size = -1; else type_size = type->byte_size; + } if((state->heapinfo1[block1].type == -1) && (state->heapinfo2[block2].type == -1)){ /* Free block */ @@ -1063,7 +1055,9 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap }else if((state->heapinfo1[block1].type == 0) && (state->heapinfo2[block2].type == 0)){ /* Complete block */ - if(state->equals_to1[block1][0] != NULL && state->equals_to2[block2][0] != NULL){ + // TODO, lookup variable type from block type as done for fragmented blocks + + if(state->equals_to1_(block1,0).valid && state->equals_to2_(block2,0).valid){ if(equal_blocks(state, block1, block2)){ if(match_pairs){ match_equals(state, previous); @@ -1109,11 +1103,13 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap size = state->heapinfo1[block1].busy_block.busy_size; - if(type_id != NULL){ - xbt_free(state->types1[block1][0]); - xbt_free(state->types2[block2][0]); - state->types1[block1][0] = strdup(type_id); - state->types2[block2][0] = strdup(type_id); + // 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) { + state->types1_(block1,0) = type; + } + if (type != NULL && area2==real_addr_block2) { + state->types2_(block2,0) = type; } if(size <= 0){ @@ -1135,15 +1131,19 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap }else if((state->heapinfo1[block1].type > 0) && (state->heapinfo2[block2].type > 0)){ /* Fragmented block */ + // Fragment number: frag1 = ((uintptr_t) (ADDR2UINT (area1) % (BLOCKSIZE))) >> state->heapinfo1[block1].type; frag2 = ((uintptr_t) (ADDR2UINT (area2) % (BLOCKSIZE))) >> state->heapinfo2[block2].type; + // Snapshot address of the fragment: addr_frag1 = (void*) ((char *)addr_block1 + (frag1 << state->heapinfo1[block1].type)); addr_frag2 = (void*) ((char *)addr_block2 + (frag2 << state->heapinfo2[block2].type)); + // Process address of the fragment: real_addr_frag1 = (void*) ((char *)real_addr_block1 + (frag1 << ((xbt_mheap_t)state->s_heap)->heapinfo[block1].type)); real_addr_frag2 = (void*) ((char *)real_addr_block2 + (frag2 << ((xbt_mheap_t)state->s_heap)->heapinfo[block2].type)); + // Check the size of the fragments against the size of the type: if(type_size != -1){ if(state->heapinfo1[block1].busy_frag.frag_size[frag1] == -1 || state->heapinfo2[block2].busy_frag.frag_size[frag2] == -1){ if(match_pairs){ @@ -1161,7 +1161,8 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap } } - if(state->equals_to1[block1][frag1] != NULL && state->equals_to2[block2][frag2] != NULL){ + // Check if the blocks are already matched together: + if(state->equals_to1_(block1,frag1).valid && state->equals_to2_(block2,frag2).valid){ if(equal_fragments(state, block1, frag1, block2, frag2)){ if(match_pairs){ match_equals(state, previous); @@ -1171,6 +1172,7 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap } } + // Compare the size of both fragments: if(state->heapinfo1[block1].busy_frag.frag_size[frag1] != state->heapinfo2[block2].busy_frag.frag_size[frag2]){ if(type_size == -1){ if(match_pairs){ @@ -1186,27 +1188,39 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap } } + // Size of the fragment: size = state->heapinfo1[block1].busy_frag.frag_size[frag1]; - if(type_id != NULL){ - xbt_free(state->types1[block1][frag1]); - xbt_free(state->types2[block2][frag2]); - state->types1[block1][frag1] = strdup(type_id); - state->types2[block2][frag2] = strdup(type_id); + // Remember (basic) type inference. + // The current data structure only allows us to do this for the whole block. + if(type != NULL && area1==real_addr_frag1){ + state->types1_(block1,frag1) = type; + } + if(type != NULL && area2==real_addr_frag2) { + state->types2_(block2,frag2) = type; + } + + // The type of the variable is already known: + if(type) { + new_type1 = type; + new_type2 = type; } - if(real_addr_frag1 != area1 || real_addr_frag2 != area2){ + // Type inference from the block type. + else if(state->types1_(block1,frag1) != NULL || state->types2_(block2,frag2) != NULL) { + 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){ - new_type_id1 = get_offset_type(state->types1[block1][frag1], offset1, info, other_info, size, &switch_type); - new_type_id2 = get_offset_type(state->types2[block2][frag2], offset1, info, other_info, size, &switch_type); - }else if(state->types1[block1][frag1] != NULL){ - new_type_id1 = get_offset_type(state->types1[block1][frag1], offset1, info, other_info, size, &switch_type); - new_type_id2 = get_offset_type(state->types1[block1][frag1], offset2, info, other_info, size, &switch_type); - }else if(state->types2[block2][frag2] != NULL){ - new_type_id1 = get_offset_type(state->types2[block2][frag2], offset1, info, other_info, size, &switch_type); - new_type_id2 = get_offset_type(state->types2[block2][frag2], offset2, info, other_info, size, &switch_type); + + if(state->types1_(block1,frag1) != NULL && state->types2_(block2,frag2) != NULL){ + new_type1 = get_offset_type(real_addr_frag1, state->types1_(block1,frag1), offset1, size, snapshot1); + new_type2 = get_offset_type(real_addr_frag2, state->types2_(block2,frag2), offset1, size, snapshot2); + }else if(state->types1_(block1,frag1) != NULL){ + new_type1 = get_offset_type(real_addr_frag1, state->types1_(block1,frag1), offset1, size, snapshot1); + new_type2 = get_offset_type(real_addr_frag2, state->types1_(block1,frag1), offset2, size, snapshot2); + }else if(state->types2_(block2,frag2) != NULL){ + new_type1 = get_offset_type(real_addr_frag1, state->types2_(block2,frag2), offset1, size, snapshot1); + new_type2 = get_offset_type(real_addr_frag2, state->types2_(block2,frag2), offset2, size, snapshot2); }else{ if(match_pairs){ match_equals(state, previous); @@ -1215,26 +1229,18 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap return -1; } - if(new_type_id1 != NULL && new_type_id2 != NULL && !strcmp(new_type_id1, new_type_id2)){ - if(switch_type){ - type = xbt_dict_get_or_null(other_info->types, new_type_id1); - while(type->byte_size == 0 && type->dw_type_id != NULL) - type = xbt_dict_get_or_null(other_info->types, type->dw_type_id); - new_size1 = type->byte_size; - type = xbt_dict_get_or_null(other_info->types, new_type_id2); - while(type->byte_size == 0 && type->dw_type_id != NULL) - type = xbt_dict_get_or_null(other_info->types, type->dw_type_id); - new_size2 = type->byte_size; - }else{ - type = xbt_dict_get_or_null(info->types, new_type_id1); - while(type->byte_size == 0 && type->dw_type_id != NULL) - type = xbt_dict_get_or_null(info->types, type->dw_type_id); + if(new_type1 != NULL && new_type2 != NULL && new_type1!=new_type2){ + + type = new_type1; + while(type->byte_size == 0 && type->subtype != NULL) + type = type->subtype; new_size1 = type->byte_size; - type = xbt_dict_get_or_null(info->types, new_type_id2); - while(type->byte_size == 0 && type->dw_type_id != NULL) - type = xbt_dict_get_or_null(info->types, type->dw_type_id); + + type = new_type2; + while(type->byte_size == 0 && type->subtype != NULL) + type = type->subtype; new_size2 = type->byte_size; - } + }else{ if(match_pairs){ match_equals(state, previous); @@ -1248,7 +1254,7 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap area2_to_compare = (char *)addr_frag2 + offset2; if(new_size1 > 0 && new_size1 == new_size2){ - type_id = new_type_id1; + type = new_type1; size = new_size1; } @@ -1284,26 +1290,15 @@ int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snap /* Start comparison*/ - if(type_id != NULL){ - if(switch_type) - res_compare = compare_heap_area_with_type(state, area1, area2, area1_to_compare, area2_to_compare, snapshot1, snapshot2, previous, other_info, info, type_id, size, check_ignore, pointer_level); - else - res_compare = compare_heap_area_with_type(state, area1, area2, area1_to_compare, area2_to_compare, snapshot1, snapshot2, previous, info, other_info, type_id, size, check_ignore, pointer_level); - if(res_compare == 1){ - if(match_pairs) - xbt_dynar_free(&previous); - return res_compare; - } + if(type){ + res_compare = compare_heap_area_with_type(state, area1, area2, area1_to_compare, area2_to_compare, snapshot1, snapshot2, previous, type, size, check_ignore, pointer_level); }else{ - if(switch_type) - res_compare = compare_heap_area_without_type(state, area1, area2, area1_to_compare, area2_to_compare, snapshot1, snapshot2, previous, other_info, info, size, check_ignore); - else - res_compare = compare_heap_area_without_type(state, area1, area2, area1_to_compare, area2_to_compare, snapshot1, snapshot2, previous, info, other_info, size, check_ignore); - if(res_compare == 1){ - if(match_pairs) - xbt_dynar_free(&previous); - return res_compare; - } + res_compare = compare_heap_area_without_type(state, area1, area2, area1_to_compare, area2_to_compare, snapshot1, snapshot2, previous, size, check_ignore); + } + if(res_compare == 1){ + if(match_pairs) + xbt_dynar_free(&previous); + return res_compare; } if(match_pairs){ @@ -1387,7 +1382,7 @@ int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){ /* Heap information */ state->heaplimit = ((struct mdesc *)heap1)->heaplimit; - state->s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - getpagesize(); + state->s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - xbt_pagesize; state->heapbase1 = (char *)heap1 + BLOCKSIZE; state->heapbase2 = (char *)heap2 + BLOCKSIZE;