1 /* mc_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"
14 #include "mc/mc_private.h"
16 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_diff, xbt,
17 "Logging specific to mc_diff in mc");
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)
32 /* if (((malloc_info *)heapinfo)[block].busy_block.bt_size == 0) { */
33 /* fprintf(stderr, "No backtrace available for that block, sorry.\n"); */
37 /* memcpy(&e.bt,&(((malloc_info *)heapinfo)[block].busy_block.bt),sizeof(void*)*XBT_BACKTRACE_SIZE); */
38 /* e.used = ((malloc_info *)heapinfo)[block].busy_block.bt_size; */
40 /* xbt_ex_setup_backtrace(&e); */
41 /* if (e.used == 0) { */
42 /* fprintf(stderr, "(backtrace not set)\n"); */
43 /* } else if (e.bt_strings == NULL) { */
44 /* fprintf(stderr, "(backtrace not ready to be computed. %s)\n",xbt_binary_name?"Dunno why":"xbt_binary_name not setup yet"); */
48 /* fprintf(stderr, "Backtrace of where the block %d was malloced (%d frames):\n", block ,e.used); */
49 /* for (i = 0; i < e.used; i++) /\* no need to display "xbt_backtrace_display" *\/{ */
50 /* fprintf(stderr, "%d ---> %s\n",i, e.bt_strings[i] + 4); */
55 static void mmalloc_backtrace_fragment_display(void *heapinfo, int block,
61 /* memcpy(&e.bt,&(((malloc_info *)heapinfo)[block].busy_frag.bt[frag]),sizeof(void*)*XBT_BACKTRACE_SIZE); */
62 /* e.used = XBT_BACKTRACE_SIZE; */
64 /* xbt_ex_setup_backtrace(&e); */
65 /* if (e.used == 0) { */
66 /* fprintf(stderr, "(backtrace not set)\n"); */
67 /* } else if (e.bt_strings == NULL) { */
68 /* fprintf(stderr, "(backtrace not ready to be computed. %s)\n",xbt_binary_name?"Dunno why":"xbt_binary_name not setup yet"); */
72 /* fprintf(stderr, "Backtrace of where the fragment %d in block %d was malloced (%d frames):\n", frag, block ,e.used); */
73 /* for (i = 0; i < e.used; i++) /\* no need to display "xbt_backtrace_display" *\/{ */
74 /* fprintf(stderr, "%d ---> %s\n",i, e.bt_strings[i] + 4); */
80 static void mmalloc_backtrace_display(void *addr)
83 /* size_t block, frag_nb; */
86 /* xbt_mheap_t heap = __mmalloc_current_heap ?: (xbt_mheap_t) mmalloc_preinit(); */
88 /* block = (((char*) (addr) - (char*) heap -> heapbase) / BLOCKSIZE + 1); */
90 /* type = heap->heapinfo[block].type; */
93 /* case -1 : /\* Free block *\/ */
94 /* fprintf(stderr, "Asked to display the backtrace of a block that is free. I'm puzzled\n"); */
97 /* case 0: /\* Large block *\/ */
98 /* mmalloc_backtrace_block_display(heap->heapinfo, block); */
100 /* default: /\* Fragmented block *\/ */
101 /* frag_nb = RESIDUAL(addr, BLOCKSIZE) >> type; */
102 /* if(heap->heapinfo[block].busy_frag.frag_size[frag_nb] == -1){ */
103 /* fprintf(stderr , "Asked to display the backtrace of a fragment that is free. I'm puzzled\n"); */
106 /* mmalloc_backtrace_fragment_display(heap->heapinfo, block, frag_nb); */
112 static int compare_backtrace(int b1, int f1, int b2, int f2)
116 for(i=0; i< XBT_BACKTRACE_SIZE; i++){
117 if(heapinfo1[b1].busy_frag.bt[f1][i] != heapinfo2[b2].busy_frag.bt[f2][i]){
118 //mmalloc_backtrace_fragment_display((void*)heapinfo1, b1, f1);
119 //mmalloc_backtrace_fragment_display((void*)heapinfo2, b2, f2);
124 for(i=0; i< heapinfo1[b1].busy_block.bt_size; i++){
125 if(heapinfo1[b1].busy_block.bt[i] != heapinfo2[b2].busy_block.bt[i]){
126 //mmalloc_backtrace_block_display((void*)heapinfo1, b1);
127 //mmalloc_backtrace_block_display((void*)heapinfo2, b2);
136 /*********************************** Heap comparison ***********************************/
137 /***************************************************************************************/
139 typedef char *type_name;
142 /** \brief Base address of the real heap */
144 /** \brief Base address of the first heap snapshot */
146 /** \brief Base address of the second heap snapshot */
148 malloc_info *heapinfo1, *heapinfo2;
150 // Number of blocks in the heaps:
151 size_t heapsize1, heapsize2;
152 xbt_dynar_t to_ignore1, to_ignore2;
153 s_heap_area_t *equals_to1, *equals_to2;
154 dw_type_t *types1, *types2;
158 #define equals_to1_(i,j) equals_to1[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
159 #define equals_to2_(i,j) equals_to2[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
160 #define types1_(i,j) types1[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
161 #define types2_(i,j) types2[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
163 __thread struct s_mc_diff *mc_diff_info = NULL;
165 /*********************************** Free functions ************************************/
167 static void heap_area_pair_free(heap_area_pair_t pair)
173 static void heap_area_pair_free_voidp(void *d)
175 heap_area_pair_free((heap_area_pair_t) * (void **) d);
178 static void heap_area_free(heap_area_t area)
184 /************************************************************************************/
186 static s_heap_area_t make_heap_area(int block, int fragment)
191 area.fragment = fragment;
196 static int is_new_heap_area_pair(xbt_dynar_t list, int block1, int fragment1,
197 int block2, int fragment2)
200 unsigned int cursor = 0;
201 heap_area_pair_t current_pair;
203 xbt_dynar_foreach(list, cursor, current_pair) {
204 if (current_pair->block1 == block1 && current_pair->block2 == block2
205 && current_pair->fragment1 == fragment1
206 && current_pair->fragment2 == fragment2)
213 static int add_heap_area_pair(xbt_dynar_t list, int block1, int fragment1,
214 int block2, int fragment2)
217 if (is_new_heap_area_pair(list, block1, fragment1, block2, fragment2)) {
218 heap_area_pair_t pair = NULL;
219 pair = xbt_new0(s_heap_area_pair_t, 1);
220 pair->block1 = block1;
221 pair->fragment1 = fragment1;
222 pair->block2 = block2;
223 pair->fragment2 = fragment2;
225 xbt_dynar_push(list, &pair);
233 static ssize_t heap_comparison_ignore_size(xbt_dynar_t ignore_list,
237 unsigned int cursor = 0;
239 int end = xbt_dynar_length(ignore_list) - 1;
240 mc_heap_ignore_region_t region;
242 while (start <= end) {
243 cursor = (start + end) / 2;
245 (mc_heap_ignore_region_t) xbt_dynar_get_as(ignore_list, cursor,
246 mc_heap_ignore_region_t);
247 if (region->address == address)
249 if (region->address < address)
251 if (region->address > address)
258 static int is_stack(void *address)
260 unsigned int cursor = 0;
261 stack_region_t stack;
263 xbt_dynar_foreach(stacks_areas, cursor, stack) {
264 if (address == stack->address)
271 static int is_block_stack(int block)
273 unsigned int cursor = 0;
274 stack_region_t stack;
276 xbt_dynar_foreach(stacks_areas, cursor, stack) {
277 if (block == stack->block)
284 static void match_equals(struct s_mc_diff *state, xbt_dynar_t list)
287 unsigned int cursor = 0;
288 heap_area_pair_t current_pair;
290 xbt_dynar_foreach(list, cursor, current_pair) {
292 if (current_pair->fragment1 != -1) {
294 state->equals_to1_(current_pair->block1, current_pair->fragment1) =
295 make_heap_area(current_pair->block2, current_pair->fragment2);
296 state->equals_to2_(current_pair->block2, current_pair->fragment2) =
297 make_heap_area(current_pair->block1, current_pair->fragment1);
301 state->equals_to1_(current_pair->block1, 0) =
302 make_heap_area(current_pair->block2, current_pair->fragment2);
303 state->equals_to2_(current_pair->block2, 0) =
304 make_heap_area(current_pair->block1, current_pair->fragment1);
311 /** Check whether two blocks are known to be matching
313 * @param state State used
314 * @param b1 Block of state 1
315 * @param b2 Block of state 2
316 * @return if the blocks are known to be matching
318 static int equal_blocks(struct s_mc_diff *state, int b1, int b2)
321 if (state->equals_to1_(b1, 0).block == b2
322 && state->equals_to2_(b2, 0).block == b1)
328 /** Check whether two fragments are known to be matching
330 * @param state State used
331 * @param b1 Block of state 1
332 * @param f1 Fragment of state 1
333 * @param b2 Block of state 2
334 * @param f2 Fragment of state 2
335 * @return if the fragments are known to be matching
337 static int equal_fragments(struct s_mc_diff *state, int b1, int f1, int b2,
341 if (state->equals_to1_(b1, f1).block == b2
342 && state->equals_to1_(b1, f1).fragment == f2
343 && state->equals_to2_(b2, f2).block == b1
344 && state->equals_to2_(b2, f2).fragment == f1)
350 int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t i1,
353 if (mc_diff_info == NULL) {
354 mc_diff_info = xbt_new0(struct s_mc_diff, 1);
355 mc_diff_info->equals_to1 = NULL;
356 mc_diff_info->equals_to2 = NULL;
357 mc_diff_info->types1 = NULL;
358 mc_diff_info->types2 = NULL;
360 struct s_mc_diff *state = mc_diff_info;
362 if ((((struct mdesc *) heap1)->heaplimit !=
363 ((struct mdesc *) heap2)->heaplimit)
365 ((((struct mdesc *) heap1)->heapsize !=
366 ((struct mdesc *) heap2)->heapsize)))
369 state->heaplimit = ((struct mdesc *) heap1)->heaplimit;
371 // Mamailloute in order to find the base address of the main heap:
373 (char *) mmalloc_get_current_heap() - STD_HEAP_SIZE - xbt_pagesize;
375 state->heapbase1 = (char *) heap1 + BLOCKSIZE;
376 state->heapbase2 = (char *) heap2 + BLOCKSIZE;
379 (malloc_info *) ((char *) heap1 +
381 ((char *) ((struct mdesc *) heap1)->heapinfo -
382 (char *) state->s_heap)));
384 (malloc_info *) ((char *) heap2 +
386 ((char *) ((struct mdesc *) heap2)->heapinfo -
387 (char *) state->s_heap)));
389 state->heapsize1 = heap1->heapsize;
390 state->heapsize2 = heap2->heapsize;
392 state->to_ignore1 = i1;
393 state->to_ignore2 = i2;
395 if (state->heaplimit > state->available) {
397 realloc(state->equals_to1,
398 state->heaplimit * MAX_FRAGMENT_PER_BLOCK *
399 sizeof(s_heap_area_t));
401 realloc(state->types1,
402 state->heaplimit * MAX_FRAGMENT_PER_BLOCK *
403 sizeof(type_name *));
405 realloc(state->equals_to2,
406 state->heaplimit * MAX_FRAGMENT_PER_BLOCK *
407 sizeof(s_heap_area_t));
409 realloc(state->types2,
410 state->heaplimit * MAX_FRAGMENT_PER_BLOCK *
411 sizeof(type_name *));
412 state->available = state->heaplimit;
415 memset(state->equals_to1, 0,
416 state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t));
417 memset(state->equals_to2, 0,
418 state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t));
419 memset(state->types1, 0,
420 state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *));
421 memset(state->types2, 0,
422 state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *));
428 void reset_heap_information()
433 int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2)
436 struct s_mc_diff *state = mc_diff_info;
438 /* Start comparison */
439 size_t i1, i2, j1, j2, k;
440 void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2;
441 int nb_diff1 = 0, nb_diff2 = 0;
443 xbt_dynar_t previous =
444 xbt_dynar_new(sizeof(heap_area_pair_t), heap_area_pair_free_voidp);
446 int equal, res_compare = 0;
448 /* Check busy blocks */
452 while (i1 <= state->heaplimit) {
454 if (state->heapinfo1[i1].type == -1) { /* Free block */
460 ((void *) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE +
461 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
463 if (state->heapinfo1[i1].type == 0) { /* Large block */
465 if (is_stack(addr_block1)) {
466 for (k = 0; k < state->heapinfo1[i1].busy_block.size; k++)
467 state->equals_to1_(i1 + k, 0) = make_heap_area(i1, -1);
468 for (k = 0; k < state->heapinfo2[i1].busy_block.size; k++)
469 state->equals_to2_(i1 + k, 0) = make_heap_area(i1, -1);
470 i1 += state->heapinfo1[i1].busy_block.size;
474 if (state->equals_to1_(i1, 0).valid) {
483 /* Try first to associate to same block in the other heap */
484 if (state->heapinfo2[i1].type == state->heapinfo1[i1].type) {
486 if (state->equals_to2_(i1, 0).valid == 0) {
489 ((void *) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE +
490 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
493 compare_heap_area(addr_block1, addr_block2, snapshot1, snapshot2,
496 if (res_compare != 1) {
497 for (k = 1; k < state->heapinfo2[i1].busy_block.size; k++)
498 state->equals_to2_(i1 + k, 0) = make_heap_area(i1, -1);
499 for (k = 1; k < state->heapinfo1[i1].busy_block.size; k++)
500 state->equals_to1_(i1 + k, 0) = make_heap_area(i1, -1);
502 i1 += state->heapinfo1[i1].busy_block.size;
505 xbt_dynar_reset(previous);
511 while (i2 <= state->heaplimit && !equal) {
514 ((void *) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE +
515 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
522 if (state->heapinfo2[i2].type != 0) {
527 if (state->equals_to2_(i2, 0).valid) {
533 compare_heap_area(addr_block1, addr_block2, snapshot1, snapshot2,
536 if (res_compare != 1) {
537 for (k = 1; k < state->heapinfo2[i2].busy_block.size; k++)
538 state->equals_to2_(i2 + k, 0) = make_heap_area(i1, -1);
539 for (k = 1; k < state->heapinfo1[i1].busy_block.size; k++)
540 state->equals_to1_(i1 + k, 0) = make_heap_area(i2, -1);
542 i1 += state->heapinfo1[i1].busy_block.size;
545 xbt_dynar_reset(previous);
552 XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1,
553 state->heapinfo1[i1].busy_block.busy_size, addr_block1);
554 i1 = state->heaplimit + 1;
559 } else { /* Fragmented block */
561 for (j1 = 0; j1 < (size_t) (BLOCKSIZE >> state->heapinfo1[i1].type); j1++) {
563 if (state->heapinfo1[i1].busy_frag.frag_size[j1] == -1) /* Free fragment */
566 if (state->equals_to1_(i1, j1).valid)
570 (void *) ((char *) addr_block1 + (j1 << state->heapinfo1[i1].type));
575 /* Try first to associate to same fragment in the other heap */
576 if (state->heapinfo2[i1].type == state->heapinfo1[i1].type) {
578 if (state->equals_to2_(i1, j1).valid == 0) {
581 ((void *) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE +
582 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
584 (void *) ((char *) addr_block2 +
585 (j1 << ((xbt_mheap_t) state->s_heap)->heapinfo[i1].
589 compare_heap_area(addr_frag1, addr_frag2, snapshot1, snapshot2,
592 if (res_compare != 1)
595 xbt_dynar_reset(previous);
601 while (i2 <= state->heaplimit && !equal) {
603 if (state->heapinfo2[i2].type <= 0) {
608 for (j2 = 0; j2 < (size_t) (BLOCKSIZE >> state->heapinfo2[i2].type);
611 if (i2 == i1 && j2 == j1)
614 if (state->equals_to2_(i2, j2).valid)
618 ((void *) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE +
619 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
621 (void *) ((char *) addr_block2 +
622 (j2 << ((xbt_mheap_t) state->s_heap)->heapinfo[i2].
626 compare_heap_area(addr_frag1, addr_frag2, snapshot2, snapshot2,
629 if (res_compare != 1) {
631 xbt_dynar_reset(previous);
635 xbt_dynar_reset(previous);
645 ("Block %zu, fragment %zu not found (size_used = %zd, address = %p)\n",
646 i1, j1, state->heapinfo1[i1].busy_frag.frag_size[j1],
648 i2 = state->heaplimit + 1;
649 i1 = state->heaplimit + 1;
662 /* All blocks/fragments are equal to another block/fragment ? */
664 void *real_addr_frag1 = NULL, *real_addr_block1 = NULL, *real_addr_block2 =
665 NULL, *real_addr_frag2 = NULL;
667 while (i <= state->heaplimit) {
668 if (state->heapinfo1[i].type == 0) {
669 if (i1 == state->heaplimit) {
670 if (state->heapinfo1[i].busy_block.busy_size > 0) {
671 if (state->equals_to1_(i, 0).valid == 0) {
672 if (XBT_LOG_ISENABLED(mc_diff, xbt_log_priority_debug)) {
674 ((void *) (((ADDR2UINT(i)) - 1) * BLOCKSIZE +
675 (char *) state->heapbase1));
676 XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i,
677 addr_block1, state->heapinfo1[i].busy_block.busy_size);
678 //mmalloc_backtrace_block_display((void*)heapinfo1, i);
685 if (state->heapinfo1[i].type > 0) {
687 ((void *) (((ADDR2UINT(i)) - 1) * BLOCKSIZE +
688 (char *) state->heapbase1));
690 ((void *) (((ADDR2UINT(i)) - 1) * BLOCKSIZE +
691 (char *) ((struct mdesc *) state->s_heap)->heapbase));
692 for (j = 0; j < (size_t) (BLOCKSIZE >> state->heapinfo1[i].type); j++) {
693 if (i1 == state->heaplimit) {
694 if (state->heapinfo1[i].busy_frag.frag_size[j] > 0) {
695 if (state->equals_to1_(i, j).valid == 0) {
696 if (XBT_LOG_ISENABLED(mc_diff, xbt_log_priority_debug)) {
698 (void *) ((char *) addr_block1 +
699 (j << state->heapinfo1[i].type));
701 (void *) ((char *) real_addr_block1 +
702 (j << ((struct mdesc *) state->s_heap)->
705 ("Block %zu, Fragment %zu (%p - %p) not found (size used = %zd)",
706 i, j, addr_frag1, real_addr_frag1,
707 state->heapinfo1[i].busy_frag.frag_size[j]);
708 //mmalloc_backtrace_fragment_display((void*)heapinfo1, i, j);
719 if (i1 == state->heaplimit)
720 XBT_DEBUG("Number of blocks/fragments not found in heap1 : %d", nb_diff1);
724 while (i <= state->heaplimit) {
725 if (state->heapinfo2[i].type == 0) {
726 if (i1 == state->heaplimit) {
727 if (state->heapinfo2[i].busy_block.busy_size > 0) {
728 if (state->equals_to2_(i, 0).valid == 0) {
729 if (XBT_LOG_ISENABLED(mc_diff, xbt_log_priority_debug)) {
731 ((void *) (((ADDR2UINT(i)) - 1) * BLOCKSIZE +
732 (char *) state->heapbase2));
733 XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i,
734 addr_block2, state->heapinfo2[i].busy_block.busy_size);
735 //mmalloc_backtrace_block_display((void*)heapinfo2, i);
742 if (state->heapinfo2[i].type > 0) {
744 ((void *) (((ADDR2UINT(i)) - 1) * BLOCKSIZE +
745 (char *) state->heapbase2));
747 ((void *) (((ADDR2UINT(i)) - 1) * BLOCKSIZE +
748 (char *) ((struct mdesc *) state->s_heap)->heapbase));
749 for (j = 0; j < (size_t) (BLOCKSIZE >> state->heapinfo2[i].type); j++) {
750 if (i1 == state->heaplimit) {
751 if (state->heapinfo2[i].busy_frag.frag_size[j] > 0) {
752 if (state->equals_to2_(i, j).valid == 0) {
753 if (XBT_LOG_ISENABLED(mc_diff, xbt_log_priority_debug)) {
755 (void *) ((char *) addr_block2 +
756 (j << state->heapinfo2[i].type));
758 (void *) ((char *) real_addr_block2 +
759 (j << ((struct mdesc *) state->s_heap)->
762 ("Block %zu, Fragment %zu (%p - %p) not found (size used = %zd)",
763 i, j, addr_frag2, real_addr_frag2,
764 state->heapinfo2[i].busy_frag.frag_size[j]);
765 //mmalloc_backtrace_fragment_display((void*)heapinfo2, i, j);
776 if (i1 == state->heaplimit)
777 XBT_DEBUG("Number of blocks/fragments not found in heap2 : %d", nb_diff2);
779 xbt_dynar_free(&previous);
780 real_addr_frag1 = NULL, real_addr_block1 = NULL, real_addr_block2 =
781 NULL, real_addr_frag2 = NULL;
783 return ((nb_diff1 > 0) || (nb_diff2 > 0));
789 * @param real_area1 Process address for state 1
790 * @param real_area2 Process address for state 2
791 * @param snapshot1 Snapshot of state 1
792 * @param snapshot2 Snapshot of state 2
795 * @param check_ignore
797 static int compare_heap_area_without_type(struct s_mc_diff *state,
798 void *real_area1, void *real_area2,
799 mc_snapshot_t snapshot1,
800 mc_snapshot_t snapshot2,
801 xbt_dynar_t previous, int size,
806 void *addr_pointed1, *addr_pointed2;
807 int pointer_align, res_compare;
808 ssize_t ignore1, ignore2;
812 if (check_ignore > 0) {
814 heap_comparison_ignore_size(state->to_ignore1,
815 (char *) real_area1 + i)) != -1) {
817 heap_comparison_ignore_size(state->to_ignore2,
818 (char *) real_area2 + i)) == ignore1) {
831 if (mc_snapshot_memcp(((char *) real_area1) + i, snapshot1, ((char *) real_area2) + i, snapshot2, 1) != 0) {
833 pointer_align = (i / sizeof(void *)) * sizeof(void *);
834 addr_pointed1 = mc_snapshot_read_pointer((char *) real_area1 + pointer_align, snapshot1);
835 addr_pointed2 = mc_snapshot_read_pointer((char *) real_area2 + pointer_align, snapshot2);
837 if (addr_pointed1 > maestro_stack_start
838 && addr_pointed1 < maestro_stack_end
839 && addr_pointed2 > maestro_stack_start
840 && addr_pointed2 < maestro_stack_end) {
841 i = pointer_align + sizeof(void *);
843 } else if (addr_pointed1 > state->s_heap
844 && addr_pointed1 < mc_snapshot_get_heap_end(snapshot1)
845 && addr_pointed2 > state->s_heap
846 && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2)) {
847 // Both addreses are in the heap:
849 compare_heap_area(addr_pointed1, addr_pointed2, snapshot1,
850 snapshot2, previous, NULL, 0);
851 if (res_compare == 1) {
854 i = pointer_align + sizeof(void *);
873 * @param real_area1 Process address for state 1
874 * @param real_area2 Process address for state 2
875 * @param snapshot1 Snapshot of state 1
876 * @param snapshot2 Snapshot of state 2
879 * @param area_size either a byte_size or an elements_count (?)
880 * @param check_ignore
881 * @param pointer_level
882 * @return 0 (same), 1 (different), -1 (unknown)
884 static int compare_heap_area_with_type(struct s_mc_diff *state,
885 void *real_area1, void *real_area2,
886 mc_snapshot_t snapshot1,
887 mc_snapshot_t snapshot2,
888 xbt_dynar_t previous, dw_type_t type,
889 int area_size, int check_ignore,
893 if (is_stack(real_area1) && is_stack(real_area2))
896 ssize_t ignore1, ignore2;
898 if ((check_ignore > 0)
899 && ((ignore1 = heap_comparison_ignore_size(state->to_ignore1, real_area1))
901 && ((ignore2 = heap_comparison_ignore_size(state->to_ignore2, real_area2))
906 dw_type_t subtype, subsubtype;
907 int res, elm_size, i;
908 unsigned int cursor = 0;
910 void *addr_pointed1, *addr_pointed2;;
912 switch (type->type) {
913 case DW_TAG_unspecified_type:
916 case DW_TAG_base_type:
917 if (type->name != NULL && strcmp(type->name, "char") == 0) { /* String, hence random (arbitrary ?) size */
918 if (real_area1 == real_area2)
921 return (mc_snapshot_memcp(real_area1, snapshot1, real_area2, snapshot2, area_size) != 0);
923 if (area_size != -1 && type->byte_size != area_size)
926 return (mc_snapshot_memcp(real_area1, snapshot1, real_area2, snapshot2, type->byte_size) != 0);
930 case DW_TAG_enumeration_type:
931 if (area_size != -1 && type->byte_size != area_size)
934 return (mc_snapshot_memcp(real_area1, snapshot1, real_area2, snapshot2, type->byte_size) != 0);
937 case DW_TAG_const_type:
938 case DW_TAG_volatile_type:
939 return compare_heap_area_with_type(state, real_area1, real_area2,
940 snapshot1, snapshot2, previous,
941 type->subtype, area_size, check_ignore,
944 case DW_TAG_array_type:
945 subtype = type->subtype;
946 switch (subtype->type) {
947 case DW_TAG_unspecified_type:
950 case DW_TAG_base_type:
951 case DW_TAG_enumeration_type:
952 case DW_TAG_pointer_type:
953 case DW_TAG_reference_type:
954 case DW_TAG_rvalue_reference_type:
955 case DW_TAG_structure_type:
956 case DW_TAG_class_type:
957 case DW_TAG_union_type:
958 if (subtype->full_type)
959 subtype = subtype->full_type;
960 elm_size = subtype->byte_size;
962 // TODO, just remove the type indirection?
963 case DW_TAG_const_type:
965 case DW_TAG_volatile_type:
966 subsubtype = subtype->subtype;
967 if (subsubtype->full_type)
968 subsubtype = subsubtype->full_type;
969 elm_size = subsubtype->byte_size;
975 for (i = 0; i < type->element_count; i++) {
976 // TODO, add support for variable stride (DW_AT_byte_stride)
978 compare_heap_area_with_type(state,
979 (char *) real_area1 + (i * elm_size),
980 (char *) real_area2 + (i * elm_size),
981 snapshot1, snapshot2, previous,
982 type->subtype, subtype->byte_size,
983 check_ignore, pointer_level);
988 case DW_TAG_reference_type:
989 case DW_TAG_rvalue_reference_type:
990 case DW_TAG_pointer_type:
991 if (type->subtype && type->subtype->type == DW_TAG_subroutine_type) {
992 addr_pointed1 = mc_snapshot_read_pointer(real_area1, snapshot1);
993 addr_pointed2 = mc_snapshot_read_pointer(real_area2, snapshot2);
994 return (addr_pointed1 != addr_pointed2);;
997 if (pointer_level > 1) { /* Array of pointers */
998 for (i = 0; i < (area_size / sizeof(void *)); i++) {
999 addr_pointed1 = mc_snapshot_read_pointer((char*) real_area1 + i * sizeof(void *), snapshot1);
1000 addr_pointed2 = mc_snapshot_read_pointer((char*) real_area2 + i * sizeof(void *), snapshot2);
1001 if (addr_pointed1 > state->s_heap
1002 && addr_pointed1 < mc_snapshot_get_heap_end(snapshot1)
1003 && addr_pointed2 > state->s_heap
1004 && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2))
1006 compare_heap_area(addr_pointed1, addr_pointed2, snapshot1,
1007 snapshot2, previous, type->subtype,
1010 res = (addr_pointed1 != addr_pointed2);
1015 addr_pointed1 = mc_snapshot_read_pointer(real_area1, snapshot1);
1016 addr_pointed2 = mc_snapshot_read_pointer(real_area2, snapshot2);
1017 if (addr_pointed1 > state->s_heap
1018 && addr_pointed1 < mc_snapshot_get_heap_end(snapshot1)
1019 && addr_pointed2 > state->s_heap
1020 && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2))
1021 return compare_heap_area(addr_pointed1, addr_pointed2, snapshot1,
1022 snapshot2, previous, type->subtype,
1025 return (addr_pointed1 != addr_pointed2);
1029 case DW_TAG_structure_type:
1030 case DW_TAG_class_type:
1031 if (type->full_type)
1032 type = type->full_type;
1033 if (area_size != -1 && type->byte_size != area_size) {
1034 if (area_size > type->byte_size && area_size % type->byte_size == 0) {
1035 for (i = 0; i < (area_size / type->byte_size); i++) {
1037 compare_heap_area_with_type(state,
1038 (char *) real_area1 + i * type->byte_size,
1039 (char *) real_area2 + i * type->byte_size,
1040 snapshot1, snapshot2, previous, type, -1,
1050 xbt_dynar_foreach(type->members, cursor, member) {
1051 // TODO, optimize this? (for the offset case)
1052 char *real_member1 =
1053 mc_member_resolve(real_area1, type, member, snapshot1);
1054 char *real_member2 =
1055 mc_member_resolve(real_area2, type, member, snapshot2);
1057 compare_heap_area_with_type(state, real_member1, real_member2,
1058 snapshot1, snapshot2,
1059 previous, member->subtype, -1,
1067 case DW_TAG_union_type:
1068 return compare_heap_area_without_type(state, real_area1, real_area2,
1069 snapshot1, snapshot2, previous,
1070 type->byte_size, check_ignore);
1080 /** Infer the type of a part of the block from the type of the block
1082 * TODO, handle DW_TAG_array_type as well as arrays of the object ((*p)[5], p[5])
1084 * TODO, handle subfields ((*p).bar.foo, (*p)[5].bar…)
1086 * @param type_id DWARF type ID of the root address
1088 * @return DWARF type ID for given offset
1090 static dw_type_t get_offset_type(void *real_base_address, dw_type_t type,
1091 int offset, int area_size,
1092 mc_snapshot_t snapshot)
1095 // Beginning of the block, the infered variable type if the type of the block:
1099 switch (type->type) {
1100 case DW_TAG_structure_type:
1101 case DW_TAG_class_type:
1102 if (type->full_type)
1103 type = type->full_type;
1105 if (area_size != -1 && type->byte_size != area_size) {
1106 if (area_size > type->byte_size && area_size % type->byte_size == 0)
1111 unsigned int cursor = 0;
1113 xbt_dynar_foreach(type->members, cursor, member) {
1115 if (!member->location.size) {
1116 // We have the offset, use it directly (shortcut):
1117 if (member->offset == offset)
1118 return member->subtype;
1121 mc_member_resolve(real_base_address, type, member, snapshot);
1122 if (real_member - (char *) real_base_address == offset)
1123 return member->subtype;
1131 /* FIXME : other cases ? */
1139 * @param area1 Process address for state 1
1140 * @param area2 Process address for state 2
1141 * @param snapshot1 Snapshot of state 1
1142 * @param snapshot2 Snapshot of state 2
1143 * @param previous Pairs of blocks already compared on the current path (or NULL)
1144 * @param type_id Type of variable
1145 * @param pointer_level
1146 * @return 0 (same), 1 (different), -1
1148 int compare_heap_area(void *area1, void *area2, mc_snapshot_t snapshot1,
1149 mc_snapshot_t snapshot2, xbt_dynar_t previous,
1150 dw_type_t type, int pointer_level)
1153 struct s_mc_diff *state = mc_diff_info;
1156 ssize_t block1, frag1, block2, frag2;
1158 int check_ignore = 0;
1160 void *real_addr_block1,
1161 *real_addr_block2, *real_addr_frag1, *real_addr_frag2;
1163 int offset1 = 0, offset2 = 0;
1164 int new_size1 = -1, new_size2 = -1;
1165 dw_type_t new_type1 = NULL, new_type2 = NULL;
1167 int match_pairs = 0;
1169 if (previous == NULL) {
1171 xbt_dynar_new(sizeof(heap_area_pair_t), heap_area_pair_free_voidp);
1174 // Get block number:
1177 (char *) ((xbt_mheap_t) state->s_heap)->heapbase) / BLOCKSIZE + 1;
1180 (char *) ((xbt_mheap_t) state->s_heap)->heapbase) / BLOCKSIZE + 1;
1182 // If either block is a stack block:
1183 if (is_block_stack((int) block1) && is_block_stack((int) block2)) {
1184 add_heap_area_pair(previous, block1, -1, block2, -1);
1186 match_equals(state, previous);
1187 xbt_dynar_free(&previous);
1191 // If either block is not in the expected area of memory:
1192 if (((char *) area1 < (char *) ((xbt_mheap_t) state->s_heap)->heapbase)
1193 || (block1 > state->heapsize1) || (block1 < 1)
1194 || ((char *) area2 < (char *) ((xbt_mheap_t) state->s_heap)->heapbase)
1195 || (block2 > state->heapsize2) || (block2 < 1)) {
1197 xbt_dynar_free(&previous);
1202 // Process address of the block:
1204 ((void *) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE +
1205 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
1207 ((void *) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE +
1208 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
1212 if (type->full_type)
1213 type = type->full_type;
1215 // This assume that for "boring" types (volatile ...) byte_size is absent:
1216 while (type->byte_size == 0 && type->subtype != NULL)
1217 type = type->subtype;
1220 if ((type->type == DW_TAG_pointer_type)
1221 || ((type->type == DW_TAG_base_type) && type->name != NULL
1222 && (!strcmp(type->name, "char"))))
1225 type_size = type->byte_size;
1229 if ((state->heapinfo1[block1].type == -1) && (state->heapinfo2[block2].type == -1)) { /* Free block */
1232 match_equals(state, previous);
1233 xbt_dynar_free(&previous);
1237 } else if ((state->heapinfo1[block1].type == 0) && (state->heapinfo2[block2].type == 0)) { /* Complete block */
1239 // TODO, lookup variable type from block type as done for fragmented blocks
1241 if (state->equals_to1_(block1, 0).valid
1242 && state->equals_to2_(block2, 0).valid) {
1243 if (equal_blocks(state, block1, block2)) {
1245 match_equals(state, previous);
1246 xbt_dynar_free(&previous);
1252 if (type_size != -1) {
1253 if (type_size != state->heapinfo1[block1].busy_block.busy_size
1254 && type_size != state->heapinfo2[block2].busy_block.busy_size
1255 && type->name != NULL && !strcmp(type->name, "s_smx_context")) {
1257 match_equals(state, previous);
1258 xbt_dynar_free(&previous);
1264 if (state->heapinfo1[block1].busy_block.size !=
1265 state->heapinfo2[block2].busy_block.size) {
1267 xbt_dynar_free(&previous);
1272 if (state->heapinfo1[block1].busy_block.busy_size !=
1273 state->heapinfo2[block2].busy_block.busy_size) {
1275 xbt_dynar_free(&previous);
1280 if (!add_heap_area_pair(previous, block1, -1, block2, -1)) {
1282 match_equals(state, previous);
1283 xbt_dynar_free(&previous);
1288 size = state->heapinfo1[block1].busy_block.busy_size;
1290 // Remember (basic) type inference.
1291 // The current data structure only allows us to do this for the whole block.
1292 if (type != NULL && area1 == real_addr_block1) {
1293 state->types1_(block1, 0) = type;
1295 if (type != NULL && area2 == real_addr_block2) {
1296 state->types2_(block2, 0) = type;
1301 match_equals(state, previous);
1302 xbt_dynar_free(&previous);
1310 if ((state->heapinfo1[block1].busy_block.ignore > 0)
1311 && (state->heapinfo2[block2].busy_block.ignore ==
1312 state->heapinfo1[block1].busy_block.ignore))
1313 check_ignore = state->heapinfo1[block1].busy_block.ignore;
1315 } else if ((state->heapinfo1[block1].type > 0) && (state->heapinfo2[block2].type > 0)) { /* Fragmented block */
1319 ((uintptr_t) (ADDR2UINT(area1) % (BLOCKSIZE))) >> state->
1320 heapinfo1[block1].type;
1322 ((uintptr_t) (ADDR2UINT(area2) % (BLOCKSIZE))) >> state->
1323 heapinfo2[block2].type;
1325 // Process address of the fragment:
1327 (void *) ((char *) real_addr_block1 +
1328 (frag1 << ((xbt_mheap_t) state->s_heap)->heapinfo[block1].
1331 (void *) ((char *) real_addr_block2 +
1332 (frag2 << ((xbt_mheap_t) state->s_heap)->heapinfo[block2].
1335 // Check the size of the fragments against the size of the type:
1336 if (type_size != -1) {
1337 if (state->heapinfo1[block1].busy_frag.frag_size[frag1] == -1
1338 || state->heapinfo2[block2].busy_frag.frag_size[frag2] == -1) {
1340 match_equals(state, previous);
1341 xbt_dynar_free(&previous);
1345 if (type_size != state->heapinfo1[block1].busy_frag.frag_size[frag1]
1346 || type_size != state->heapinfo2[block2].busy_frag.frag_size[frag2]) {
1348 match_equals(state, previous);
1349 xbt_dynar_free(&previous);
1354 // Check if the blocks are already matched together:
1355 if (state->equals_to1_(block1, frag1).valid
1356 && state->equals_to2_(block2, frag2).valid) {
1357 if (equal_fragments(state, block1, frag1, block2, frag2)) {
1359 match_equals(state, previous);
1360 xbt_dynar_free(&previous);
1365 // Compare the size of both fragments:
1366 if (state->heapinfo1[block1].busy_frag.frag_size[frag1] !=
1367 state->heapinfo2[block2].busy_frag.frag_size[frag2]) {
1368 if (type_size == -1) {
1370 match_equals(state, previous);
1371 xbt_dynar_free(&previous);
1376 xbt_dynar_free(&previous);
1381 // Size of the fragment:
1382 size = state->heapinfo1[block1].busy_frag.frag_size[frag1];
1384 // Remember (basic) type inference.
1385 // The current data structure only allows us to do this for the whole block.
1386 if (type != NULL && area1 == real_addr_frag1) {
1387 state->types1_(block1, frag1) = type;
1389 if (type != NULL && area2 == real_addr_frag2) {
1390 state->types2_(block2, frag2) = type;
1392 // The type of the variable is already known:
1397 // Type inference from the block type.
1398 else if (state->types1_(block1, frag1) != NULL
1399 || state->types2_(block2, frag2) != NULL) {
1401 offset1 = (char *) area1 - (char *) real_addr_frag1;
1402 offset2 = (char *) area2 - (char *) real_addr_frag2;
1404 if (state->types1_(block1, frag1) != NULL
1405 && state->types2_(block2, frag2) != NULL) {
1407 get_offset_type(real_addr_frag1, state->types1_(block1, frag1),
1408 offset1, size, snapshot1);
1410 get_offset_type(real_addr_frag2, state->types2_(block2, frag2),
1411 offset1, size, snapshot2);
1412 } else if (state->types1_(block1, frag1) != NULL) {
1414 get_offset_type(real_addr_frag1, state->types1_(block1, frag1),
1415 offset1, size, snapshot1);
1417 get_offset_type(real_addr_frag2, state->types1_(block1, frag1),
1418 offset2, size, snapshot2);
1419 } else if (state->types2_(block2, frag2) != NULL) {
1421 get_offset_type(real_addr_frag1, state->types2_(block2, frag2),
1422 offset1, size, snapshot1);
1424 get_offset_type(real_addr_frag2, state->types2_(block2, frag2),
1425 offset2, size, snapshot2);
1428 match_equals(state, previous);
1429 xbt_dynar_free(&previous);
1434 if (new_type1 != NULL && new_type2 != NULL && new_type1 != new_type2) {
1437 while (type->byte_size == 0 && type->subtype != NULL)
1438 type = type->subtype;
1439 new_size1 = type->byte_size;
1442 while (type->byte_size == 0 && type->subtype != NULL)
1443 type = type->subtype;
1444 new_size2 = type->byte_size;
1448 match_equals(state, previous);
1449 xbt_dynar_free(&previous);
1455 if (new_size1 > 0 && new_size1 == new_size2) {
1460 if (offset1 == 0 && offset2 == 0) {
1461 if (!add_heap_area_pair(previous, block1, frag1, block2, frag2)) {
1463 match_equals(state, previous);
1464 xbt_dynar_free(&previous);
1472 match_equals(state, previous);
1473 xbt_dynar_free(&previous);
1478 if ((state->heapinfo1[block1].busy_frag.ignore[frag1] > 0)
1479 && (state->heapinfo2[block2].busy_frag.ignore[frag2] ==
1480 state->heapinfo1[block1].busy_frag.ignore[frag1]))
1481 check_ignore = state->heapinfo1[block1].busy_frag.ignore[frag1];
1486 xbt_dynar_free(&previous);
1493 /* Start comparison */
1496 compare_heap_area_with_type(state, area1, area2, snapshot1, snapshot2,
1497 previous, type, size, check_ignore,
1501 compare_heap_area_without_type(state, area1, area2, snapshot1, snapshot2,
1502 previous, size, check_ignore);
1504 if (res_compare == 1) {
1506 xbt_dynar_free(&previous);
1511 match_equals(state, previous);
1512 xbt_dynar_free(&previous);
1518 /*********************************************** Miscellaneous ***************************************************/
1519 /****************************************************************************************************************/
1522 static int get_pointed_area_size(void *area, int heap)
1525 struct s_mc_diff *state = mc_diff_info;
1528 malloc_info *heapinfo;
1531 heapinfo = state->heapinfo1;
1533 heapinfo = state->heapinfo2;
1537 (char *) ((xbt_mheap_t) state->s_heap)->heapbase) / BLOCKSIZE + 1;
1539 if (((char *) area < (char *) ((xbt_mheap_t) state->s_heap)->heapbase)
1540 || (block > state->heapsize1) || (block < 1))
1543 if (heapinfo[block].type == -1) { /* Free block */
1545 } else if (heapinfo[block].type == 0) { /* Complete block */
1546 return (int) heapinfo[block].busy_block.busy_size;
1549 ((uintptr_t) (ADDR2UINT(area) % (BLOCKSIZE))) >> heapinfo[block].type;
1550 return (int) heapinfo[block].busy_frag.frag_size[frag];
1556 char *get_type_description(mc_object_info_t info, char *type_name)
1559 xbt_dict_cursor_t dict_cursor;
1563 xbt_dict_foreach(info->types, dict_cursor, type_origin, type) {
1564 if (type->name && (strcmp(type->name, type_name) == 0)
1565 && type->byte_size > 0) {
1566 xbt_dict_cursor_free(&dict_cursor);
1571 xbt_dict_cursor_free(&dict_cursor);
1577 #define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
1581 int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2)
1584 struct s_mc_diff *state = mc_diff_info;
1586 if (heap1 == NULL && heap1 == NULL) {
1587 XBT_DEBUG("Malloc descriptors null");
1591 if (heap1->heaplimit != heap2->heaplimit) {
1592 XBT_DEBUG("Different limit of valid info table indices");
1596 /* Heap information */
1597 state->heaplimit = ((struct mdesc *) heap1)->heaplimit;
1600 // Mamailloute in order to find the base address of the main heap:
1602 (char *) mmalloc_get_current_heap() - STD_HEAP_SIZE - xbt_pagesize;
1604 state->heapbase1 = (char *) heap1 + BLOCKSIZE;
1605 state->heapbase2 = (char *) heap2 + BLOCKSIZE;
1608 (malloc_info *) ((char *) heap1 +
1610 ((char *) heap1->heapinfo - (char *) state->s_heap)));
1612 (malloc_info *) ((char *) heap2 +
1614 ((char *) heap2->heapinfo - (char *) state->s_heap)));
1616 state->heapsize1 = heap1->heapsize;
1617 state->heapsize2 = heap2->heapsize;
1619 /* Start comparison */
1621 void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2;
1625 /* Check busy blocks */
1629 while (i <= state->heaplimit) {
1632 ((void *) (((ADDR2UINT(i)) - 1) * BLOCKSIZE +
1633 (char *) state->heapbase1));
1635 ((void *) (((ADDR2UINT(i)) - 1) * BLOCKSIZE +
1636 (char *) state->heapbase2));
1638 if (state->heapinfo1[i].type != state->heapinfo2[i].type) {
1640 distance += BLOCKSIZE;
1641 XBT_DEBUG("Different type of blocks (%zu) : %d - %d -> distance = %d", i,
1642 state->heapinfo1[i].type, state->heapinfo2[i].type, distance);
1647 if (state->heapinfo1[i].type == -1) { /* Free block */
1652 if (state->heapinfo1[i].type == 0) { /* Large block */
1654 if (state->heapinfo1[i].busy_block.size !=
1655 state->heapinfo2[i].busy_block.size) {
1657 BLOCKSIZE * max(state->heapinfo1[i].busy_block.size,
1658 state->heapinfo2[i].busy_block.size);
1659 i += max(state->heapinfo1[i].busy_block.size,
1660 state->heapinfo2[i].busy_block.size);
1662 ("Different larger of cluster at block %zu : %zu - %zu -> distance = %d",
1663 i, state->heapinfo1[i].busy_block.size,
1664 state->heapinfo2[i].busy_block.size, distance);
1668 /*if(heapinfo1[i].busy_block.busy_size != heapinfo2[i].busy_block.busy_size){
1669 distance += max(heapinfo1[i].busy_block.busy_size, heapinfo2[i].busy_block.busy_size);
1670 i += max(heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size);
1671 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);
1677 //while(k < (heapinfo1[i].busy_block.busy_size)){
1678 while (k < state->heapinfo1[i].busy_block.size * BLOCKSIZE) {
1679 if (memcmp((char *) addr_block1 + k, (char *) addr_block2 + k, 1) !=
1688 } else { /* Fragmented block */
1690 for (j = 0; j < (size_t) (BLOCKSIZE >> state->heapinfo1[i].type); j++) {
1693 (void *) ((char *) addr_block1 + (j << state->heapinfo1[i].type));
1695 (void *) ((char *) addr_block2 + (j << state->heapinfo2[i].type));
1697 if (state->heapinfo1[i].busy_frag.frag_size[j] == 0
1698 && state->heapinfo2[i].busy_frag.frag_size[j] == 0) {
1703 /*if(heapinfo1[i].busy_frag.frag_size[j] != heapinfo2[i].busy_frag.frag_size[j]){
1704 distance += max(heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j]);
1705 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);
1711 //while(k < max(heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j])){
1712 while (k < (BLOCKSIZE / (BLOCKSIZE >> state->heapinfo1[i].type))) {
1713 if (memcmp((char *) addr_frag1 + k, (char *) addr_frag2 + k, 1) !=