- if(mdp1->heapinfo[i].type > 0){ /* busy fragmented block */
-
- if(mdp1->heapinfo[i].type != mdp2->heapinfo[i].type){
- fprintf(stderr,"Different size of fragments in fragmented block %zu : %d - %d\n", i, mdp1->heapinfo[i].type, mdp2->heapinfo[i].type);
- errors++;
- }
-
- if(mdp1->heapinfo[i].busy_frag.nfree != mdp2->heapinfo[i].busy_frag.nfree){
- fprintf(stderr,"Different free fragments in fragmented block %zu : %zu - %zu\n", i, mdp1->heapinfo[i].busy_frag.nfree, mdp2->heapinfo[i].busy_frag.nfree);
- errors++;
- }
-
- if(mdp1->heapinfo[i].busy_frag.first != mdp2->heapinfo[i].busy_frag.first){
- 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);
- errors++;
- }
-
- frag_size = pow(2, mdp1->heapinfo[i].type);
-
- for(j=0; j< (BLOCKSIZE/frag_size); j++){
-
- if(mdp1->heapinfo[i].busy_frag.frag_size[j] != mdp2->heapinfo[i].busy_frag.frag_size[j]){
- fprintf(stderr,"Different busy_size for fragment %zu in block %zu : %hu - %hu\n", j, i, mdp1->heapinfo[i].busy_frag.frag_size[j], mdp2->heapinfo[i].busy_frag.frag_size[j]);
- errors++;
- }
-
- if(mdp1->heapinfo[i].busy_frag.frag_size[j] > 0){
-
- addr_frag1 = (char *)addr_block1 + (j * frag_size);
- addr_frag2 = (char *)addr_block2 + (j * frag_size);
-
- //if(memcmp(addr_frag1, addr_frag2, frag_size) != 0){
- if(memcmp(addr_frag1, addr_frag2, mdp1->heapinfo[i].busy_frag.frag_size[j]) != 0){
- fprintf(stderr,"\nDifferent data in fragment %zu (size = %zu, size used = %hu) in block %zu \n", j, frag_size, mdp1->heapinfo[i].busy_frag.frag_size[j], i);
-
- /* Hamming distance on different blocks */
- distance = 0;
- //for(k=0;k<frag_size;k++){
- for(k=0;k<mdp1->heapinfo[i].busy_frag.frag_size[j];k++){
- if(memcmp(((char *)addr_frag1) + k, ((char *)addr_frag2) + k, 1) != 0){
- fprintf(stderr, "Different byte (offset=%d) (%p - %p) in fragment %zu in block %zu\n", k, (char *)addr_frag1 + k, (char *)addr_frag2 + k, j, i);
- distance++;
- pointer_align = (k / sizeof(void*)) * sizeof(void*);
- pointed_address1 = xbt_strdup(get_addr_memory_map(*((void **)((char *)addr_frag1 + pointer_align)), s_heap, r_heap));
- pointed_address2 = xbt_strdup(get_addr_memory_map(*((void **)((char *)addr_frag2 + pointer_align)), s_heap, r_heap));
- fprintf(stderr, "Pointed address : %p (in %s) - %p (in %s)\n", *((void **)((char *)addr_frag1 + pointer_align)), pointed_address1, *((void **)((char *)addr_frag2 + pointer_align)), pointed_address2);
- if((strcmp(pointed_address1, pointed_address2) == 0) && (strcmp(pointed_address1, "std_heap") == 0)){
- /* FIXME : compare value pointed thanks to DWARF */
- }
- }
- }
-
- fprintf(stderr, "Hamming distance between fragments : %d\n", distance);
-
- mmalloc_backtrace_fragment_display(mdp1, i, j);
- mmalloc_backtrace_fragment_display(mdp2, i, j);
- errors++;
- }
-
- }
- }
-
- i++;
-
- }else{ /* free block */
-
- i++;
+ }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] == 0) /* Free fragment */
+ 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(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(mmalloc_ignore)){
+ if(in_mmalloc_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);
+ }else{
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[current_block].busy_frag.frag_size[current_fragment], previous, 0);
+ }
+
+ if(res_compare == 0){
+ equal = 1;
+ match_equals(previous);
+ }
+
+ xbt_dynar_reset(previous);
+
+ }
+
+ }
+
+
+ while(i2 <= heaplimit && !equal){
+
+ if(heapinfo2[i2].type <= 0){
+ i2++;
+ continue;
+ }
+
+ for(j2=0; j2 < (size_t) (BLOCKSIZE >> heapinfo2[i2].type); j2++){
+
+ if(heapinfo2[i2].type == heapinfo1[i1].type && i2 == current_block && j2 == current_fragment)
+ continue;
+
+ if(heapinfo2[i2].busy_frag.equal_to[j2] == 1)
+ continue;
+
+ if(heapinfo1[i1].busy_frag.frag_size[j1] != heapinfo2[i2].busy_frag.frag_size[j2]) /* Different size_used */
+ continue;
+
+ addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)heapbase2));
+ addr_frag2 = (void*) ((char *)addr_block2 + (j2 << heapinfo2[i2].type));
+
+ /* Comparison */
+ add_heap_area_pair(previous, i1, j1, i2, j2);
+
+ if(ignore_done < xbt_dynar_length(mmalloc_ignore)){
+ if(in_mmalloc_ignore((int)i1, (int)j1))
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[i1].busy_frag.frag_size[j1], previous, 1);
+ else
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[i1].busy_frag.frag_size[j1], previous, 0);
+ }else{
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[i1].busy_frag.frag_size[j1], previous, 0);
+ }
+
+ if(!res_compare){
+ equal = 1;
+ match_equals(previous);
+ xbt_dynar_reset(previous);
+ break;
+ }
+
+ xbt_dynar_reset(previous);
+
+ }
+
+ i2++;
+
+ }