1 /* mm_diff - Memory snapshooting and comparison */
3 /* Copyright (c) 2008-2014. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "xbt/ex_interface.h" /* internals of backtrace setup */
12 #include "xbt/mmalloc.h"
13 #include "mc/datatypes.h"
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mm_diff, xbt,
16 "Logging specific to mm_diff in mmalloc");
18 xbt_dynar_t mc_heap_comparison_ignore;
19 xbt_dynar_t stacks_areas;
20 void *maestro_stack_start, *maestro_stack_end;
23 /********************************* Backtrace ***********************************/
24 /******************************************************************************/
26 static void mmalloc_backtrace_block_display(void* heapinfo, int block){
30 /* if (((malloc_info *)heapinfo)[block].busy_block.bt_size == 0) { */
31 /* fprintf(stderr, "No backtrace available for that block, sorry.\n"); */
35 /* memcpy(&e.bt,&(((malloc_info *)heapinfo)[block].busy_block.bt),sizeof(void*)*XBT_BACKTRACE_SIZE); */
36 /* e.used = ((malloc_info *)heapinfo)[block].busy_block.bt_size; */
38 /* xbt_ex_setup_backtrace(&e); */
39 /* if (e.used == 0) { */
40 /* fprintf(stderr, "(backtrace not set)\n"); */
41 /* } else if (e.bt_strings == NULL) { */
42 /* fprintf(stderr, "(backtrace not ready to be computed. %s)\n",xbt_binary_name?"Dunno why":"xbt_binary_name not setup yet"); */
46 /* fprintf(stderr, "Backtrace of where the block %d was malloced (%d frames):\n", block ,e.used); */
47 /* for (i = 0; i < e.used; i++) /\* no need to display "xbt_backtrace_display" *\/{ */
48 /* fprintf(stderr, "%d ---> %s\n",i, e.bt_strings[i] + 4); */
53 static void mmalloc_backtrace_fragment_display(void* heapinfo, int block, int frag){
57 /* memcpy(&e.bt,&(((malloc_info *)heapinfo)[block].busy_frag.bt[frag]),sizeof(void*)*XBT_BACKTRACE_SIZE); */
58 /* e.used = XBT_BACKTRACE_SIZE; */
60 /* xbt_ex_setup_backtrace(&e); */
61 /* if (e.used == 0) { */
62 /* fprintf(stderr, "(backtrace not set)\n"); */
63 /* } else if (e.bt_strings == NULL) { */
64 /* fprintf(stderr, "(backtrace not ready to be computed. %s)\n",xbt_binary_name?"Dunno why":"xbt_binary_name not setup yet"); */
68 /* fprintf(stderr, "Backtrace of where the fragment %d in block %d was malloced (%d frames):\n", frag, block ,e.used); */
69 /* for (i = 0; i < e.used; i++) /\* no need to display "xbt_backtrace_display" *\/{ */
70 /* fprintf(stderr, "%d ---> %s\n",i, e.bt_strings[i] + 4); */
76 static void mmalloc_backtrace_display(void *addr){
78 /* size_t block, frag_nb; */
81 /* xbt_mheap_t heap = __mmalloc_current_heap ?: (xbt_mheap_t) mmalloc_preinit(); */
83 /* block = (((char*) (addr) - (char*) heap -> heapbase) / BLOCKSIZE + 1); */
85 /* type = heap->heapinfo[block].type; */
88 /* case -1 : /\* Free block *\/ */
89 /* fprintf(stderr, "Asked to display the backtrace of a block that is free. I'm puzzled\n"); */
92 /* case 0: /\* Large block *\/ */
93 /* mmalloc_backtrace_block_display(heap->heapinfo, block); */
95 /* default: /\* Fragmented block *\/ */
96 /* frag_nb = RESIDUAL(addr, BLOCKSIZE) >> type; */
97 /* if(heap->heapinfo[block].busy_frag.frag_size[frag_nb] == -1){ */
98 /* fprintf(stderr , "Asked to display the backtrace of a fragment that is free. I'm puzzled\n"); */
101 /* mmalloc_backtrace_fragment_display(heap->heapinfo, block, frag_nb); */
107 static int compare_backtrace(int b1, int f1, int b2, int f2){
110 for(i=0; i< XBT_BACKTRACE_SIZE; i++){
111 if(heapinfo1[b1].busy_frag.bt[f1][i] != heapinfo2[b2].busy_frag.bt[f2][i]){
112 //mmalloc_backtrace_fragment_display((void*)heapinfo1, b1, f1);
113 //mmalloc_backtrace_fragment_display((void*)heapinfo2, b2, f2);
118 for(i=0; i< heapinfo1[b1].busy_block.bt_size; i++){
119 if(heapinfo1[b1].busy_block.bt[i] != heapinfo2[b2].busy_block.bt[i]){
120 //mmalloc_backtrace_block_display((void*)heapinfo1, b1);
121 //mmalloc_backtrace_block_display((void*)heapinfo2, b2);
130 /*********************************** Heap comparison ***********************************/
131 /***************************************************************************************/
133 typedef char* type_name;
135 __thread void *s_heap = NULL, *heapbase1 = NULL, *heapbase2 = NULL;
136 __thread malloc_info *heapinfo1 = NULL, *heapinfo2 = NULL;
137 __thread size_t heaplimit = 0, heapsize1 = 0, heapsize2 = 0;
138 __thread xbt_dynar_t to_ignore1 = NULL, to_ignore2 = NULL;
139 __thread heap_area_t **equals_to1, **equals_to2;
140 __thread type_name **types1, **types2;
142 /*********************************** Free functions ************************************/
144 static void heap_area_pair_free(heap_area_pair_t pair){
149 static void heap_area_pair_free_voidp(void *d){
150 heap_area_pair_free((heap_area_pair_t) * (void **) d);
153 static void heap_area_free(heap_area_t area){
158 /************************************************************************************/
160 static heap_area_t new_heap_area(int block, int fragment){
161 heap_area_t area = NULL;
162 area = xbt_new0(s_heap_area_t, 1);
164 area->fragment = fragment;
169 static int is_new_heap_area_pair(xbt_dynar_t list, int block1, int fragment1, int block2, int fragment2){
171 unsigned int cursor = 0;
172 heap_area_pair_t current_pair;
174 xbt_dynar_foreach(list, cursor, current_pair){
175 if(current_pair->block1 == block1 && current_pair->block2 == block2 && current_pair->fragment1 == fragment1 && current_pair->fragment2 == fragment2)
182 static int add_heap_area_pair(xbt_dynar_t list, int block1, int fragment1, int block2, int fragment2){
184 if(is_new_heap_area_pair(list, block1, fragment1, block2, fragment2)){
185 heap_area_pair_t pair = NULL;
186 pair = xbt_new0(s_heap_area_pair_t, 1);
187 pair->block1 = block1;
188 pair->fragment1 = fragment1;
189 pair->block2 = block2;
190 pair->fragment2 = fragment2;
192 xbt_dynar_push(list, &pair);
200 static ssize_t heap_comparison_ignore_size(xbt_dynar_t ignore_list, void *address){
202 unsigned int cursor = 0;
204 int end = xbt_dynar_length(ignore_list) - 1;
205 mc_heap_ignore_region_t region;
208 cursor = (start + end) / 2;
209 region = (mc_heap_ignore_region_t)xbt_dynar_get_as(ignore_list, cursor, mc_heap_ignore_region_t);
210 if(region->address == address)
212 if(region->address < address)
214 if(region->address > address)
221 static int is_stack(void *address){
222 unsigned int cursor = 0;
223 stack_region_t stack;
225 xbt_dynar_foreach(stacks_areas, cursor, stack){
226 if(address == stack->address)
233 static int is_block_stack(int block){
234 unsigned int cursor = 0;
235 stack_region_t stack;
237 xbt_dynar_foreach(stacks_areas, cursor, stack){
238 if(block == stack->block)
245 static void match_equals(xbt_dynar_t list){
247 unsigned int cursor = 0;
248 heap_area_pair_t current_pair;
249 heap_area_t previous_area;
251 xbt_dynar_foreach(list, cursor, current_pair){
253 if(current_pair->fragment1 != -1){
255 if(equals_to1[current_pair->block1][current_pair->fragment1] != NULL){
256 previous_area = equals_to1[current_pair->block1][current_pair->fragment1];
257 heap_area_free(equals_to2[previous_area->block][previous_area->fragment]);
258 equals_to2[previous_area->block][previous_area->fragment] = NULL;
259 heap_area_free(previous_area);
261 if(equals_to2[current_pair->block2][current_pair->fragment2] != NULL){
262 previous_area = equals_to2[current_pair->block2][current_pair->fragment2];
263 heap_area_free(equals_to1[previous_area->block][previous_area->fragment]);
264 equals_to1[previous_area->block][previous_area->fragment] = NULL;
265 heap_area_free(previous_area);
268 equals_to1[current_pair->block1][current_pair->fragment1] = new_heap_area(current_pair->block2, current_pair->fragment2);
269 equals_to2[current_pair->block2][current_pair->fragment2] = new_heap_area(current_pair->block1, current_pair->fragment1);
273 if(equals_to1[current_pair->block1][0] != NULL){
274 previous_area = equals_to1[current_pair->block1][0];
275 heap_area_free(equals_to2[previous_area->block][0]);
276 equals_to2[previous_area->block][0] = NULL;
277 heap_area_free(previous_area);
279 if(equals_to2[current_pair->block2][0] != NULL){
280 previous_area = equals_to2[current_pair->block2][0];
281 heap_area_free(equals_to1[previous_area->block][0]);
282 equals_to1[previous_area->block][0] = NULL;
283 heap_area_free(previous_area);
286 equals_to1[current_pair->block1][0] = new_heap_area(current_pair->block2, current_pair->fragment2);
287 equals_to2[current_pair->block2][0] = new_heap_area(current_pair->block1, current_pair->fragment1);
294 static int equal_blocks(int b1, int b2){
296 if(equals_to1[b1][0]->block == b2 && equals_to2[b2][0]->block == b1)
302 static int equal_fragments(int b1, int f1, int b2, int f2){
304 if(equals_to1[b1][f1]->block == b2 && equals_to1[b1][f1]->fragment == f2 && equals_to2[b2][f2]->block == b1 && equals_to2[b2][f2]->fragment == f1)
310 int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t i1, xbt_dynar_t i2){
312 if((((struct mdesc *)heap1)->heaplimit != ((struct mdesc *)heap2)->heaplimit) || ((((struct mdesc *)heap1)->heapsize != ((struct mdesc *)heap2)->heapsize) ))
317 heaplimit = ((struct mdesc *)heap1)->heaplimit;
319 s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - getpagesize();
321 heapbase1 = (char *)heap1 + BLOCKSIZE;
322 heapbase2 = (char *)heap2 + BLOCKSIZE;
324 heapinfo1 = (malloc_info *)((char *)heap1 + ((uintptr_t)((char *)((struct mdesc *)heap1)->heapinfo - (char *)s_heap)));
325 heapinfo2 = (malloc_info *)((char *)heap2 + ((uintptr_t)((char *)((struct mdesc *)heap2)->heapinfo - (char *)s_heap)));
327 heapsize1 = heap1->heapsize;
328 heapsize2 = heap2->heapsize;
333 equals_to1 = malloc(heaplimit * sizeof(heap_area_t *));
334 types1 = malloc(heaplimit * sizeof(type_name *));
335 for(i=0; i<=heaplimit; i++){
336 equals_to1[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(heap_area_t));
337 types1[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(type_name));
338 for(j=0; j<MAX_FRAGMENT_PER_BLOCK; j++){
339 equals_to1[i][j] = NULL;
344 equals_to2 = malloc(heaplimit * sizeof(heap_area_t *));
345 types2 = malloc(heaplimit * sizeof(type_name *));
346 for(i=0; i<=heaplimit; i++){
347 equals_to2[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(heap_area_t));
348 types2[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(type_name));
349 for(j=0; j<MAX_FRAGMENT_PER_BLOCK; j++){
350 equals_to2[i][j] = NULL;
356 MC_ignore_global_variable("heaplimit");
357 MC_ignore_global_variable("s_heap");
358 MC_ignore_global_variable("heapbase1");
359 MC_ignore_global_variable("heapbase2");
360 MC_ignore_global_variable("heapinfo1");
361 MC_ignore_global_variable("heapinfo2");
362 MC_ignore_global_variable("heapsize1");
363 MC_ignore_global_variable("heapsize2");
364 MC_ignore_global_variable("to_ignore1");
365 MC_ignore_global_variable("to_ignore2");
366 MC_ignore_global_variable("equals_to1");
367 MC_ignore_global_variable("equals_to2");
368 MC_ignore_global_variable("types1");
369 MC_ignore_global_variable("types2");
376 void reset_heap_information(){
380 for(i=0; i<=heaplimit; i++){
381 for(j=0; j<MAX_FRAGMENT_PER_BLOCK;j++){
382 heap_area_free(equals_to1[i][j]);
383 equals_to1[i][j] = NULL;
384 heap_area_free(equals_to2[i][j]);
385 equals_to2[i][j] = NULL;
386 xbt_free(types1[i][j]);
388 xbt_free(types2[i][j]);
402 s_heap = NULL, heapbase1 = NULL, heapbase2 = NULL;
403 heapinfo1 = NULL, heapinfo2 = NULL;
404 heaplimit = 0, heapsize1 = 0, heapsize2 = 0;
405 to_ignore1 = NULL, to_ignore2 = NULL;
406 equals_to1 = NULL, equals_to2 = NULL;
407 types1 = NULL, types2 = NULL;
411 int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_types, xbt_dict_t other_types){
413 if(heap1 == NULL && heap2 == NULL){
414 XBT_DEBUG("Malloc descriptors null");
418 /* Start comparison */
419 size_t i1, i2, j1, j2, k;
420 void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2;
421 int nb_diff1 = 0, nb_diff2 = 0;
423 xbt_dynar_t previous = xbt_dynar_new(sizeof(heap_area_pair_t), heap_area_pair_free_voidp);
425 int equal, res_compare = 0;
427 /* Check busy blocks*/
431 while(i1 <= heaplimit){
433 if(heapinfo1[i1].type == -1){ /* Free block */
438 addr_block1 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
440 if(heapinfo1[i1].type == 0){ /* Large block */
442 if(is_stack(addr_block1)){
443 for(k=0; k < heapinfo1[i1].busy_block.size; k++)
444 equals_to1[i1+k][0] = new_heap_area(i1, -1);
445 for(k=0; k < heapinfo2[i1].busy_block.size; k++)
446 equals_to2[i1+k][0] = new_heap_area(i1, -1);
447 i1 += heapinfo1[i1].busy_block.size;
451 if(equals_to1[i1][0] != NULL){
460 /* Try first to associate to same block in the other heap */
461 if(heapinfo2[i1].type == heapinfo1[i1].type){
463 if(equals_to2[i1][0] == NULL){
465 addr_block2 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
467 res_compare = compare_heap_area(addr_block1, addr_block2, NULL, all_types, other_types, NULL, 0);
469 if(res_compare != 1){
470 for(k=1; k < heapinfo2[i1].busy_block.size; k++)
471 equals_to2[i1+k][0] = new_heap_area(i1, -1);
472 for(k=1; k < heapinfo1[i1].busy_block.size; k++)
473 equals_to1[i1+k][0] = new_heap_area(i1, -1);
475 i1 += heapinfo1[i1].busy_block.size;
478 xbt_dynar_reset(previous);
484 while(i2 <= heaplimit && !equal){
486 addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
493 if(heapinfo2[i2].type != 0){
498 if(equals_to2[i2][0] != NULL){
503 res_compare = compare_heap_area(addr_block1, addr_block2, NULL, all_types, other_types, NULL, 0);
505 if(res_compare != 1 ){
506 for(k=1; k < heapinfo2[i2].busy_block.size; k++)
507 equals_to2[i2+k][0] = new_heap_area(i1, -1);
508 for(k=1; k < heapinfo1[i1].busy_block.size; k++)
509 equals_to1[i1+k][0] = new_heap_area(i2, -1);
511 i1 += heapinfo1[i1].busy_block.size;
514 xbt_dynar_reset(previous);
521 XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1, heapinfo1[i1].busy_block.busy_size, addr_block1);
527 }else{ /* Fragmented block */
529 for(j1=0; j1 < (size_t) (BLOCKSIZE >> heapinfo1[i1].type); j1++){
531 if(heapinfo1[i1].busy_frag.frag_size[j1] == -1) /* Free fragment */
534 if(equals_to1[i1][j1] != NULL)
537 addr_frag1 = (void*) ((char *)addr_block1 + (j1 << heapinfo1[i1].type));
542 /* Try first to associate to same fragment in the other heap */
543 if(heapinfo2[i1].type == heapinfo1[i1].type){
545 if(equals_to2[i1][j1] == NULL){
547 addr_block2 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
548 addr_frag2 = (void*) ((char *)addr_block2 + (j1 << ((xbt_mheap_t)s_heap)->heapinfo[i1].type));
550 res_compare = compare_heap_area(addr_frag1, addr_frag2, NULL, all_types, other_types, NULL, 0);
555 xbt_dynar_reset(previous);
561 while(i2 <= heaplimit && !equal){
563 if(heapinfo2[i2].type <= 0){
568 for(j2=0; j2 < (size_t) (BLOCKSIZE >> heapinfo2[i2].type); j2++){
570 if(i2 == i1 && j2 == j1)
573 if(equals_to2[i2][j2] != NULL)
576 addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
577 addr_frag2 = (void*) ((char *)addr_block2 + (j2 <<((xbt_mheap_t)s_heap)->heapinfo[i2].type));
579 res_compare = compare_heap_area(addr_frag1, addr_frag2, NULL, all_types, other_types, NULL, 0);
581 if(res_compare != 1){
583 xbt_dynar_reset(previous);
587 xbt_dynar_reset(previous);
596 XBT_DEBUG("Block %zu, fragment %zu not found (size_used = %zd, address = %p)\n", i1, j1, heapinfo1[i1].busy_frag.frag_size[j1], addr_frag1);
611 /* All blocks/fragments are equal to another block/fragment ? */
613 void *real_addr_frag1 = NULL, *real_addr_block1 = NULL, *real_addr_block2 = NULL, *real_addr_frag2 = NULL;
616 if(heapinfo1[i].type == 0){
618 if(heapinfo1[i].busy_block.busy_size > 0){
619 if(equals_to1[i][0] == NULL){
620 if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
621 addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase1));
622 XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i, addr_block1, heapinfo1[i].busy_block.busy_size);
623 //mmalloc_backtrace_block_display((void*)heapinfo1, i);
630 if(heapinfo1[i].type > 0){
631 addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase1));
632 real_addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)((struct mdesc *)s_heap)->heapbase));
633 for(j=0; j < (size_t) (BLOCKSIZE >> heapinfo1[i].type); j++){
635 if(heapinfo1[i].busy_frag.frag_size[j] > 0){
636 if(equals_to1[i][j] == NULL){
637 if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
638 addr_frag1 = (void*) ((char *)addr_block1 + (j << heapinfo1[i].type));
639 real_addr_frag1 = (void*) ((char *)real_addr_block1 + (j << ((struct mdesc *)s_heap)->heapinfo[i].type));
640 XBT_DEBUG("Block %zu, Fragment %zu (%p - %p) not found (size used = %zd)", i, j, addr_frag1, real_addr_frag1, heapinfo1[i].busy_frag.frag_size[j]);
641 //mmalloc_backtrace_fragment_display((void*)heapinfo1, i, j);
653 XBT_DEBUG("Number of blocks/fragments not found in heap1 : %d", nb_diff1);
658 if(heapinfo2[i].type == 0){
660 if(heapinfo2[i].busy_block.busy_size > 0){
661 if(equals_to2[i][0] == NULL){
662 if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
663 addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase2));
664 XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i, addr_block2, heapinfo2[i].busy_block.busy_size);
665 //mmalloc_backtrace_block_display((void*)heapinfo2, i);
672 if(heapinfo2[i].type > 0){
673 addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase2));
674 real_addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)((struct mdesc *)s_heap)->heapbase));
675 for(j=0; j < (size_t) (BLOCKSIZE >> heapinfo2[i].type); j++){
677 if(heapinfo2[i].busy_frag.frag_size[j] > 0){
678 if(equals_to2[i][j] == NULL){
679 if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
680 addr_frag2 = (void*) ((char *)addr_block2 + (j << heapinfo2[i].type));
681 real_addr_frag2 = (void*) ((char *)real_addr_block2 + (j << ((struct mdesc *)s_heap)->heapinfo[i].type));
682 XBT_DEBUG( "Block %zu, Fragment %zu (%p - %p) not found (size used = %zd)", i, j, addr_frag2, real_addr_frag2, heapinfo2[i].busy_frag.frag_size[j]);
683 //mmalloc_backtrace_fragment_display((void*)heapinfo2, i, j);
695 XBT_DEBUG("Number of blocks/fragments not found in heap2 : %d", nb_diff2);
697 xbt_dynar_free(&previous);
698 real_addr_frag1 = NULL, real_addr_block1 = NULL, real_addr_block2 = NULL, real_addr_frag2 = NULL;
700 return ((nb_diff1 > 0) || (nb_diff2 > 0));
703 static int compare_heap_area_without_type(void *real_area1, void *real_area2, void *area1, void *area2, xbt_dynar_t previous, xbt_dict_t all_types, xbt_dict_t other_types, int size, int check_ignore){
706 void *addr_pointed1, *addr_pointed2;
707 int pointer_align, ignore1, ignore2, res_compare;
711 if(check_ignore > 0){
712 if((ignore1 = heap_comparison_ignore_size(to_ignore1, (char *)real_area1 + i)) != -1){
713 if((ignore2 = heap_comparison_ignore_size(to_ignore2, (char *)real_area2 + i)) == ignore1){
726 if(memcmp(((char *)area1) + i, ((char *)area2) + i, 1) != 0){
728 pointer_align = (i / sizeof(void*)) * sizeof(void*);
729 addr_pointed1 = *((void **)((char *)area1 + pointer_align));
730 addr_pointed2 = *((void **)((char *)area2 + pointer_align));
732 if(addr_pointed1 > maestro_stack_start && addr_pointed1 < maestro_stack_end && addr_pointed2 > maestro_stack_start && addr_pointed2 < maestro_stack_end){
733 i = pointer_align + sizeof(void *);
735 }else if((addr_pointed1 > s_heap) && ((char *)addr_pointed1 < (char *)s_heap + STD_HEAP_SIZE)
736 && (addr_pointed2 > s_heap) && ((char *)addr_pointed2 < (char *)s_heap + STD_HEAP_SIZE)){
737 res_compare = compare_heap_area(addr_pointed1, addr_pointed2, previous, all_types, other_types, NULL, 0);
738 if(res_compare == 1){
741 i = pointer_align + sizeof(void *);
758 static int compare_heap_area_with_type(void *real_area1, void *real_area2, void *area1, void *area2,
759 xbt_dynar_t previous, xbt_dict_t all_types, xbt_dict_t other_types, char *type_id,
760 int area_size, int check_ignore, int pointer_level){
762 if(is_stack(real_area1) && is_stack(real_area2))
765 size_t ignore1, ignore2;
767 if((check_ignore > 0) && ((ignore1 = heap_comparison_ignore_size(to_ignore1, real_area1)) > 0) && ((ignore2 = heap_comparison_ignore_size(to_ignore2, real_area2)) == ignore1)){
771 dw_type_t type = xbt_dict_get_or_null(all_types, type_id);
772 dw_type_t subtype, subsubtype;
773 int res, elm_size, i, switch_types = 0;
774 unsigned int cursor = 0;
776 void *addr_pointed1, *addr_pointed2;;
781 if(strcmp(type->name, "char") == 0){ /* String, hence random (arbitrary ?) size */
782 if(real_area1 == real_area2)
785 return (memcmp(area1, area2, area_size) != 0);
787 if(area_size != -1 && type->size != area_size)
790 return (memcmp(area1, area2, type->size) != 0);
794 case e_dw_enumeration_type:
795 if(area_size != -1 && type->size != area_size)
798 return (memcmp(area1, area2, type->size) != 0);
801 return compare_heap_area_with_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->dw_type_id, area_size, check_ignore, pointer_level);
803 case e_dw_const_type:
806 case e_dw_array_type:
807 subtype = xbt_dict_get_or_null(all_types, type->dw_type_id);
808 switch(subtype->type){
810 case e_dw_enumeration_type:
811 case e_dw_pointer_type:
812 case e_dw_structure_type:
813 case e_dw_union_type:
814 if(subtype->size == 0){ /*declaration of the type, need the complete description */
815 type_desc = get_type_description(all_types, subtype->name);
817 subtype = xbt_dict_get_or_null(all_types, type_desc);
819 subtype = xbt_dict_get_or_null(other_types, get_type_description(other_types, subtype->name));
823 elm_size = subtype->size;
826 case e_dw_volatile_type:
827 subsubtype = xbt_dict_get_or_null(all_types, subtype->dw_type_id);
828 if(subsubtype->size == 0){ /*declaration of the type, need the complete description */
829 type_desc = get_type_description(all_types, subsubtype->name);
831 subsubtype = xbt_dict_get_or_null(all_types, type_desc);
833 subsubtype = xbt_dict_get_or_null(other_types, get_type_description(other_types, subtype->name));
837 elm_size = subsubtype->size;
843 for(i=0; i<type->size; i++){
845 res = compare_heap_area_with_type((char *)real_area1 + (i*elm_size), (char *)real_area2 + (i*elm_size), (char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), previous, other_types, all_types, type->dw_type_id, type->size, check_ignore, pointer_level);
847 res = compare_heap_area_with_type((char *)real_area1 + (i*elm_size), (char *)real_area2 + (i*elm_size), (char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), previous, all_types, other_types, type->dw_type_id, type->size, check_ignore, pointer_level);
852 case e_dw_pointer_type:
853 if(type->dw_type_id && ((dw_type_t)xbt_dict_get_or_null(all_types, type->dw_type_id))->type == e_dw_subroutine_type){
854 addr_pointed1 = *((void **)(area1));
855 addr_pointed2 = *((void **)(area2));
856 return (addr_pointed1 != addr_pointed2);;
859 if(pointer_level > 1){ /* Array of pointers */
860 for(i=0; i<(area_size/sizeof(void *)); i++){
861 addr_pointed1 = *((void **)((char *)area1 + (i*sizeof(void *))));
862 addr_pointed2 = *((void **)((char *)area2 + (i*sizeof(void *))));
863 if(addr_pointed1 > s_heap && (char *)addr_pointed1 < (char*) s_heap + STD_HEAP_SIZE && addr_pointed2 > s_heap && (char *)addr_pointed2 < (char*) s_heap + STD_HEAP_SIZE)
864 res = compare_heap_area(addr_pointed1, addr_pointed2, previous, all_types, other_types, type->dw_type_id, pointer_level);
866 res = (addr_pointed1 != addr_pointed2);
871 addr_pointed1 = *((void **)(area1));
872 addr_pointed2 = *((void **)(area2));
873 if(addr_pointed1 > s_heap && (char *)addr_pointed1 < (char*) s_heap + STD_HEAP_SIZE && addr_pointed2 > s_heap && (char *)addr_pointed2 < (char*) s_heap + STD_HEAP_SIZE)
874 return compare_heap_area(addr_pointed1, addr_pointed2, previous, all_types, other_types, type->dw_type_id, pointer_level);
876 return (addr_pointed1 != addr_pointed2);
880 case e_dw_structure_type:
881 if(type->size == 0){ /*declaration of the structure, need the complete description */
882 type_desc = get_type_description(all_types, type->name);
884 type = xbt_dict_get_or_null(all_types, type_desc);
886 type = xbt_dict_get_or_null(other_types, get_type_description(other_types, type->name));
890 if(area_size != -1 && type->size != area_size){
891 if(area_size>type->size && area_size%type->size == 0){
892 for(i=0; i<(area_size/type->size); i++){
894 res = compare_heap_area_with_type((char *)real_area1 + (i*type->size), (char *)real_area2 + (i*type->size), (char *)area1 + (i*type->size), (char *)area2 + (i*type->size), previous, other_types, all_types, type_id, -1, check_ignore, 0);
896 res = compare_heap_area_with_type((char *)real_area1 + (i*type->size), (char *)real_area2 + (i*type->size), (char *)area1 + (i*type->size), (char *)area2 + (i*type->size), previous, all_types, other_types, type_id, -1, check_ignore, 0);
905 xbt_dynar_foreach(type->members, cursor, member){
907 res = compare_heap_area_with_type((char *)real_area1 + member->offset, (char *)real_area2 + member->offset, (char *)area1 + member->offset, (char *)area2 + member->offset, previous, other_types, all_types, member->dw_type_id, -1, check_ignore, 0);
909 res = compare_heap_area_with_type((char *)real_area1 + member->offset, (char *)real_area2 + member->offset, (char *)area1 + member->offset, (char *)area2 + member->offset, previous, all_types, other_types, member->dw_type_id, -1, check_ignore, 0);
916 case e_dw_union_type:
917 return compare_heap_area_without_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->size, check_ignore);
919 case e_dw_volatile_type:
920 return compare_heap_area_with_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->dw_type_id, area_size, check_ignore, pointer_level);
930 static char* get_offset_type(char* type_id, int offset, xbt_dict_t all_types, xbt_dict_t other_types, int area_size, int *switch_type){
931 dw_type_t type = xbt_dict_get_or_null(all_types, type_id);
933 type = xbt_dict_get_or_null(other_types, type_id);
938 case e_dw_structure_type :
939 if(type->size == 0){ /*declaration of the structure, need the complete description */
940 if(*switch_type == 0){
941 type_desc = get_type_description(all_types, type->name);
943 type = xbt_dict_get_or_null(all_types, type_desc);
945 type = xbt_dict_get_or_null(other_types, get_type_description(other_types, type->name));
949 type_desc = get_type_description(other_types, type->name);
951 type = xbt_dict_get_or_null(other_types, type_desc);
953 type = xbt_dict_get_or_null(all_types, get_type_description(other_types, type->name));
959 if(area_size != -1 && type->size != area_size){
960 if(area_size>type->size && area_size%type->size == 0)
965 unsigned int cursor = 0;
967 xbt_dynar_foreach(type->members, cursor, member){
968 if(member->offset == offset)
969 return member->dw_type_id;
975 /* FIXME : other cases ? */
981 int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t all_types, xbt_dict_t other_types, char *type_id, int pointer_level){
984 ssize_t block1, frag1, block2, frag2;
986 int check_ignore = 0;
988 void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2, *real_addr_block1, *real_addr_block2, *real_addr_frag1, *real_addr_frag2;
989 void *area1_to_compare, *area2_to_compare;
990 dw_type_t type = NULL;
993 int offset1 =0, offset2 = 0;
994 int new_size1 = -1, new_size2 = -1;
995 char *new_type_id1 = NULL, *new_type_id2 = NULL;
1000 if(previous == NULL){
1001 previous = xbt_dynar_new(sizeof(heap_area_pair_t), heap_area_pair_free_voidp);
1005 block1 = ((char*)area1 - (char*)((xbt_mheap_t)s_heap)->heapbase) / BLOCKSIZE + 1;
1006 block2 = ((char*)area2 - (char*)((xbt_mheap_t)s_heap)->heapbase) / BLOCKSIZE + 1;
1008 if(is_block_stack((int)block1) && is_block_stack((int)block2)){
1009 add_heap_area_pair(previous, block1, -1, block2, -1);
1011 match_equals(previous);
1012 xbt_dynar_free(&previous);
1017 if(((char *)area1 < (char*)((xbt_mheap_t)s_heap)->heapbase) || (block1 > heapsize1) || (block1 < 1) || ((char *)area2 < (char*)((xbt_mheap_t)s_heap)->heapbase) || (block2 > heapsize2) || (block2 < 1)){
1019 xbt_dynar_free(&previous);
1024 addr_block1 = ((void*) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE + (char*)heapbase1));
1025 addr_block2 = ((void*) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE + (char*)heapbase2));
1027 real_addr_block1 = ((void*) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
1028 real_addr_block2 = ((void*) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
1031 type = xbt_dict_get_or_null(all_types, type_id);
1032 if(type->size == 0){
1033 if(type->dw_type_id == NULL){
1034 type_desc = get_type_description(all_types, type->name);
1036 type = xbt_dict_get_or_null(all_types, type_desc);
1038 type = xbt_dict_get_or_null(other_types, get_type_description(other_types, type->name));
1040 type = xbt_dict_get_or_null(all_types, type->dw_type_id);
1043 if((type->type == e_dw_pointer_type) || ((type->type == e_dw_base_type) && (!strcmp(type->name, "char"))))
1046 type_size = type->size;
1049 if((heapinfo1[block1].type == -1) && (heapinfo2[block2].type == -1)){ /* Free block */
1052 match_equals(previous);
1053 xbt_dynar_free(&previous);
1057 }else if((heapinfo1[block1].type == 0) && (heapinfo2[block2].type == 0)){ /* Complete block */
1059 if(equals_to1[block1][0] != NULL && equals_to2[block2][0] != NULL){
1060 if(equal_blocks(block1, block2)){
1062 match_equals(previous);
1063 xbt_dynar_free(&previous);
1069 if(type_size != -1){
1070 if(type_size != heapinfo1[block1].busy_block.busy_size && type_size != heapinfo2[block2].busy_block.busy_size && !strcmp(type->name, "s_smx_context")){
1072 match_equals(previous);
1073 xbt_dynar_free(&previous);
1079 if(heapinfo1[block1].busy_block.size != heapinfo2[block2].busy_block.size){
1081 xbt_dynar_free(&previous);
1086 if(heapinfo1[block1].busy_block.busy_size != heapinfo2[block2].busy_block.busy_size){
1088 xbt_dynar_free(&previous);
1093 if(!add_heap_area_pair(previous, block1, -1, block2, -1)){
1095 match_equals(previous);
1096 xbt_dynar_free(&previous);
1101 size = heapinfo1[block1].busy_block.busy_size;
1103 if(type_id != NULL){
1104 xbt_free(types1[block1][0]);
1105 xbt_free(types2[block2][0]);
1106 types1[block1][0] = strdup(type_id);
1107 types2[block2][0] = strdup(type_id);
1112 match_equals(previous);
1113 xbt_dynar_free(&previous);
1121 area1_to_compare = addr_block1;
1122 area2_to_compare = addr_block2;
1124 if((heapinfo1[block1].busy_block.ignore > 0) && (heapinfo2[block2].busy_block.ignore == heapinfo1[block1].busy_block.ignore))
1125 check_ignore = heapinfo1[block1].busy_block.ignore;
1127 }else if((heapinfo1[block1].type > 0) && (heapinfo2[block2].type > 0)){ /* Fragmented block */
1129 frag1 = ((uintptr_t) (ADDR2UINT (area1) % (BLOCKSIZE))) >> heapinfo1[block1].type;
1130 frag2 = ((uintptr_t) (ADDR2UINT (area2) % (BLOCKSIZE))) >> heapinfo2[block2].type;
1132 addr_frag1 = (void*) ((char *)addr_block1 + (frag1 << heapinfo1[block1].type));
1133 addr_frag2 = (void*) ((char *)addr_block2 + (frag2 << heapinfo2[block2].type));
1135 real_addr_frag1 = (void*) ((char *)real_addr_block1 + (frag1 << ((xbt_mheap_t)s_heap)->heapinfo[block1].type));
1136 real_addr_frag2 = (void*) ((char *)real_addr_block2 + (frag2 << ((xbt_mheap_t)s_heap)->heapinfo[block2].type));
1138 if(type_size != -1){
1139 if(heapinfo1[block1].busy_frag.frag_size[frag1] == -1 || heapinfo2[block2].busy_frag.frag_size[frag2] == -1){
1141 match_equals(previous);
1142 xbt_dynar_free(&previous);
1146 if(type_size != heapinfo1[block1].busy_frag.frag_size[frag1] || type_size != heapinfo2[block2].busy_frag.frag_size[frag2]){
1148 match_equals(previous);
1149 xbt_dynar_free(&previous);
1155 if(equals_to1[block1][frag1] != NULL && equals_to2[block2][frag2] != NULL){
1156 if(equal_fragments(block1, frag1, block2, frag2)){
1158 match_equals(previous);
1159 xbt_dynar_free(&previous);
1165 if(heapinfo1[block1].busy_frag.frag_size[frag1] != heapinfo2[block2].busy_frag.frag_size[frag2]){
1166 if(type_size == -1){
1168 match_equals(previous);
1169 xbt_dynar_free(&previous);
1174 xbt_dynar_free(&previous);
1180 size = heapinfo1[block1].busy_frag.frag_size[frag1];
1182 if(type_id != NULL){
1183 xbt_free(types1[block1][frag1]);
1184 xbt_free(types2[block2][frag2]);
1185 types1[block1][frag1] = strdup(type_id);
1186 types2[block2][frag2] = strdup(type_id);
1189 if(real_addr_frag1 != area1 || real_addr_frag2 != area2){
1190 offset1 = (char *)area1 - (char *)real_addr_frag1;
1191 offset2 = (char *)area2 - (char *)real_addr_frag2;
1192 if(types1[block1][frag1] != NULL && types2[block2][frag2] != NULL){
1193 new_type_id1 = get_offset_type(types1[block1][frag1], offset1, all_types, other_types, size, &switch_type);
1194 new_type_id2 = get_offset_type(types2[block2][frag2], offset1, all_types, other_types, size, &switch_type);
1195 }else if(types1[block1][frag1] != NULL){
1196 new_type_id1 = get_offset_type(types1[block1][frag1], offset1, all_types, other_types, size, &switch_type);
1197 new_type_id2 = get_offset_type(types1[block1][frag1], offset2, all_types, other_types, size, &switch_type);
1198 }else if(types2[block2][frag2] != NULL){
1199 new_type_id1 = get_offset_type(types2[block2][frag2], offset1, all_types, other_types, size, &switch_type);
1200 new_type_id2 = get_offset_type(types2[block2][frag2], offset2, all_types, other_types, size, &switch_type);
1203 match_equals(previous);
1204 xbt_dynar_free(&previous);
1209 if(new_type_id1 != NULL && new_type_id2 != NULL && !strcmp(new_type_id1, new_type_id2)){
1211 type = xbt_dict_get_or_null(other_types, new_type_id1);
1212 while(type->size == 0 && type->dw_type_id != NULL)
1213 type = xbt_dict_get_or_null(other_types, type->dw_type_id);
1214 new_size1 = type->size;
1215 type = xbt_dict_get_or_null(other_types, new_type_id2);
1216 while(type->size == 0 && type->dw_type_id != NULL)
1217 type = xbt_dict_get_or_null(other_types, type->dw_type_id);
1218 new_size2 = type->size;
1220 type = xbt_dict_get_or_null(all_types, new_type_id1);
1221 while(type->size == 0 && type->dw_type_id != NULL)
1222 type = xbt_dict_get_or_null(all_types, type->dw_type_id);
1223 new_size1 = type->size;
1224 type = xbt_dict_get_or_null(all_types, new_type_id2);
1225 while(type->size == 0 && type->dw_type_id != NULL)
1226 type = xbt_dict_get_or_null(all_types, type->dw_type_id);
1227 new_size2 = type->size;
1231 match_equals(previous);
1232 xbt_dynar_free(&previous);
1238 area1_to_compare = (char *)addr_frag1 + offset1;
1239 area2_to_compare = (char *)addr_frag2 + offset2;
1241 if(new_size1 > 0 && new_size1 == new_size2){
1242 type_id = new_type_id1;
1246 if(offset1 == 0 && offset2 == 0){
1247 if(!add_heap_area_pair(previous, block1, frag1, block2, frag2)){
1249 match_equals(previous);
1250 xbt_dynar_free(&previous);
1258 match_equals(previous);
1259 xbt_dynar_free(&previous);
1264 if((heapinfo1[block1].busy_frag.ignore[frag1] > 0) && ( heapinfo2[block2].busy_frag.ignore[frag2] == heapinfo1[block1].busy_frag.ignore[frag1]))
1265 check_ignore = heapinfo1[block1].busy_frag.ignore[frag1];
1270 xbt_dynar_free(&previous);
1277 /* Start comparison*/
1278 if(type_id != NULL){
1280 res_compare = compare_heap_area_with_type(area1, area2, area1_to_compare, area2_to_compare, previous, other_types, all_types, type_id, size, check_ignore, pointer_level);
1282 res_compare = compare_heap_area_with_type(area1, area2, area1_to_compare, area2_to_compare, previous, all_types, other_types, type_id, size, check_ignore, pointer_level);
1283 if(res_compare == 1){
1285 xbt_dynar_free(&previous);
1290 res_compare = compare_heap_area_without_type(area1, area2, area1_to_compare, area2_to_compare, previous, other_types, all_types, size, check_ignore);
1292 res_compare = compare_heap_area_without_type(area1, area2, area1_to_compare, area2_to_compare, previous, all_types, other_types, size, check_ignore);
1293 if(res_compare == 1){
1295 xbt_dynar_free(&previous);
1301 match_equals(previous);
1302 xbt_dynar_free(&previous);
1308 /*********************************************** Miscellaneous ***************************************************/
1309 /****************************************************************************************************************/
1312 int get_pointed_area_size(void *area, int heap){
1315 malloc_info *heapinfo;
1318 heapinfo = heapinfo1;
1320 heapinfo = heapinfo2;
1322 block = ((char*)area - (char*)((xbt_mheap_t)s_heap)->heapbase) / BLOCKSIZE + 1;
1324 if(((char *)area < (char*)((xbt_mheap_t)s_heap)->heapbase) || (block > heapsize1) || (block < 1))
1327 if(heapinfo[block].type == -1){ /* Free block */
1329 }else if(heapinfo[block].type == 0){ /* Complete block */
1330 return (int)heapinfo[block].busy_block.busy_size;
1332 frag = ((uintptr_t) (ADDR2UINT (area) % (BLOCKSIZE))) >> heapinfo[block].type;
1333 return (int)heapinfo[block].busy_frag.frag_size[frag];
1338 char *get_type_description(xbt_dict_t types, char *type_name){
1340 xbt_dict_cursor_t dict_cursor;
1344 xbt_dict_foreach(types, dict_cursor, type_origin, type){
1345 if(type->name && (strcmp(type->name, type_name) == 0) && type->size > 0){
1346 xbt_dict_cursor_free(&dict_cursor);
1351 xbt_dict_cursor_free(&dict_cursor);
1357 #define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
1360 int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){
1362 if(heap1 == NULL && heap1 == NULL){
1363 XBT_DEBUG("Malloc descriptors null");
1367 if(heap1->heaplimit != heap2->heaplimit){
1368 XBT_DEBUG("Different limit of valid info table indices");
1372 /* Heap information */
1373 heaplimit = ((struct mdesc *)heap1)->heaplimit;
1375 s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - getpagesize();
1377 heapbase1 = (char *)heap1 + BLOCKSIZE;
1378 heapbase2 = (char *)heap2 + BLOCKSIZE;
1380 heapinfo1 = (malloc_info *)((char *)heap1 + ((uintptr_t)((char *)heap1->heapinfo - (char *)s_heap)));
1381 heapinfo2 = (malloc_info *)((char *)heap2 + ((uintptr_t)((char *)heap2->heapinfo - (char *)s_heap)));
1383 heapsize1 = heap1->heapsize;
1384 heapsize2 = heap2->heapsize;
1386 /* Start comparison */
1388 void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2;
1392 /* Check busy blocks*/
1396 while(i <= heaplimit){
1398 addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase1));
1399 addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase2));
1401 if(heapinfo1[i].type != heapinfo2[i].type){
1403 distance += BLOCKSIZE;
1404 XBT_DEBUG("Different type of blocks (%zu) : %d - %d -> distance = %d", i, heapinfo1[i].type, heapinfo2[i].type, distance);
1409 if(heapinfo1[i].type == -1){ /* Free block */
1414 if(heapinfo1[i].type == 0){ /* Large block */
1416 if(heapinfo1[i].busy_block.size != heapinfo2[i].busy_block.size){
1417 distance += BLOCKSIZE * max(heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size);
1418 i += max(heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size);
1419 XBT_DEBUG("Different larger of cluster at block %zu : %zu - %zu -> distance = %d", i, heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size, distance);
1423 /*if(heapinfo1[i].busy_block.busy_size != heapinfo2[i].busy_block.busy_size){
1424 distance += max(heapinfo1[i].busy_block.busy_size, heapinfo2[i].busy_block.busy_size);
1425 i += max(heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size);
1426 XBT_DEBUG("Different size used oin large cluster at block %zu : %zu - %zu -> distance = %d", i, heapinfo1[i].busy_block.busy_size, heapinfo2[i].busy_block.busy_size, distance);
1432 //while(k < (heapinfo1[i].busy_block.busy_size)){
1433 while(k < heapinfo1[i].busy_block.size * BLOCKSIZE){
1434 if(memcmp((char *)addr_block1 + k, (char *)addr_block2 + k, 1) != 0){
1442 }else { /* Fragmented block */
1444 for(j=0; j < (size_t) (BLOCKSIZE >> heapinfo1[i].type); j++){
1446 addr_frag1 = (void*) ((char *)addr_block1 + (j << heapinfo1[i].type));
1447 addr_frag2 = (void*) ((char *)addr_block2 + (j << heapinfo2[i].type));
1449 if(heapinfo1[i].busy_frag.frag_size[j] == 0 && heapinfo2[i].busy_frag.frag_size[j] == 0){
1454 /*if(heapinfo1[i].busy_frag.frag_size[j] != heapinfo2[i].busy_frag.frag_size[j]){
1455 distance += max(heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j]);
1456 XBT_DEBUG("Different size used in fragment %zu in block %zu : %d - %d -> distance = %d", j, i, heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j], distance);
1462 //while(k < max(heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j])){
1463 while(k < (BLOCKSIZE / (BLOCKSIZE >> heapinfo1[i].type))){
1464 if(memcmp((char *)addr_frag1 + k, (char *)addr_frag2 + k, 1) != 0){