1 /* mm_diff - Memory snapshooting and comparison */
3 /* Copyright (c) 2008-2012. The SimGrid Team. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include "xbt/ex_interface.h" /* internals of backtrace setup */
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mm_diff, xbt,
13 "Logging specific to mm_diff in mmalloc");
15 extern char *xbt_binary_name;
17 void mmalloc_backtrace_block_display(void* heapinfo, size_t block){
21 if (((malloc_info *)heapinfo)[block].busy_block.bt_size == 0) {
22 fprintf(stderr,"No backtrace available for that block, sorry.\n");
26 memcpy(&e.bt,&(((malloc_info *)heapinfo)[block].busy_block.bt),sizeof(void*)*XBT_BACKTRACE_SIZE);
27 e.used = ((malloc_info *)heapinfo)[block].busy_block.bt_size;
29 xbt_ex_setup_backtrace(&e);
31 fprintf(stderr, "(backtrace not set)\n");
32 } else if (e.bt_strings == NULL) {
33 fprintf(stderr, "(backtrace not ready to be computed. %s)\n",xbt_binary_name?"Dunno why":"xbt_binary_name not setup yet");
37 fprintf(stderr, "Backtrace of where the block %zu was malloced (%d frames):\n", block ,e.used);
38 for (i = 0; i < e.used; i++) /* no need to display "xbt_backtrace_display" */{
39 fprintf(stderr,"%d",i);fflush(NULL);
40 fprintf(stderr, "---> %s\n", e.bt_strings[i] + 4);
45 void mmalloc_backtrace_fragment_display(void* heapinfo, size_t block, size_t frag){
49 memcpy(&e.bt,&(((malloc_info *)heapinfo)[block].busy_frag.bt[frag]),sizeof(void*)*XBT_BACKTRACE_SIZE);
50 e.used = XBT_BACKTRACE_SIZE;
52 xbt_ex_setup_backtrace(&e);
54 fprintf(stderr, "(backtrace not set)\n");
55 } else if (e.bt_strings == NULL) {
56 fprintf(stderr, "(backtrace not ready to be computed. %s)\n",xbt_binary_name?"Dunno why":"xbt_binary_name not setup yet");
60 fprintf(stderr, "Backtrace of where the fragment %zu in block %zu was malloced (%d frames):\n", frag, block ,e.used);
61 for (i = 0; i < e.used; i++) /* no need to display "xbt_backtrace_display" */{
62 fprintf(stderr,"%d",i);fflush(NULL);
63 fprintf(stderr, "---> %s\n", e.bt_strings[i] + 4);
68 int mmalloc_compare_heap(xbt_mheap_t mdp1, xbt_mheap_t mdp2){
70 if(mdp1 == NULL && mdp2 == NULL){
71 fprintf(stderr, "Malloc descriptors null\n");
75 int errors = mmalloc_compare_mdesc(mdp1, mdp2);
82 malloc_info *heapinfo1, *heapinfo2;
83 void *heapbase1, *heapbase2;
84 size_t heapsize1, heapsize2;
86 int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){
90 if(mdp1->heaplimit != mdp2->heaplimit){
91 fprintf(stderr,"Different limit of valid info table indices\n");
95 s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - getpagesize();
97 fprintf(stderr, "s_heap->heapbase : %p\n", ((struct mdesc*)s_heap)->heapbase);
99 heapbase1 = (char *)mdp1 + BLOCKSIZE;
100 heapbase2 = (char *)mdp2 + BLOCKSIZE;
102 fprintf(stderr, "Heapbase1 : %p, Heapbase2 : %p\n", heapbase1, heapbase2);
103 fprintf(stderr, "Heapinfo : %p\n", mdp1->heapinfo);
105 heapinfo1 = (malloc_info *)((char *)mdp1 + ((char *)mdp1->heapinfo - (char *)s_heap));
106 heapinfo2 = (malloc_info *)((char *)mdp2 + ((char *)mdp2->heapinfo - (char *)s_heap));
108 fprintf(stderr, "Heapinfo1 : %p, Heapinfo2 : %p\n", heapinfo1, heapinfo2);
110 heapsize1 = mdp1->heapsize;
111 heapsize2 = mdp2->heapsize;
114 void *addr_block1 = NULL, *addr_block2 = NULL, *addr_frag1 = NULL, *addr_frag2 = NULL;
121 int total_distance = 0;
124 void *address_pointed1 = NULL, *address_pointed2 = NULL;
126 int block_pointed1, block_pointed2, frag_pointed1, frag_pointed2;
127 void *addr_block_pointed1 = NULL, *addr_block_pointed2 = NULL, *addr_frag_pointed1 = NULL, *addr_frag_pointed2 = NULL;
129 /* Check busy blocks*/
131 while(i < mdp1->heaplimit){
133 if(heapinfo1[i].type != heapinfo2[i].type){
134 fprintf(stderr,"Different type of block : %d - %d\n", heapinfo1[i].type, heapinfo2[i].type);
138 /* Get address of block i in each heap */
139 addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase1));
140 addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase2));
142 if(heapinfo1[i].type == 0){ /* busy large block */
144 if(heapinfo1[i].busy_block.size != heapinfo2[i].busy_block.size){
145 fprintf(stderr,"Different size of a large cluster : %zu - %zu\n", heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size);
150 if(heapinfo1[i].busy_block.busy_size != heapinfo2[i].busy_block.busy_size){
151 fprintf(stderr,"Different busy_size of a large cluster : %zu - %zu\n", heapinfo1[i].busy_block.busy_size, heapinfo2[i].busy_block.busy_size);
156 /* Hamming distance on different blocks */
160 for(k=0;k<heapinfo1[i].busy_block.busy_size;k++){
162 if(memcmp(((char *)addr_block1) + k, ((char *)addr_block2) + k, 1) != 0){
164 fprintf(stderr, "Different byte (offset=%d) (%p - %p) in block %zu\n", k, (char *)addr_block1 + k, (char *)addr_block2 + k, i); fflush(NULL);
166 /* Check if pointer difference */
167 pointer_align = (k >> sizeof(void*)) * sizeof(void*);
168 address_pointed1 = *((void **)((char *)addr_block1 + pointer_align));
169 address_pointed2 = *((void **)((char *)addr_block2 + pointer_align));
171 fprintf(stderr, "Addresses pointed : %p - %p \n", address_pointed1, address_pointed2);
173 /* Get block number */
174 block_pointed1 = ((char*)address_pointed1 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
175 block_pointed2 = ((char*)address_pointed2 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
177 fprintf(stderr, "Blocks pointed : %d - %d\n", block_pointed1, block_pointed2);
179 if((char *) address_pointed1 < (char*)((struct mdesc*)s_heap)->heapbase || block_pointed1 > heapsize1 || block_pointed1 < 1 || (char *) address_pointed2 < (char*)((struct mdesc*)s_heap)->heapbase || block_pointed2 > heapsize2 || block_pointed2 < 1) {
180 fprintf(stderr, "Unknown pointer(s) ! \n");
186 addr_block_pointed1 = ((void*) (((ADDR2UINT((size_t)block_pointed1)) - 1) * BLOCKSIZE + (char*)heapbase1));
187 addr_block_pointed2 = ((void*) (((ADDR2UINT((size_t)block_pointed2)) - 1) * BLOCKSIZE + (char*)heapbase2));
189 fprintf(stderr, "Addr blocks pointed : %p - %p\n", addr_block_pointed1, addr_block_pointed2);
191 if(heapinfo1[block_pointed1].type == heapinfo2[block_pointed2].type){
193 if(heapinfo1[block_pointed1].type == 0){ // Large block
195 if(heapinfo1[block_pointed1].busy_block.busy_size == heapinfo2[block_pointed2].busy_block.busy_size){
197 if(memcmp(addr_block_pointed1, addr_block_pointed2, heapinfo1[block_pointed1].busy_block.busy_size) != 0){
200 fprintf(stderr, "False difference detected\n");
207 }else{ // Fragmented block
209 /* Get fragment number */
210 frag_pointed1 = ((uintptr_t) (ADDR2UINT (address_pointed1) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed1].type;
211 frag_pointed2 = ((uintptr_t) (ADDR2UINT (address_pointed2) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed2].type;
213 fprintf(stderr, "Fragments pointed : %d - %d\n", frag_pointed1, frag_pointed2);
215 addr_frag_pointed1 = (char*)addr_block_pointed1 + (frag_pointed1 * (int)pow(2, heapinfo1[block_pointed1].type));
216 addr_frag_pointed2 = (char*)addr_block_pointed2 + (frag_pointed2 * (int)pow(2, heapinfo2[block_pointed2].type));
218 fprintf(stderr, "Addr frag pointed : %p - %p\n", addr_frag_pointed1, addr_frag_pointed2);
220 fprintf(stderr, "Size used in fragments pointed : %d - %d\n", heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1], heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]);
222 if(heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1] == heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]){
224 if(memcmp(addr_frag_pointed1, addr_frag_pointed2, heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1]) != 0){
227 fprintf(stderr, "False difference detected\n");
237 if(((heapinfo1[block_pointed1].type == 0) && (heapinfo2[block_pointed2].type != 0)) || ((heapinfo1[block_pointed1].type != 0) && (heapinfo2[block_pointed2].type == 0))){
238 fprintf(stderr, "Pointers on blocks with different types \n");
242 frag_pointed1 = ((uintptr_t) (ADDR2UINT (address_pointed1) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed1].type;
243 frag_pointed2 = ((uintptr_t) (ADDR2UINT (address_pointed2) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed2].type;
245 fprintf(stderr, "Fragments pointed : %d - %d\n", frag_pointed1, frag_pointed2);
247 addr_frag_pointed1 = (char*)addr_block_pointed1 + (frag_pointed1 * (int)pow(2, heapinfo1[block_pointed1].type));
248 addr_frag_pointed2 = (char*)addr_block_pointed2 + (frag_pointed2 * (int)pow(2, heapinfo2[block_pointed2].type));
250 fprintf(stderr, "Addr frag pointed : %p - %p\n", addr_frag_pointed1, addr_frag_pointed2);
252 fprintf(stderr, "Size used in fragments pointed : %d - %d\n", heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1], heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]);
254 if(heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1] == heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]){
256 if(memcmp(addr_frag_pointed1, addr_frag_pointed2, heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1]) != 0){
259 fprintf(stderr, "False difference detected\n");
273 fprintf(stderr,"\nDifferent data in large block %zu (size = %zu (in blocks), busy_size = %zu (in bytes))\n", i, heapinfo1[i].busy_block.size, heapinfo1[i].busy_block.busy_size);
275 fprintf(stderr, "Hamming distance between blocks : %d\n", distance);
276 mmalloc_backtrace_block_display(heapinfo1, i);
277 mmalloc_backtrace_block_display(heapinfo2, i);
278 fprintf(stderr, "\n");
280 total_distance += distance;
287 if(heapinfo1[i].type > 0){ /* busy fragmented block */
289 if(heapinfo1[i].type != heapinfo2[i].type){
290 fprintf(stderr,"Different size of fragments in fragmented block %zu : %d - %d\n", i, heapinfo1[i].type, heapinfo2[i].type); fflush(NULL);
294 if(heapinfo1[i].busy_frag.nfree != heapinfo2[i].busy_frag.nfree){
295 fprintf(stderr,"Different free fragments in fragmented block %zu : %zu - %zu\n", i, heapinfo1[i].busy_frag.nfree, heapinfo2[i].busy_frag.nfree); fflush(NULL);
299 if(heapinfo1[i].busy_frag.first != heapinfo2[i].busy_frag.first){
300 fprintf(stderr,"Different first free fragment in fragmented block %zu : %zu - %zu\n", i, heapinfo1[i].busy_frag.first, heapinfo2[i].busy_frag.first); fflush(NULL);
304 frag_size = pow(2, heapinfo1[i].type);
306 for(j=0; j< (BLOCKSIZE/frag_size); j++){
308 if(heapinfo1[i].busy_frag.frag_size[j] != heapinfo2[i].busy_frag.frag_size[j]){
309 fprintf(stderr,"Different busy_size for fragment %zu in block %zu : %hu - %hu\n", j, i, heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j]); fflush(NULL);
313 if(heapinfo1[i].busy_frag.frag_size[j] > 0){
315 addr_frag1 = (char *)addr_block1 + (j * frag_size);
316 addr_frag2 = (char *)addr_block2 + (j * frag_size);
318 /* Hamming distance on different blocks */
321 for(k=0;k<heapinfo1[i].busy_frag.frag_size[j];k++){
323 if(memcmp(((char *)addr_frag1) + k, ((char *)addr_frag2) + k, 1) != 0){
325 fprintf(stderr, "Different byte (offset=%d) (%p - %p) in fragment %zu in block %zu\n", k, (char *)addr_frag1 + k, (char *)addr_frag2 + k, j, i); fflush(NULL);
327 pointer_align = (k / sizeof(void*)) * sizeof(void*);
328 address_pointed1 = *((void **)((char *)addr_frag1 + pointer_align));
329 address_pointed2 = *((void **)((char *)addr_frag2 + pointer_align));
331 fprintf(stderr, "Addresses pointed : %p - %p \n", address_pointed1, address_pointed2);
334 block_pointed1 = ((char*)address_pointed1 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
335 block_pointed2 = ((char*)address_pointed2 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
337 fprintf(stderr, "Blocks pointed : %d - %d\n", block_pointed1, block_pointed2);
339 if((char *) address_pointed1 < (char*)((struct mdesc*)s_heap)->heapbase || block_pointed1 > heapsize1 || block_pointed1 < 1 || (char *) address_pointed2 < (char*)((struct mdesc*)s_heap)->heapbase || block_pointed2 > heapsize2 || block_pointed2 < 1) {
340 fprintf(stderr, "Unknown pointer(s) ! \n");
346 addr_block_pointed1 = ((void*) (((ADDR2UINT((size_t)block_pointed1)) - 1) * BLOCKSIZE + (char*)heapbase1));
347 addr_block_pointed2 = ((void*) (((ADDR2UINT((size_t)block_pointed2)) - 1) * BLOCKSIZE + (char*)heapbase2));
349 fprintf(stderr, "Addr block pointed : %p - %p\n", addr_block_pointed1, addr_block_pointed2);
351 if(heapinfo1[block_pointed1].type == heapinfo2[block_pointed2].type){
353 if(heapinfo1[block_pointed1].type == 0){ // Large block
355 if(heapinfo1[block_pointed1].busy_block.busy_size == heapinfo2[block_pointed2].busy_block.busy_size){
357 if(memcmp(addr_block_pointed1, addr_block_pointed2, heapinfo1[block_pointed1].busy_block.busy_size) != 0){
360 fprintf(stderr, "False difference detected\n");
367 }else{ // Fragmented block
369 frag_pointed1 = ((uintptr_t) (ADDR2UINT (address_pointed1) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed1].type;
370 frag_pointed2 = ((uintptr_t) (ADDR2UINT (address_pointed2) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed2].type;
372 fprintf(stderr, "Fragments pointed : %d - %d\n", frag_pointed1, frag_pointed2);
374 addr_frag_pointed1 = (char*)addr_block_pointed1 + (frag_pointed1 * (int)pow(2, heapinfo1[block_pointed1].type));
375 addr_frag_pointed2 = (char*)addr_block_pointed2 + (frag_pointed2 * (int)pow(2, heapinfo2[block_pointed2].type));
377 fprintf(stderr, "Addr frag pointed : %p - %p\n", addr_frag_pointed1, addr_frag_pointed2);
379 fprintf(stderr, "Size used in fragments pointed : %d - %d\n", heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1], heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]);
381 if(heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1] == heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]){
383 if(memcmp(addr_frag_pointed1, addr_frag_pointed2, heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1]) != 0){
386 fprintf(stderr, "False difference detected\n");
396 if(((heapinfo1[block_pointed1].type == 0) && (heapinfo2[block_pointed2].type != 0)) || ((heapinfo1[block_pointed1].type != 0) && (heapinfo2[block_pointed2].type == 0))){
397 fprintf(stderr, "Pointers on blocks with different types \n");
401 frag_pointed1 = ((uintptr_t) (ADDR2UINT (address_pointed1) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed1].type;
402 frag_pointed2 = ((uintptr_t) (ADDR2UINT (address_pointed2) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed2].type;
404 fprintf(stderr, "Fragments pointed : %d - %d\n", frag_pointed1, frag_pointed2);
406 addr_frag_pointed1 = (char*)addr_block_pointed1 + (frag_pointed1 * (int)pow(2, heapinfo1[block_pointed1].type));
407 addr_frag_pointed2 = (char*)addr_block_pointed2 + (frag_pointed2 * (int)pow(2, heapinfo2[block_pointed2].type));
409 fprintf(stderr, "Addr frag pointed : %p - %p\n", addr_frag_pointed1, addr_frag_pointed2);
411 fprintf(stderr, "Size used in fragments pointed : %d - %d\n", heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1], heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]);
413 if(heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1] == heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]){
415 if(memcmp(addr_frag_pointed1, addr_frag_pointed2, heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1]) != 0){
418 fprintf(stderr, "False difference detected\n");
432 fprintf(stderr,"\nDifferent data in fragment %zu (size = %zu, size used = %hu) in block %zu \n", j, frag_size, heapinfo1[i].busy_frag.frag_size[j], i);
433 fprintf(stderr, "Hamming distance between fragments : %d\n", distance);
434 mmalloc_backtrace_fragment_display(heapinfo1, i, j);
435 mmalloc_backtrace_fragment_display(heapinfo2, i, j);
436 fprintf(stderr, "\n");
438 total_distance += distance;
447 }else{ /* free block */
458 fprintf(stderr, "Hamming distance between heap regions : %d\n", total_distance);
464 int compare_area(void *area1, void* area2, size_t size){
467 int i, pointer_align;
468 void *address_pointed1 = NULL, *address_pointed2 = NULL;
469 int block_pointed1, block_pointed2, frag_pointed1, frag_pointed2;
470 void *addr_block_pointed1 = NULL, *addr_block_pointed2 = NULL, *addr_frag_pointed1 = NULL, *addr_frag_pointed2 = NULL;
472 for(i=0; i<size; i++){
474 if(memcmp(((char *)area1) + i, ((char *)area2) + i, 1) != 0){
476 /* Check pointer difference */
477 pointer_align = (i / sizeof(void*)) * sizeof(void*);
478 address_pointed1 = *((void **)((char *)area1 + pointer_align));
479 address_pointed2 = *((void **)((char *)area2 + pointer_align));
481 /* Get pointed blocks number */
482 block_pointed1 = ((char*)address_pointed1 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
483 block_pointed2 = ((char*)address_pointed2 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
485 /* Check if valid blocks number */
486 if((char *)address_pointed1 < (char*)((struct mdesc*)s_heap)->heapbase || block_pointed1 > heapsize1 || block_pointed1 < 1 || (char *)address_pointed2 < (char*)((struct mdesc*)s_heap)->heapbase || block_pointed2 > heapsize2 || block_pointed2 < 1) {
487 fprintf(stderr, "Unknown pointer(s) ! \n");
493 /* Get address of pointed block in saved heaps */
494 addr_block_pointed1 = ((void*) (((ADDR2UINT((size_t)block_pointed1)) - 1) * BLOCKSIZE + (char*)heapbase1));
495 addr_block_pointed2 = ((void*) (((ADDR2UINT((size_t)block_pointed2)) - 1) * BLOCKSIZE + (char*)heapbase2));
497 if(heapinfo1[block_pointed1].type == heapinfo2[block_pointed2].type){ /* Same type of block (large or fragmented) */
499 if(heapinfo1[block_pointed1].type == 0){ /* Large block */
501 if(heapinfo1[block_pointed1].busy_block.busy_size == heapinfo2[block_pointed2].busy_block.busy_size){
503 if(compare_area(addr_block_pointed1, addr_block_pointed2, heapinfo1[block_pointed1].busy_block.busy_size) != 0){
504 /* FIXME : Check temp list of differences */
507 fprintf(stderr, "False difference detected\n");
511 /* FIXME : Add blocks in temp list of differences */
515 }else{ /* Fragmented block */
517 /* Get pointed fragments number */
518 frag_pointed1 = ((uintptr_t) (ADDR2UINT (address_pointed1) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed1].type;
519 frag_pointed2 = ((uintptr_t) (ADDR2UINT (address_pointed2) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed2].type;
521 /* Get address of pointed fragments in saved heaps */
522 addr_frag_pointed1 = (char*)addr_block_pointed1 + (frag_pointed1 * (int)pow(2, heapinfo1[block_pointed1].type));
523 addr_frag_pointed2 = (char*)addr_block_pointed2 + (frag_pointed2 * (int)pow(2, heapinfo2[block_pointed2].type));
525 if(heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1] == heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]){
527 if(compare_area(addr_frag_pointed1, addr_frag_pointed2, heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1]) != 0){
528 /* FIXME : Check in temp list of differences */
531 fprintf(stderr, "False difference detected\n");
535 /* FIXME : Check in temp list of differences */
541 }else{ /* Can be fragmented block with different fragments size but same size_used */
543 if(((heapinfo1[block_pointed1].type == 0) && (heapinfo2[block_pointed2].type != 0)) || ((heapinfo1[block_pointed1].type != 0) && (heapinfo2[block_pointed2].type == 0))){
545 fprintf(stderr, "Pointers on blocks with different types \n");
550 /* Get pointed fragments number */
551 frag_pointed1 = ((uintptr_t) (ADDR2UINT (address_pointed1) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed1].type;
552 frag_pointed2 = ((uintptr_t) (ADDR2UINT (address_pointed2) % (BLOCKSIZE))) >> ((struct mdesc*)s_heap)->heapinfo[block_pointed2].type;
554 /* Get address of pointed fragments in saved heaps */
555 addr_frag_pointed1 = (char*)addr_block_pointed1 + (frag_pointed1 * (int)pow(2, heapinfo1[block_pointed1].type));
556 addr_frag_pointed2 = (char*)addr_block_pointed2 + (frag_pointed2 * (int)pow(2, heapinfo2[block_pointed2].type));
558 if(heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1] == heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]){
560 if(compare_area(addr_frag_pointed1, addr_frag_pointed2, heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1]) != 0){
561 /* FIXME : Check temp list of differences */
564 fprintf(stderr, "False difference detected\n");
568 /* FIXME : Check list of differences */
583 /* void *get_end_addr_heap(void *heap){ */
585 /* FILE *fp; /\* File pointer to process's proc maps file *\/ */
586 /* char *line = NULL; /\* Temporal storage for each line that is readed *\/ */
587 /* ssize_t read; /\* Number of bytes readed *\/ */
588 /* size_t n = 0; /\* Amount of bytes to read by getline *\/ */
590 /* fp = fopen("/proc/self/maps", "r"); */
593 /* perror("fopen failed"); */
596 /* xbt_dynar_t lfields = NULL; */
597 /* xbt_dynar_t start_end = NULL; */
598 /* void *start_addr; */
599 /* void *end_addr; */
601 /* while ((read = getline(&line, &n, fp)) != -1) { */
603 /* xbt_str_trim(line, NULL); */
604 /* xbt_str_strip_spaces(line); */
605 /* lfields = xbt_str_split(line,NULL); */
607 /* start_end = xbt_str_split(xbt_dynar_get_as(lfields, 0, char*), "-"); */
608 /* start_addr = (void *) strtoul(xbt_dynar_get_as(start_end, 0, char*), NULL, 16); */
609 /* end_addr = (void *) strtoul(xbt_dynar_get_as(start_end, 1, char*), NULL, 16); */
611 /* if(start_addr == heap){ */
614 /* xbt_dynar_reset(lfields); */
615 /* xbt_free(lfields); */
616 /* xbt_dynar_reset(start_end); */
617 /* xbt_free(start_end); */
618 /* return end_addr; */
623 /* xbt_dynar_reset(lfields); */
624 /* xbt_free(lfields); */
625 /* xbt_dynar_reset(start_end); */
626 /* xbt_free(start_end); */