- xbt_ex_t e;
-
- memcpy(&e.bt,&(mdp->heapinfo[block].busy_frag.bt[frag]),sizeof(void*)*XBT_BACKTRACE_SIZE);
- e.used = XBT_BACKTRACE_SIZE;
-
- xbt_ex_setup_backtrace(&e);
- if (e.used == 0) {
- fprintf(stderr, "(backtrace not set)\n");
- } else if (e.bt_strings == NULL) {
- fprintf(stderr, "(backtrace not ready to be computed. %s)\n",xbt_binary_name?"Dunno why":"xbt_binary_name not setup yet");
- } else {
- int i;
-
- fprintf(stderr, "Backtrace of where the fragment %zu in block %zu where malloced (%d frames):\n", frag, block ,e.used);
- for (i = 0; i < e.used; i++) /* no need to display "xbt_backtrace_display" */{
- fprintf(stderr,"%d",i);fflush(NULL);
- fprintf(stderr, "---> %s\n", e.bt_strings[i] + 4);
+ /* Try first to associate to same block in the other heap */
+ if(heapinfo2[current_block].type == heapinfo1[current_block].type){
+
+ if(heapinfo2[current_block].busy_block.equal_to == NULL){
+
+ addr_block2 = ((void*) (((ADDR2UINT(current_block)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
+ snap_addr_block2 = ((void*) (((ADDR2UINT(current_block)) - 1) * BLOCKSIZE + (char*)heapbase2));
+
+ if((xbt_dynar_length(*stack2) < xbt_dynar_length(stacks_areas)) && ((stack_name = is_stack(addr_block2)) != NULL)){
+ stack_region_t stack = xbt_new0(s_stack_region_t, 1);
+ stack->address = snap_addr_block2;
+ stack->process_name = strdup(stack_name);
+ stack->size = heapinfo2[current_block].busy_block.busy_size;
+ xbt_dynar_push(*stack2, &stack);
+ res_compare = -1;
+ }
+
+ res_compare = compare_area(addr_block1, addr_block2, previous, equals);
+
+ if(res_compare == 0 || res_compare == -1){
+ for(k=1; k < heapinfo2[current_block].busy_block.size; k++)
+ heapinfo2[current_block+k].busy_block.equal_to = new_heap_area(i1, -1);
+ for(k=1; k < heapinfo1[current_block].busy_block.size; k++)
+ heapinfo1[current_block+k].busy_block.equal_to = new_heap_area(i1, -1);
+ equal = 1;
+ match_equals(previous, equals);
+ i1 = i1 + heapinfo1[current_block].busy_block.size;
+ }
+
+ xbt_dynar_reset(previous);
+
+ }
+
+ }
+
+ while(i2 <= heaplimit && !equal){
+
+ addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
+ snap_addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)heapbase2));
+
+ if((xbt_dynar_length(*stack2) < xbt_dynar_length(stacks_areas)) && ((stack_name = is_stack(addr_block2)) != NULL)){
+ stack_region_t stack = xbt_new0(s_stack_region_t, 1);
+ stack->address = snap_addr_block2;
+ stack->process_name = strdup(stack_name);
+ stack->size = heapinfo2[i2].busy_block.busy_size;
+ xbt_dynar_push(*stack2, &stack);
+ res_compare = -1;
+ }
+
+ if(i2 == current_block){
+ i2++;
+ continue;
+ }
+
+ if(heapinfo2[i2].type != 0){
+ i2++;
+ continue;
+ }
+
+ if(heapinfo2[i2].busy_block.equal_to != NULL){
+ i2++;
+ continue;
+ }
+
+ res_compare = compare_area(addr_block1, addr_block2, previous, equals);
+
+ if(res_compare == 0 || res_compare == -1){
+ for(k=1; k < heapinfo2[i2].busy_block.size; k++)
+ heapinfo2[i2+k].busy_block.equal_to = new_heap_area(i1, -1);
+ for(k=1; k < heapinfo1[i1].busy_block.size; k++)
+ heapinfo1[i1+k].busy_block.equal_to = new_heap_area(i2, -1);
+ equal = 1;
+ match_equals(previous, equals);
+ i1 = i1 + heapinfo1[i1].busy_block.size;
+ }
+
+ xbt_dynar_reset(previous);
+
+ i2++;
+
+ }
+
+ if(!equal){
+ XBT_DEBUG("Block %zu not found (size_used = %zu)", i1, heapinfo1[i1].busy_block.busy_size);
+ i1 = heaplimit + 1;
+ nb_diff1++;
+ }
+
+ }else{ /* Fragmented block */
+
+ for(j1=0; j1 < (size_t) (BLOCKSIZE >> heapinfo1[i1].type); j1++){
+
+ current_fragment = j1;
+
+ if(heapinfo1[i1].busy_frag.frag_size[j1] == -1) /* Free fragment */
+ continue;
+
+ if(heapinfo1[i1].busy_frag.equal_to[j1] != NULL)
+ continue;
+
+ addr_frag1 = (void*) ((char *)addr_block1 + (j1 << heapinfo1[i1].type));
+
+ i2 = 1;
+ equal = 0;
+
+ /* Try first to associate to same fragment in the other heap */
+ if(heapinfo2[current_block].type == heapinfo1[current_block].type){
+
+ if(heapinfo2[current_block].busy_frag.equal_to[current_fragment] == NULL){
+
+ addr_block2 = ((void*) (((ADDR2UINT(current_block)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
+ addr_frag2 = (void*) ((char *)addr_block2 + (current_fragment << ((xbt_mheap_t)s_heap)->heapinfo[current_block].type));
+
+ res_compare = compare_area(addr_frag1, addr_frag2, previous, equals);
+
+ if(res_compare == 0){
+ equal = 1;
+ match_equals(previous, equals);
+ }
+
+ xbt_dynar_reset(previous);
+
+ }
+ }
+
+ while(i2 <= heaplimit && !equal){
+
+
+ if(heapinfo2[i2].type <= 0){
+ i2++;
+ continue;
+ }
+
+ for(j2=0; j2 < (size_t) (BLOCKSIZE >> heapinfo2[i2].type); j2++){
+
+ if(heapinfo2[i2].type == heapinfo1[i1].type && i2 == current_block && j2 == current_fragment)
+ continue;
+
+ if(heapinfo2[i2].busy_frag.equal_to[j2] != NULL)
+ continue;
+
+ addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
+ addr_frag2 = (void*) ((char *)addr_block2 + (j2 << ((xbt_mheap_t)s_heap)->heapinfo[i2].type));
+
+ res_compare = compare_area(addr_frag1, addr_frag2, previous, equals);
+
+ if(res_compare == 0){
+ equal = 1;
+ match_equals(previous, equals);
+ xbt_dynar_reset(previous);
+ break;
+ }
+
+ xbt_dynar_reset(previous);
+
+ }
+
+ i2++;
+
+ }
+
+ if(heapinfo1[i1].busy_frag.equal_to[j1] == NULL){
+ XBT_DEBUG("Block %zu, fragment %zu not found (size_used = %d)", i1, j1, heapinfo1[i1].busy_frag.frag_size[j1]);
+ i2 = heaplimit + 1;
+ i1 = heaplimit + 1;
+ nb_diff1++;
+ break;
+ }
+
+ }
+
+ i1++;
+