- addr_block1 = (char*)heapbase1 + ((i-1)*BLOCKSIZE);
- xbt_assert(addr_block1 < breakval1, "Block address out of heap memory used");
-
- addr_block2 = (char*)heapbase2 + ((i-1)*BLOCKSIZE);
- xbt_assert(addr_block2 < breakval2, "Block address out of heap memory used");
-
- if(mdp1->heapinfo[i].type == 0){ /* busy large block */
-
- if(mdp1->heapinfo[i].busy_block.size != mdp2->heapinfo[i].busy_block.size){
- fprintf(stderr,"Different size of a large cluster : %zu - %zu\n", mdp1->heapinfo[i].busy_block.size, mdp2->heapinfo[i].busy_block.size);
- fflush(NULL);
- errors++;
- }
-
- if(mdp1->heapinfo[i].busy_block.busy_size != mdp2->heapinfo[i].busy_block.busy_size){
- fprintf(stderr,"Different busy_size of a large cluster : %zu - %zu\n", mdp1->heapinfo[i].busy_block.busy_size, mdp2->heapinfo[i].busy_block.busy_size);
- fflush(NULL);
- errors++;
- }
-
- /* Hamming distance on different blocks */
- distance = 0;
-
- //for(k=0;k<mdp1->heapinfo[i].busy_block.size * BLOCKSIZE;k++){
- for(k=0;k<mdp1->heapinfo[i].busy_block.busy_size;k++){
- if((((char *)addr_block1) + k != 0) && (((char *)addr_block2) + k != 0)){
- if(memcmp(((char *)addr_block1) + k, ((char *)addr_block2) + k, 1) != 0){
- fprintf(stderr, "Different byte (offset=%d) (%p - %p) in block %zu\n", k, (char *)addr_block1 + k, (char *)addr_block2 + k, i); fflush(NULL);
- pointer_align = (k / sizeof(void*)) * sizeof(void*);
- address_pointed1 = *((void **)((char *)addr_block1 + pointer_align));
- address_pointed2 = *((void **)((char *)addr_block2 + pointer_align));
- if(((address_pointed1 > (void *)s_heap) && (address_pointed1 < mdp1->breakval)) && ((address_pointed2 > (void *)s_heap) && (address_pointed2 < mdp2->breakval))){
- block_pointed1 = ((char*)address_pointed1 - (char*)((struct mdesc*)s_heap)->heapbase) % BLOCKSIZE;
- block_pointed2 = ((char*)address_pointed2 - (char*)((struct mdesc*)s_heap)->heapbase) % BLOCKSIZE;
- //fprintf(stderr, "Blocks pointed : %d - %d\n", block_pointed1, block_pointed2);
- if((block_pointed1 == 0) && (block_pointed2 == 0)){
- block_pointed1 = ((char*)address_pointed1 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
- block_pointed2 = ((char*)address_pointed2 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
- if(mdp1->heapinfo[block_pointed1].type == mdp2->heapinfo[block_pointed2].type){
- if(mdp1->heapinfo[block_pointed1].type == 0){ // Large block
- if(mdp1->heapinfo[block_pointed1].busy_block.busy_size == mdp2->heapinfo[block_pointed2].busy_block.busy_size){
- addr_block_pointed1 = (char*)heapbase1 + ((block_pointed1 - 1)*BLOCKSIZE);
- addr_block_pointed2 = (char*)heapbase2 + ((block_pointed2 - 1)*BLOCKSIZE);
- if(memcmp(addr_block_pointed1, addr_block_pointed2, mdp1->heapinfo[block_pointed1].busy_block.busy_size) != 0){
- distance++;
- }else{
- fprintf(stderr, "False difference detected\n");
- }
- }else{
- distance++;
- }
- }else{ // Fragmented block
- addr_block_pointed1 = (char*)mdp1 + ((char *)address_pointed1 - (char *)s_heap);
- addr_block_pointed2 = (char*)mdp2 + ((char *)address_pointed2 - (char *)s_heap);
- if(mdp1->heapinfo[block_pointed1].busy_frag.frag_size[0] == mdp2->heapinfo[block_pointed2].busy_frag.frag_size[0]){
- if(memcmp(addr_block_pointed1, addr_block_pointed2, mdp1->heapinfo[block_pointed1].busy_frag.frag_size[0]) != 0){
- fprintf(stderr, "Pointed fragments are different \n");
- distance++;
- }else{
- fprintf(stderr, "False difference detected\n");
- }
- }else{
- fprintf(stderr, "Different size of pointed fragments\n");
- distance ++;
- }
- }
+ addr_block1 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)heapbase1));
+ real_addr_block1 = (char*)((xbt_mheap_t)s_heap)->heapbase + (((char *)addr_block1) - (char *)heapbase1);
+
+ if(heapinfo1[i1].type == 0){ /* Large block */
+
+ if((stack_name = is_stack(real_addr_block1)) != NULL){
+ stack_region_t stack = xbt_new0(s_stack_region_t, 1);
+ stack->address = addr_block1;
+ stack->process_name = strdup(stack_name);
+ stack->size = heapinfo1[i1].busy_block.busy_size;
+ xbt_dynar_push(*stack1, &stack);
+ }
+
+ if(heapinfo1[i1].busy_block.busy_size == 0){
+ i1++;
+ continue;
+ }
+
+ if(heapinfo1[i1].busy_block.equal_to != NULL){
+ i1++;
+ continue;
+ }
+
+ i2 = 1;
+ equal = 0;
+
+ /* Try first to associate to same block in the other heap */
+ if(heapinfo2[current_block].type == heapinfo1[current_block].type){
+
+ if(heapinfo2[current_block].busy_block.equal_to == NULL){
+
+ if(heapinfo1[current_block].busy_block.busy_size == heapinfo2[current_block].busy_block.busy_size){
+
+ addr_block2 = ((void*) (((ADDR2UINT(current_block)) - 1) * BLOCKSIZE + (char*)heapbase2));
+ real_addr_block2 = (char*)((xbt_mheap_t)s_heap)->heapbase + (((char *)addr_block2) - (char *)heapbase2);
+
+ if((stack_name = is_stack(real_addr_block2)) != NULL){
+ stack_region_t stack = xbt_new0(s_stack_region_t, 1);
+ stack->address = addr_block2;
+ stack->process_name = strdup(stack_name);
+ stack->size = heapinfo2[current_block].busy_block.busy_size;
+ xbt_dynar_push(*stack2, &stack);
+ }
+
+ add_heap_area_pair(previous, current_block, -1, current_block, -1);
+
+ if(ignore_done < xbt_dynar_length(mc_comparison_ignore)){
+ if(in_mc_comparison_ignore((int)current_block, -1))
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 1);
+ else
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 0);
+ }else{
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 0);
+ }
+
+ if(res_compare == 0){
+ for(k=1; k < heapinfo2[current_block].busy_block.size; k++)
+ heapinfo2[current_block+k].busy_block.equal_to = new_heap_area(i1, -1);
+ for(k=1; k < heapinfo1[current_block].busy_block.size; k++)
+ heapinfo1[current_block+k].busy_block.equal_to = new_heap_area(i1, -1);
+ equal = 1;
+ match_equals(previous, equals);
+ i1 = i1 + heapinfo1[current_block].busy_block.size;
+ }
+
+ xbt_dynar_reset(previous);
+
+ }
+
+ }
+
+ }
+
+ while(i2 <= heaplimit && !equal){
+
+ addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)heapbase2));
+ real_addr_block2 = (char*)((xbt_mheap_t)s_heap)->heapbase + (((char *)addr_block2) - (char *)heapbase2);
+
+ if((stack_name = is_stack(real_addr_block2)) != NULL){
+ stack_region_t stack = xbt_new0(s_stack_region_t, 1);
+ stack->address = addr_block2;
+ stack->process_name = strdup(stack_name);
+ stack->size = heapinfo2[i2].busy_block.busy_size;
+ xbt_dynar_push(*stack2, &stack);
+ }
+
+ if(i2 == current_block){
+ i2++;
+ continue;
+ }
+
+ if(heapinfo2[i2].type != 0){
+ i2++;
+ continue;
+ }
+
+ if(heapinfo2[i2].busy_block.equal_to != NULL){
+ i2++;
+ continue;
+ }
+
+ if(heapinfo1[i1].busy_block.size != heapinfo2[i2].busy_block.size){
+ i2++;
+ continue;
+ }
+
+ if(heapinfo1[i1].busy_block.busy_size != heapinfo2[i2].busy_block.busy_size){
+ i2++;
+ continue;
+ }
+
+ /* Comparison */
+ add_heap_area_pair(previous, i1, -1, i2, -1);
+
+ if(ignore_done < xbt_dynar_length(mc_comparison_ignore)){
+ if(in_mc_comparison_ignore((int)i1, -1))
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[i1].busy_block.busy_size, previous, 1);
+ else
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[i1].busy_block.busy_size, previous, 0);
+ }else{
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[i1].busy_block.busy_size, previous, 0);
+ }
+
+ if(res_compare == 0){
+ for(k=1; k < heapinfo2[i2].busy_block.size; k++)
+ heapinfo2[i2+k].busy_block.equal_to = new_heap_area(i1, -1);
+ for(k=1; k < heapinfo1[i1].busy_block.size; k++)
+ heapinfo1[i1+k].busy_block.equal_to = new_heap_area(i2, -1);
+ equal = 1;
+ match_equals(previous, equals);
+ i1 = i1 + heapinfo1[i1].busy_block.size;
+ }
+
+ xbt_dynar_reset(previous);
+
+ i2++;
+
+ }
+
+ if(!equal)
+ i1++;
+
+ }else{ /* Fragmented block */
+
+ for(j1=0; j1 < (size_t) (BLOCKSIZE >> heapinfo1[i1].type); j1++){
+
+ current_fragment = j1;
+
+ if(heapinfo1[i1].busy_frag.frag_size[j1] == -1) /* Free fragment */
+ continue;
+
+ if(heapinfo1[i1].busy_frag.equal_to[j1] != NULL)
+ continue;
+
+ addr_frag1 = (void*) ((char *)addr_block1 + (j1 << heapinfo1[i1].type));
+
+ i2 = 1;
+ equal = 0;
+
+ /* Try first to associate to same fragment in the other heap */
+ if(heapinfo2[current_block].type == heapinfo1[current_block].type){
+
+ if(heapinfo2[current_block].busy_frag.equal_to[current_fragment] == NULL){
+
+ if(heapinfo1[current_block].busy_frag.frag_size[current_fragment] == heapinfo2[current_block].busy_frag.frag_size[current_fragment]){
+
+ addr_block2 = ((void*) (((ADDR2UINT(current_block)) - 1) * BLOCKSIZE + (char*)heapbase2));
+ addr_frag2 = (void*) ((char *)addr_block2 + (current_fragment << heapinfo2[current_block].type));
+
+ add_heap_area_pair(previous, current_block, current_fragment, current_block, current_fragment);
+
+ if(ignore_done < xbt_dynar_length(mc_comparison_ignore)){
+ if(in_mc_comparison_ignore((int)current_block, (int)current_fragment))
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[current_block].busy_frag.frag_size[current_fragment], previous, 1);
+ else
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[current_block].busy_frag.frag_size[current_fragment], previous, 0);