1 /* mm_diff - Memory snapshooting and comparison */
3 /* Copyright (c) 2008-2013. 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"
14 #include "mc/mc_private.h"
16 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mm_diff, xbt,
17 "Logging specific to mm_diff in mmalloc");
19 xbt_dynar_t mc_heap_comparison_ignore;
20 xbt_dynar_t stacks_areas;
21 void *maestro_stack_start, *maestro_stack_end;
24 /********************************* Backtrace ***********************************/
25 /******************************************************************************/
27 static void mmalloc_backtrace_block_display(void* heapinfo, int block){
31 /* if (((malloc_info *)heapinfo)[block].busy_block.bt_size == 0) { */
32 /* fprintf(stderr, "No backtrace available for that block, sorry.\n"); */
36 /* memcpy(&e.bt,&(((malloc_info *)heapinfo)[block].busy_block.bt),sizeof(void*)*XBT_BACKTRACE_SIZE); */
37 /* e.used = ((malloc_info *)heapinfo)[block].busy_block.bt_size; */
39 /* xbt_ex_setup_backtrace(&e); */
40 /* if (e.used == 0) { */
41 /* fprintf(stderr, "(backtrace not set)\n"); */
42 /* } else if (e.bt_strings == NULL) { */
43 /* fprintf(stderr, "(backtrace not ready to be computed. %s)\n",xbt_binary_name?"Dunno why":"xbt_binary_name not setup yet"); */
47 /* fprintf(stderr, "Backtrace of where the block %d was malloced (%d frames):\n", block ,e.used); */
48 /* for (i = 0; i < e.used; i++) /\* no need to display "xbt_backtrace_display" *\/{ */
49 /* fprintf(stderr, "%d ---> %s\n",i, e.bt_strings[i] + 4); */
54 static void mmalloc_backtrace_fragment_display(void* heapinfo, int block, int frag){
58 /* memcpy(&e.bt,&(((malloc_info *)heapinfo)[block].busy_frag.bt[frag]),sizeof(void*)*XBT_BACKTRACE_SIZE); */
59 /* e.used = XBT_BACKTRACE_SIZE; */
61 /* xbt_ex_setup_backtrace(&e); */
62 /* if (e.used == 0) { */
63 /* fprintf(stderr, "(backtrace not set)\n"); */
64 /* } else if (e.bt_strings == NULL) { */
65 /* fprintf(stderr, "(backtrace not ready to be computed. %s)\n",xbt_binary_name?"Dunno why":"xbt_binary_name not setup yet"); */
69 /* fprintf(stderr, "Backtrace of where the fragment %d in block %d was malloced (%d frames):\n", frag, block ,e.used); */
70 /* for (i = 0; i < e.used; i++) /\* no need to display "xbt_backtrace_display" *\/{ */
71 /* fprintf(stderr, "%d ---> %s\n",i, e.bt_strings[i] + 4); */
77 static void mmalloc_backtrace_display(void *addr){
79 /* size_t block, frag_nb; */
82 /* xbt_mheap_t heap = __mmalloc_current_heap ?: (xbt_mheap_t) mmalloc_preinit(); */
84 /* block = (((char*) (addr) - (char*) heap -> heapbase) / BLOCKSIZE + 1); */
86 /* type = heap->heapinfo[block].type; */
89 /* case -1 : /\* Free block *\/ */
90 /* fprintf(stderr, "Asked to display the backtrace of a block that is free. I'm puzzled\n"); */
93 /* case 0: /\* Large block *\/ */
94 /* mmalloc_backtrace_block_display(heap->heapinfo, block); */
96 /* default: /\* Fragmented block *\/ */
97 /* frag_nb = RESIDUAL(addr, BLOCKSIZE) >> type; */
98 /* if(heap->heapinfo[block].busy_frag.frag_size[frag_nb] == -1){ */
99 /* fprintf(stderr , "Asked to display the backtrace of a fragment that is free. I'm puzzled\n"); */
102 /* mmalloc_backtrace_fragment_display(heap->heapinfo, block, frag_nb); */
108 static int compare_backtrace(int b1, int f1, int b2, int f2){
111 for(i=0; i< XBT_BACKTRACE_SIZE; i++){
112 if(heapinfo1[b1].busy_frag.bt[f1][i] != heapinfo2[b2].busy_frag.bt[f2][i]){
113 //mmalloc_backtrace_fragment_display((void*)heapinfo1, b1, f1);
114 //mmalloc_backtrace_fragment_display((void*)heapinfo2, b2, f2);
119 for(i=0; i< heapinfo1[b1].busy_block.bt_size; i++){
120 if(heapinfo1[b1].busy_block.bt[i] != heapinfo2[b2].busy_block.bt[i]){
121 //mmalloc_backtrace_block_display((void*)heapinfo1, b1);
122 //mmalloc_backtrace_block_display((void*)heapinfo2, b2);
131 /*********************************** Heap comparison ***********************************/
132 /***************************************************************************************/
134 typedef char* type_name;
136 __thread void *s_heap = NULL, *heapbase1 = NULL, *heapbase2 = NULL;
137 __thread malloc_info *heapinfo1 = NULL, *heapinfo2 = NULL;
138 __thread size_t heaplimit = 0, heapsize1 = 0, heapsize2 = 0;
139 __thread xbt_dynar_t to_ignore1 = NULL, to_ignore2 = NULL;
140 __thread heap_area_t **equals_to1, **equals_to2;
141 __thread type_name **types1, **types2;
143 /*********************************** Free functions ************************************/
145 static void heap_area_pair_free(heap_area_pair_t pair){
150 static void heap_area_pair_free_voidp(void *d){
151 heap_area_pair_free((heap_area_pair_t) * (void **) d);
154 static void heap_area_free(heap_area_t area){
159 /************************************************************************************/
161 static heap_area_t new_heap_area(int block, int fragment){
162 heap_area_t area = NULL;
163 area = xbt_new0(s_heap_area_t, 1);
165 area->fragment = fragment;
170 static int is_new_heap_area_pair(xbt_dynar_t list, int block1, int fragment1, int block2, int fragment2){
172 unsigned int cursor = 0;
173 heap_area_pair_t current_pair;
175 xbt_dynar_foreach(list, cursor, current_pair){
176 if(current_pair->block1 == block1 && current_pair->block2 == block2 && current_pair->fragment1 == fragment1 && current_pair->fragment2 == fragment2)
183 static int add_heap_area_pair(xbt_dynar_t list, int block1, int fragment1, int block2, int fragment2){
185 if(is_new_heap_area_pair(list, block1, fragment1, block2, fragment2)){
186 heap_area_pair_t pair = NULL;
187 pair = xbt_new0(s_heap_area_pair_t, 1);
188 pair->block1 = block1;
189 pair->fragment1 = fragment1;
190 pair->block2 = block2;
191 pair->fragment2 = fragment2;
193 xbt_dynar_push(list, &pair);
201 static ssize_t heap_comparison_ignore_size(xbt_dynar_t ignore_list, void *address){
203 unsigned int cursor = 0;
205 int end = xbt_dynar_length(ignore_list) - 1;
206 mc_heap_ignore_region_t region;
209 cursor = (start + end) / 2;
210 region = (mc_heap_ignore_region_t)xbt_dynar_get_as(ignore_list, cursor, mc_heap_ignore_region_t);
211 if(region->address == address)
213 if(region->address < address)
215 if(region->address > address)
222 static int is_stack(void *address){
223 unsigned int cursor = 0;
224 stack_region_t stack;
226 xbt_dynar_foreach(stacks_areas, cursor, stack){
227 if(address == stack->address)
234 static int is_block_stack(int block){
235 unsigned int cursor = 0;
236 stack_region_t stack;
238 xbt_dynar_foreach(stacks_areas, cursor, stack){
239 if(block == stack->block)
246 static void match_equals(xbt_dynar_t list){
248 unsigned int cursor = 0;
249 heap_area_pair_t current_pair;
250 heap_area_t previous_area;
252 xbt_dynar_foreach(list, cursor, current_pair){
254 if(current_pair->fragment1 != -1){
256 if(equals_to1[current_pair->block1][current_pair->fragment1] != NULL){
257 previous_area = equals_to1[current_pair->block1][current_pair->fragment1];
258 heap_area_free(equals_to2[previous_area->block][previous_area->fragment]);
259 equals_to2[previous_area->block][previous_area->fragment] = NULL;
260 heap_area_free(previous_area);
262 if(equals_to2[current_pair->block2][current_pair->fragment2] != NULL){
263 previous_area = equals_to2[current_pair->block2][current_pair->fragment2];
264 heap_area_free(equals_to1[previous_area->block][previous_area->fragment]);
265 equals_to1[previous_area->block][previous_area->fragment] = NULL;
266 heap_area_free(previous_area);
269 equals_to1[current_pair->block1][current_pair->fragment1] = new_heap_area(current_pair->block2, current_pair->fragment2);
270 equals_to2[current_pair->block2][current_pair->fragment2] = new_heap_area(current_pair->block1, current_pair->fragment1);
274 if(equals_to1[current_pair->block1][0] != NULL){
275 previous_area = equals_to1[current_pair->block1][0];
276 heap_area_free(equals_to2[previous_area->block][0]);
277 equals_to2[previous_area->block][0] = NULL;
278 heap_area_free(previous_area);
280 if(equals_to2[current_pair->block2][0] != NULL){
281 previous_area = equals_to2[current_pair->block2][0];
282 heap_area_free(equals_to1[previous_area->block][0]);
283 equals_to1[previous_area->block][0] = NULL;
284 heap_area_free(previous_area);
287 equals_to1[current_pair->block1][0] = new_heap_area(current_pair->block2, current_pair->fragment2);
288 equals_to2[current_pair->block2][0] = new_heap_area(current_pair->block1, current_pair->fragment1);
295 static int equal_blocks(int b1, int b2){
297 if(equals_to1[b1][0]->block == b2 && equals_to2[b2][0]->block == b1)
303 static int equal_fragments(int b1, int f1, int b2, int f2){
305 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)
311 int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t i1, xbt_dynar_t i2){
313 if((((struct mdesc *)heap1)->heaplimit != ((struct mdesc *)heap2)->heaplimit) || ((((struct mdesc *)heap1)->heapsize != ((struct mdesc *)heap2)->heapsize) ))
318 heaplimit = ((struct mdesc *)heap1)->heaplimit;
320 s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - getpagesize();
322 heapbase1 = (char *)heap1 + BLOCKSIZE;
323 heapbase2 = (char *)heap2 + BLOCKSIZE;
325 heapinfo1 = (malloc_info *)((char *)heap1 + ((uintptr_t)((char *)((struct mdesc *)heap1)->heapinfo - (char *)s_heap)));
326 heapinfo2 = (malloc_info *)((char *)heap2 + ((uintptr_t)((char *)((struct mdesc *)heap2)->heapinfo - (char *)s_heap)));
328 heapsize1 = heap1->heapsize;
329 heapsize2 = heap2->heapsize;
334 equals_to1 = malloc(heaplimit * sizeof(heap_area_t *));
335 types1 = malloc(heaplimit * sizeof(type_name *));
336 for(i=0; i<=heaplimit; i++){
337 equals_to1[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(heap_area_t));
338 types1[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(type_name));
339 for(j=0; j<MAX_FRAGMENT_PER_BLOCK; j++){
340 equals_to1[i][j] = NULL;
345 equals_to2 = malloc(heaplimit * sizeof(heap_area_t *));
346 types2 = malloc(heaplimit * sizeof(type_name *));
347 for(i=0; i<=heaplimit; i++){
348 equals_to2[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(heap_area_t));
349 types2[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(type_name));
350 for(j=0; j<MAX_FRAGMENT_PER_BLOCK; j++){
351 equals_to2[i][j] = NULL;
357 MC_ignore_global_variable("heaplimit");
358 MC_ignore_global_variable("s_heap");
359 MC_ignore_global_variable("heapbase1");
360 MC_ignore_global_variable("heapbase2");
361 MC_ignore_global_variable("heapinfo1");
362 MC_ignore_global_variable("heapinfo2");
363 MC_ignore_global_variable("heapsize1");
364 MC_ignore_global_variable("heapsize2");
365 MC_ignore_global_variable("to_ignore1");
366 MC_ignore_global_variable("to_ignore2");
367 MC_ignore_global_variable("equals_to1");
368 MC_ignore_global_variable("equals_to2");
369 MC_ignore_global_variable("types1");
370 MC_ignore_global_variable("types2");
377 void reset_heap_information(){
381 for(i=0; i<=heaplimit; i++){
382 for(j=0; j<MAX_FRAGMENT_PER_BLOCK;j++){
383 heap_area_free(equals_to1[i][j]);
384 equals_to1[i][j] = NULL;
385 heap_area_free(equals_to2[i][j]);
386 equals_to2[i][j] = NULL;
387 xbt_free(types1[i][j]);
389 xbt_free(types2[i][j]);
403 s_heap = NULL, heapbase1 = NULL, heapbase2 = NULL;
404 heapinfo1 = NULL, heapinfo2 = NULL;
405 heaplimit = 0, heapsize1 = 0, heapsize2 = 0;
406 to_ignore1 = NULL, to_ignore2 = NULL;
407 equals_to1 = NULL, equals_to2 = NULL;
408 types1 = NULL, types2 = NULL;
412 int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, mc_object_info_t info, mc_object_info_t other_info){
414 if(heap1 == NULL && heap2 == NULL){
415 XBT_DEBUG("Malloc descriptors null");
419 /* Start comparison */
420 size_t i1, i2, j1, j2, k;
421 void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2;
422 int nb_diff1 = 0, nb_diff2 = 0;
424 xbt_dynar_t previous = xbt_dynar_new(sizeof(heap_area_pair_t), heap_area_pair_free_voidp);
426 int equal, res_compare = 0;
428 /* Check busy blocks*/
432 while(i1 <= heaplimit){
434 if(heapinfo1[i1].type == -1){ /* Free block */
439 addr_block1 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
441 if(heapinfo1[i1].type == 0){ /* Large block */
443 if(is_stack(addr_block1)){
444 for(k=0; k < heapinfo1[i1].busy_block.size; k++)
445 equals_to1[i1+k][0] = new_heap_area(i1, -1);
446 for(k=0; k < heapinfo2[i1].busy_block.size; k++)
447 equals_to2[i1+k][0] = new_heap_area(i1, -1);
448 i1 += heapinfo1[i1].busy_block.size;
452 if(equals_to1[i1][0] != NULL){
461 /* Try first to associate to same block in the other heap */
462 if(heapinfo2[i1].type == heapinfo1[i1].type){
464 if(equals_to2[i1][0] == NULL){
466 addr_block2 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
468 res_compare = compare_heap_area(addr_block1, addr_block2, NULL, info, other_info, NULL, 0);
470 if(res_compare != 1){
471 for(k=1; k < heapinfo2[i1].busy_block.size; k++)
472 equals_to2[i1+k][0] = new_heap_area(i1, -1);
473 for(k=1; k < heapinfo1[i1].busy_block.size; k++)
474 equals_to1[i1+k][0] = new_heap_area(i1, -1);
476 i1 += heapinfo1[i1].busy_block.size;
479 xbt_dynar_reset(previous);
485 while(i2 <= heaplimit && !equal){
487 addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
494 if(heapinfo2[i2].type != 0){
499 if(equals_to2[i2][0] != NULL){
504 res_compare = compare_heap_area(addr_block1, addr_block2, NULL, info, other_info, NULL, 0);
506 if(res_compare != 1 ){
507 for(k=1; k < heapinfo2[i2].busy_block.size; k++)
508 equals_to2[i2+k][0] = new_heap_area(i1, -1);
509 for(k=1; k < heapinfo1[i1].busy_block.size; k++)
510 equals_to1[i1+k][0] = new_heap_area(i2, -1);
512 i1 += heapinfo1[i1].busy_block.size;
515 xbt_dynar_reset(previous);
522 XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1, heapinfo1[i1].busy_block.busy_size, addr_block1);
528 }else{ /* Fragmented block */
530 for(j1=0; j1 < (size_t) (BLOCKSIZE >> heapinfo1[i1].type); j1++){
532 if(heapinfo1[i1].busy_frag.frag_size[j1] == -1) /* Free fragment */
535 if(equals_to1[i1][j1] != NULL)
538 addr_frag1 = (void*) ((char *)addr_block1 + (j1 << heapinfo1[i1].type));
543 /* Try first to associate to same fragment in the other heap */
544 if(heapinfo2[i1].type == heapinfo1[i1].type){
546 if(equals_to2[i1][j1] == NULL){
548 addr_block2 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
549 addr_frag2 = (void*) ((char *)addr_block2 + (j1 << ((xbt_mheap_t)s_heap)->heapinfo[i1].type));
551 res_compare = compare_heap_area(addr_frag1, addr_frag2, NULL, info, other_info, NULL, 0);
556 xbt_dynar_reset(previous);
562 while(i2 <= heaplimit && !equal){
564 if(heapinfo2[i2].type <= 0){
569 for(j2=0; j2 < (size_t) (BLOCKSIZE >> heapinfo2[i2].type); j2++){
571 if(i2 == i1 && j2 == j1)
574 if(equals_to2[i2][j2] != NULL)
577 addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
578 addr_frag2 = (void*) ((char *)addr_block2 + (j2 <<((xbt_mheap_t)s_heap)->heapinfo[i2].type));
580 res_compare = compare_heap_area(addr_frag1, addr_frag2, NULL, info, other_info, NULL, 0);
582 if(res_compare != 1){
584 xbt_dynar_reset(previous);
588 xbt_dynar_reset(previous);
597 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);
612 /* All blocks/fragments are equal to another block/fragment ? */
614 void *real_addr_frag1 = NULL, *real_addr_block1 = NULL, *real_addr_block2 = NULL, *real_addr_frag2 = NULL;
617 if(heapinfo1[i].type == 0){
619 if(heapinfo1[i].busy_block.busy_size > 0){
620 if(equals_to1[i][0] == NULL){
621 if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
622 addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase1));
623 XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i, addr_block1, heapinfo1[i].busy_block.busy_size);
624 //mmalloc_backtrace_block_display((void*)heapinfo1, i);
631 if(heapinfo1[i].type > 0){
632 addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase1));
633 real_addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)((struct mdesc *)s_heap)->heapbase));
634 for(j=0; j < (size_t) (BLOCKSIZE >> heapinfo1[i].type); j++){
636 if(heapinfo1[i].busy_frag.frag_size[j] > 0){
637 if(equals_to1[i][j] == NULL){
638 if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
639 addr_frag1 = (void*) ((char *)addr_block1 + (j << heapinfo1[i].type));
640 real_addr_frag1 = (void*) ((char *)real_addr_block1 + (j << ((struct mdesc *)s_heap)->heapinfo[i].type));
641 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]);
642 //mmalloc_backtrace_fragment_display((void*)heapinfo1, i, j);
654 XBT_DEBUG("Number of blocks/fragments not found in heap1 : %d", nb_diff1);
659 if(heapinfo2[i].type == 0){
661 if(heapinfo2[i].busy_block.busy_size > 0){
662 if(equals_to2[i][0] == NULL){
663 if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
664 addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase2));
665 XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i, addr_block2, heapinfo2[i].busy_block.busy_size);
666 //mmalloc_backtrace_block_display((void*)heapinfo2, i);
673 if(heapinfo2[i].type > 0){
674 addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase2));
675 real_addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)((struct mdesc *)s_heap)->heapbase));
676 for(j=0; j < (size_t) (BLOCKSIZE >> heapinfo2[i].type); j++){
678 if(heapinfo2[i].busy_frag.frag_size[j] > 0){
679 if(equals_to2[i][j] == NULL){
680 if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
681 addr_frag2 = (void*) ((char *)addr_block2 + (j << heapinfo2[i].type));
682 real_addr_frag2 = (void*) ((char *)real_addr_block2 + (j << ((struct mdesc *)s_heap)->heapinfo[i].type));
683 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]);
684 //mmalloc_backtrace_fragment_display((void*)heapinfo2, i, j);
696 XBT_DEBUG("Number of blocks/fragments not found in heap2 : %d", nb_diff2);
698 xbt_dynar_free(&previous);
699 real_addr_frag1 = NULL, real_addr_block1 = NULL, real_addr_block2 = NULL, real_addr_frag2 = NULL;
701 return ((nb_diff1 > 0) || (nb_diff2 > 0));
704 static int compare_heap_area_without_type(void *real_area1, void *real_area2, void *area1, void *area2, xbt_dynar_t previous, mc_object_info_t info, mc_object_info_t other_info, int size, int check_ignore){
707 void *addr_pointed1, *addr_pointed2;
708 int pointer_align, res_compare;
709 ssize_t ignore1, ignore2;
713 if(check_ignore > 0){
714 if((ignore1 = heap_comparison_ignore_size(to_ignore1, (char *)real_area1 + i)) != -1){
715 if((ignore2 = heap_comparison_ignore_size(to_ignore2, (char *)real_area2 + i)) == ignore1){
728 if(memcmp(((char *)area1) + i, ((char *)area2) + i, 1) != 0){
730 pointer_align = (i / sizeof(void*)) * sizeof(void*);
731 addr_pointed1 = *((void **)((char *)area1 + pointer_align));
732 addr_pointed2 = *((void **)((char *)area2 + pointer_align));
734 if(addr_pointed1 > maestro_stack_start && addr_pointed1 < maestro_stack_end && addr_pointed2 > maestro_stack_start && addr_pointed2 < maestro_stack_end){
735 i = pointer_align + sizeof(void *);
737 }else if((addr_pointed1 > s_heap) && ((char *)addr_pointed1 < (char *)s_heap + STD_HEAP_SIZE)
738 && (addr_pointed2 > s_heap) && ((char *)addr_pointed2 < (char *)s_heap + STD_HEAP_SIZE)){
739 res_compare = compare_heap_area(addr_pointed1, addr_pointed2, previous, info, other_info, NULL, 0);
740 if(res_compare == 1){
743 i = pointer_align + sizeof(void *);
759 // area_size is either a byte_size or an elements_count?&
760 static int compare_heap_area_with_type(void *real_area1, void *real_area2, void *area1, void *area2,
761 xbt_dynar_t previous, mc_object_info_t info, mc_object_info_t other_info, char *type_id,
762 int area_size, int check_ignore, int pointer_level){
764 if(is_stack(real_area1) && is_stack(real_area2))
767 ssize_t ignore1, ignore2;
769 if((check_ignore > 0) && ((ignore1 = heap_comparison_ignore_size(to_ignore1, real_area1)) > 0) && ((ignore2 = heap_comparison_ignore_size(to_ignore2, real_area2)) == ignore1)){
773 dw_type_t type = xbt_dict_get_or_null(info->types, type_id);
774 dw_type_t subtype, subsubtype;
775 int res, elm_size, i, switch_types = 0;
776 unsigned int cursor = 0;
778 void *addr_pointed1, *addr_pointed2;;
781 case DW_TAG_base_type:
782 if(type->name!=NULL && strcmp(type->name, "char") == 0){ /* String, hence random (arbitrary ?) size */
783 if(real_area1 == real_area2)
786 return (memcmp(area1, area2, area_size) != 0);
788 if(area_size != -1 && type->byte_size != area_size)
791 return (memcmp(area1, area2, type->byte_size) != 0);
795 case DW_TAG_enumeration_type:
796 if(area_size != -1 && type->byte_size != area_size)
799 return (memcmp(area1, area2, type->byte_size) != 0);
802 case DW_TAG_const_type:
803 case DW_TAG_volatile_type:
804 return compare_heap_area_with_type(real_area1, real_area2, area1, area2, previous, info, other_info, type->dw_type_id, area_size, check_ignore, pointer_level);
806 case DW_TAG_array_type:
807 subtype = xbt_dict_get_or_null(info->types, type->dw_type_id);
808 switch(subtype->type){
809 case DW_TAG_base_type:
810 case DW_TAG_enumeration_type:
811 case DW_TAG_pointer_type:
812 case DW_TAG_structure_type:
813 case DW_TAG_union_type:
814 if(subtype->byte_size == 0){ /*declaration of the type, need the complete description */
815 subtype = xbt_dict_get_or_null(other_info->types_by_name, subtype->name);
818 elm_size = subtype->byte_size;
820 // TODO, just remove the type indirection?
821 case DW_TAG_const_type:
823 case DW_TAG_volatile_type:
824 subsubtype = subtype->subtype;
825 if(subsubtype->byte_size == 0){ /*declaration of the type, need the complete description */
826 subsubtype = xbt_dict_get_or_null(other_info->types_by_name, subtype->name);
829 elm_size = subsubtype->byte_size;
835 for(i=0; i<type->element_count; i++){
836 // TODO, add support for variable stride (DW_AT_byte_stride)
838 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_info, info, type->dw_type_id, subtype->byte_size, check_ignore, pointer_level);
840 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, info, other_info, type->dw_type_id, subtype->byte_size, check_ignore, pointer_level);
845 case DW_TAG_pointer_type:
846 if(type->dw_type_id && ((dw_type_t)xbt_dict_get_or_null(info->types, type->dw_type_id))->type == DW_TAG_subroutine_type){
847 addr_pointed1 = *((void **)(area1));
848 addr_pointed2 = *((void **)(area2));
849 return (addr_pointed1 != addr_pointed2);;
852 if(pointer_level > 1){ /* Array of pointers */
853 for(i=0; i<(area_size/sizeof(void *)); i++){
854 addr_pointed1 = *((void **)((char *)area1 + (i*sizeof(void *))));
855 addr_pointed2 = *((void **)((char *)area2 + (i*sizeof(void *))));
856 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)
857 res = compare_heap_area(addr_pointed1, addr_pointed2, previous, info, other_info, type->dw_type_id, pointer_level);
859 res = (addr_pointed1 != addr_pointed2);
864 addr_pointed1 = *((void **)(area1));
865 addr_pointed2 = *((void **)(area2));
866 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)
867 return compare_heap_area(addr_pointed1, addr_pointed2, previous, info, other_info, type->dw_type_id, pointer_level);
869 return (addr_pointed1 != addr_pointed2);
873 case DW_TAG_structure_type:
874 if(type->byte_size == 0){ /*declaration of the structure, need the complete description */
875 dw_type_t full_type = xbt_dict_get_or_null(info->types_by_name, type->name);
879 type = xbt_dict_get_or_null(other_info->types_by_name, type->name);
883 if(area_size != -1 && type->byte_size != area_size){
884 if(area_size>type->byte_size && area_size%type->byte_size == 0){
885 for(i=0; i<(area_size/type->byte_size); i++){
887 res = compare_heap_area_with_type((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), previous, other_info, info, type_id, -1, check_ignore, 0);
889 res = compare_heap_area_with_type((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), previous, info, other_info, type_id, -1, check_ignore, 0);
898 xbt_dynar_foreach(type->members, cursor, member){
900 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_info, info, member->dw_type_id, -1, check_ignore, 0);
902 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, info, other_info, member->dw_type_id, -1, check_ignore, 0);
909 case DW_TAG_union_type:
910 return compare_heap_area_without_type(real_area1, real_area2, area1, area2, previous, info, other_info, type->byte_size, check_ignore);
920 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){
921 dw_type_t type = xbt_dict_get_or_null(info->types, type_id);
923 type = xbt_dict_get_or_null(other_info->types, type_id);
927 case DW_TAG_structure_type :
928 if(type->byte_size == 0){ /*declaration of the structure, need the complete description */
929 if(*switch_type == 0){
930 dw_type_t full_type = xbt_dict_get_or_null(info->types_by_name, type->name);
934 type = xbt_dict_get_or_null(other_info->types_by_name, type->name);
938 dw_type_t full_type = xbt_dict_get_or_null(other_info->types_by_name, type->name);
942 type = xbt_dict_get_or_null(info->types_by_name, type->name);
948 if(area_size != -1 && type->byte_size != area_size){
949 if(area_size>type->byte_size && area_size%type->byte_size == 0)
954 unsigned int cursor = 0;
956 xbt_dynar_foreach(type->members, cursor, member){
957 if(member->offset == offset)
958 return member->dw_type_id;
964 /* FIXME : other cases ? */
970 int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, mc_object_info_t info, mc_object_info_t other_info, char *type_id, int pointer_level){
973 ssize_t block1, frag1, block2, frag2;
975 int check_ignore = 0;
977 void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2, *real_addr_block1, *real_addr_block2, *real_addr_frag1, *real_addr_frag2;
978 void *area1_to_compare, *area2_to_compare;
979 dw_type_t type = NULL;
981 int offset1 =0, offset2 = 0;
982 int new_size1 = -1, new_size2 = -1;
983 char *new_type_id1 = NULL, *new_type_id2 = NULL;
988 if(previous == NULL){
989 previous = xbt_dynar_new(sizeof(heap_area_pair_t), heap_area_pair_free_voidp);
993 block1 = ((char*)area1 - (char*)((xbt_mheap_t)s_heap)->heapbase) / BLOCKSIZE + 1;
994 block2 = ((char*)area2 - (char*)((xbt_mheap_t)s_heap)->heapbase) / BLOCKSIZE + 1;
996 if(is_block_stack((int)block1) && is_block_stack((int)block2)){
997 add_heap_area_pair(previous, block1, -1, block2, -1);
999 match_equals(previous);
1000 xbt_dynar_free(&previous);
1005 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)){
1007 xbt_dynar_free(&previous);
1012 addr_block1 = ((void*) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE + (char*)heapbase1));
1013 addr_block2 = ((void*) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE + (char*)heapbase2));
1015 real_addr_block1 = ((void*) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
1016 real_addr_block2 = ((void*) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
1019 type = xbt_dict_get_or_null(info->types, type_id);
1020 if(type->byte_size == 0){
1021 if(type->subtype == NULL){
1022 dw_type_t full_type = xbt_dict_get_or_null(info->types_by_name, type->name);
1026 type = xbt_dict_get_or_null(other_info->types_by_name, type->name);
1028 type = type->subtype;
1031 if((type->byte_size == DW_TAG_pointer_type) || ((type->type == DW_TAG_base_type) && type->name!=NULL && (!strcmp(type->name, "char"))))
1034 type_size = type->byte_size;
1037 if((heapinfo1[block1].type == -1) && (heapinfo2[block2].type == -1)){ /* Free block */
1040 match_equals(previous);
1041 xbt_dynar_free(&previous);
1045 }else if((heapinfo1[block1].type == 0) && (heapinfo2[block2].type == 0)){ /* Complete block */
1047 if(equals_to1[block1][0] != NULL && equals_to2[block2][0] != NULL){
1048 if(equal_blocks(block1, block2)){
1050 match_equals(previous);
1051 xbt_dynar_free(&previous);
1057 if(type_size != -1){
1058 if(type_size != heapinfo1[block1].busy_block.busy_size && type_size != heapinfo2[block2].busy_block.busy_size && type->name!=NULL && !strcmp(type->name, "s_smx_context")){
1060 match_equals(previous);
1061 xbt_dynar_free(&previous);
1067 if(heapinfo1[block1].busy_block.size != heapinfo2[block2].busy_block.size){
1069 xbt_dynar_free(&previous);
1074 if(heapinfo1[block1].busy_block.busy_size != heapinfo2[block2].busy_block.busy_size){
1076 xbt_dynar_free(&previous);
1081 if(!add_heap_area_pair(previous, block1, -1, block2, -1)){
1083 match_equals(previous);
1084 xbt_dynar_free(&previous);
1089 size = heapinfo1[block1].busy_block.busy_size;
1091 if(type_id != NULL){
1092 xbt_free(types1[block1][0]);
1093 xbt_free(types2[block2][0]);
1094 types1[block1][0] = strdup(type_id);
1095 types2[block2][0] = strdup(type_id);
1100 match_equals(previous);
1101 xbt_dynar_free(&previous);
1109 area1_to_compare = addr_block1;
1110 area2_to_compare = addr_block2;
1112 if((heapinfo1[block1].busy_block.ignore > 0) && (heapinfo2[block2].busy_block.ignore == heapinfo1[block1].busy_block.ignore))
1113 check_ignore = heapinfo1[block1].busy_block.ignore;
1115 }else if((heapinfo1[block1].type > 0) && (heapinfo2[block2].type > 0)){ /* Fragmented block */
1117 frag1 = ((uintptr_t) (ADDR2UINT (area1) % (BLOCKSIZE))) >> heapinfo1[block1].type;
1118 frag2 = ((uintptr_t) (ADDR2UINT (area2) % (BLOCKSIZE))) >> heapinfo2[block2].type;
1120 addr_frag1 = (void*) ((char *)addr_block1 + (frag1 << heapinfo1[block1].type));
1121 addr_frag2 = (void*) ((char *)addr_block2 + (frag2 << heapinfo2[block2].type));
1123 real_addr_frag1 = (void*) ((char *)real_addr_block1 + (frag1 << ((xbt_mheap_t)s_heap)->heapinfo[block1].type));
1124 real_addr_frag2 = (void*) ((char *)real_addr_block2 + (frag2 << ((xbt_mheap_t)s_heap)->heapinfo[block2].type));
1126 if(type_size != -1){
1127 if(heapinfo1[block1].busy_frag.frag_size[frag1] == -1 || heapinfo2[block2].busy_frag.frag_size[frag2] == -1){
1129 match_equals(previous);
1130 xbt_dynar_free(&previous);
1134 if(type_size != heapinfo1[block1].busy_frag.frag_size[frag1] || type_size != heapinfo2[block2].busy_frag.frag_size[frag2]){
1136 match_equals(previous);
1137 xbt_dynar_free(&previous);
1143 if(equals_to1[block1][frag1] != NULL && equals_to2[block2][frag2] != NULL){
1144 if(equal_fragments(block1, frag1, block2, frag2)){
1146 match_equals(previous);
1147 xbt_dynar_free(&previous);
1153 if(heapinfo1[block1].busy_frag.frag_size[frag1] != heapinfo2[block2].busy_frag.frag_size[frag2]){
1154 if(type_size == -1){
1156 match_equals(previous);
1157 xbt_dynar_free(&previous);
1162 xbt_dynar_free(&previous);
1168 size = heapinfo1[block1].busy_frag.frag_size[frag1];
1170 if(type_id != NULL){
1171 xbt_free(types1[block1][frag1]);
1172 xbt_free(types2[block2][frag2]);
1173 types1[block1][frag1] = strdup(type_id);
1174 types2[block2][frag2] = strdup(type_id);
1177 if(real_addr_frag1 != area1 || real_addr_frag2 != area2){
1178 offset1 = (char *)area1 - (char *)real_addr_frag1;
1179 offset2 = (char *)area2 - (char *)real_addr_frag2;
1180 if(types1[block1][frag1] != NULL && types2[block2][frag2] != NULL){
1181 new_type_id1 = get_offset_type(types1[block1][frag1], offset1, info, other_info, size, &switch_type);
1182 new_type_id2 = get_offset_type(types2[block2][frag2], offset1, info, other_info, size, &switch_type);
1183 }else if(types1[block1][frag1] != NULL){
1184 new_type_id1 = get_offset_type(types1[block1][frag1], offset1, info, other_info, size, &switch_type);
1185 new_type_id2 = get_offset_type(types1[block1][frag1], offset2, info, other_info, size, &switch_type);
1186 }else if(types2[block2][frag2] != NULL){
1187 new_type_id1 = get_offset_type(types2[block2][frag2], offset1, info, other_info, size, &switch_type);
1188 new_type_id2 = get_offset_type(types2[block2][frag2], offset2, info, other_info, size, &switch_type);
1191 match_equals(previous);
1192 xbt_dynar_free(&previous);
1197 if(new_type_id1 != NULL && new_type_id2 != NULL && !strcmp(new_type_id1, new_type_id2)){
1199 type = xbt_dict_get_or_null(other_info->types, new_type_id1);
1200 while(type->byte_size == 0 && type->dw_type_id != NULL)
1201 type = xbt_dict_get_or_null(other_info->types, type->dw_type_id);
1202 new_size1 = type->byte_size;
1203 type = xbt_dict_get_or_null(other_info->types, new_type_id2);
1204 while(type->byte_size == 0 && type->dw_type_id != NULL)
1205 type = xbt_dict_get_or_null(other_info->types, type->dw_type_id);
1206 new_size2 = type->byte_size;
1208 type = xbt_dict_get_or_null(info->types, new_type_id1);
1209 while(type->byte_size == 0 && type->dw_type_id != NULL)
1210 type = xbt_dict_get_or_null(info->types, type->dw_type_id);
1211 new_size1 = type->byte_size;
1212 type = xbt_dict_get_or_null(info->types, new_type_id2);
1213 while(type->byte_size == 0 && type->dw_type_id != NULL)
1214 type = xbt_dict_get_or_null(info->types, type->dw_type_id);
1215 new_size2 = type->byte_size;
1219 match_equals(previous);
1220 xbt_dynar_free(&previous);
1226 area1_to_compare = (char *)addr_frag1 + offset1;
1227 area2_to_compare = (char *)addr_frag2 + offset2;
1229 if(new_size1 > 0 && new_size1 == new_size2){
1230 type_id = new_type_id1;
1234 if(offset1 == 0 && offset2 == 0){
1235 if(!add_heap_area_pair(previous, block1, frag1, block2, frag2)){
1237 match_equals(previous);
1238 xbt_dynar_free(&previous);
1246 match_equals(previous);
1247 xbt_dynar_free(&previous);
1252 if((heapinfo1[block1].busy_frag.ignore[frag1] > 0) && ( heapinfo2[block2].busy_frag.ignore[frag2] == heapinfo1[block1].busy_frag.ignore[frag1]))
1253 check_ignore = heapinfo1[block1].busy_frag.ignore[frag1];
1258 xbt_dynar_free(&previous);
1265 /* Start comparison*/
1266 if(type_id != NULL){
1268 res_compare = compare_heap_area_with_type(area1, area2, area1_to_compare, area2_to_compare, previous, other_info, info, type_id, size, check_ignore, pointer_level);
1270 res_compare = compare_heap_area_with_type(area1, area2, area1_to_compare, area2_to_compare, previous, info, other_info, type_id, size, check_ignore, pointer_level);
1271 if(res_compare == 1){
1273 xbt_dynar_free(&previous);
1278 res_compare = compare_heap_area_without_type(area1, area2, area1_to_compare, area2_to_compare, previous, other_info, info, size, check_ignore);
1280 res_compare = compare_heap_area_without_type(area1, area2, area1_to_compare, area2_to_compare, previous, info, other_info, size, check_ignore);
1281 if(res_compare == 1){
1283 xbt_dynar_free(&previous);
1289 match_equals(previous);
1290 xbt_dynar_free(&previous);
1296 /*********************************************** Miscellaneous ***************************************************/
1297 /****************************************************************************************************************/
1300 int get_pointed_area_size(void *area, int heap){
1303 malloc_info *heapinfo;
1306 heapinfo = heapinfo1;
1308 heapinfo = heapinfo2;
1310 block = ((char*)area - (char*)((xbt_mheap_t)s_heap)->heapbase) / BLOCKSIZE + 1;
1312 if(((char *)area < (char*)((xbt_mheap_t)s_heap)->heapbase) || (block > heapsize1) || (block < 1))
1315 if(heapinfo[block].type == -1){ /* Free block */
1317 }else if(heapinfo[block].type == 0){ /* Complete block */
1318 return (int)heapinfo[block].busy_block.busy_size;
1320 frag = ((uintptr_t) (ADDR2UINT (area) % (BLOCKSIZE))) >> heapinfo[block].type;
1321 return (int)heapinfo[block].busy_frag.frag_size[frag];
1326 char *get_type_description(mc_object_info_t info, char *type_name){
1328 xbt_dict_cursor_t dict_cursor;
1332 xbt_dict_foreach(info->types, dict_cursor, type_origin, type){
1333 if(type->name && (strcmp(type->name, type_name) == 0) && type->byte_size > 0){
1334 xbt_dict_cursor_free(&dict_cursor);
1339 xbt_dict_cursor_free(&dict_cursor);
1345 #define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
1348 int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){
1350 if(heap1 == NULL && heap1 == NULL){
1351 XBT_DEBUG("Malloc descriptors null");
1355 if(heap1->heaplimit != heap2->heaplimit){
1356 XBT_DEBUG("Different limit of valid info table indices");
1360 /* Heap information */
1361 heaplimit = ((struct mdesc *)heap1)->heaplimit;
1363 s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - getpagesize();
1365 heapbase1 = (char *)heap1 + BLOCKSIZE;
1366 heapbase2 = (char *)heap2 + BLOCKSIZE;
1368 heapinfo1 = (malloc_info *)((char *)heap1 + ((uintptr_t)((char *)heap1->heapinfo - (char *)s_heap)));
1369 heapinfo2 = (malloc_info *)((char *)heap2 + ((uintptr_t)((char *)heap2->heapinfo - (char *)s_heap)));
1371 heapsize1 = heap1->heapsize;
1372 heapsize2 = heap2->heapsize;
1374 /* Start comparison */
1376 void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2;
1380 /* Check busy blocks*/
1384 while(i <= heaplimit){
1386 addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase1));
1387 addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase2));
1389 if(heapinfo1[i].type != heapinfo2[i].type){
1391 distance += BLOCKSIZE;
1392 XBT_DEBUG("Different type of blocks (%zu) : %d - %d -> distance = %d", i, heapinfo1[i].type, heapinfo2[i].type, distance);
1397 if(heapinfo1[i].type == -1){ /* Free block */
1402 if(heapinfo1[i].type == 0){ /* Large block */
1404 if(heapinfo1[i].busy_block.size != heapinfo2[i].busy_block.size){
1405 distance += BLOCKSIZE * max(heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size);
1406 i += max(heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size);
1407 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);
1411 /*if(heapinfo1[i].busy_block.busy_size != heapinfo2[i].busy_block.busy_size){
1412 distance += max(heapinfo1[i].busy_block.busy_size, heapinfo2[i].busy_block.busy_size);
1413 i += max(heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size);
1414 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);
1420 //while(k < (heapinfo1[i].busy_block.busy_size)){
1421 while(k < heapinfo1[i].busy_block.size * BLOCKSIZE){
1422 if(memcmp((char *)addr_block1 + k, (char *)addr_block2 + k, 1) != 0){
1430 }else { /* Fragmented block */
1432 for(j=0; j < (size_t) (BLOCKSIZE >> heapinfo1[i].type); j++){
1434 addr_frag1 = (void*) ((char *)addr_block1 + (j << heapinfo1[i].type));
1435 addr_frag2 = (void*) ((char *)addr_block2 + (j << heapinfo2[i].type));
1437 if(heapinfo1[i].busy_frag.frag_size[j] == 0 && heapinfo2[i].busy_frag.frag_size[j] == 0){
1442 /*if(heapinfo1[i].busy_frag.frag_size[j] != heapinfo2[i].busy_frag.frag_size[j]){
1443 distance += max(heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j]);
1444 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);
1450 //while(k < max(heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j])){
1451 while(k < (BLOCKSIZE / (BLOCKSIZE >> heapinfo1[i].type))){
1452 if(memcmp((char *)addr_frag1 + k, (char *)addr_frag2 + k, 1) != 0){