X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8a80a7488d5a9c1b57d287f939a310ee63c27583..9f15834456c85d37c5a58753f4c034f64bfe0f39:/src/xbt/mmalloc/mm_diff.c diff --git a/src/xbt/mmalloc/mm_diff.c b/src/xbt/mmalloc/mm_diff.c index a101947507..1a2a5eedda 100644 --- a/src/xbt/mmalloc/mm_diff.c +++ b/src/xbt/mmalloc/mm_diff.c @@ -91,7 +91,7 @@ void mmalloc_backtrace_block_display(xbt_mheap_t mdp, size_t block){ } void mmalloc_backtrace_fragment_display(xbt_mheap_t mdp, size_t block, size_t frag){ - + xbt_ex_t e; memcpy(&e.bt,&(mdp->heapinfo[block].busy_frag.bt[frag]),sizeof(void*)*XBT_BACKTRACE_SIZE); @@ -136,7 +136,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ } void* s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - getpagesize(); - + void *heapbase1 = (char *)mdp1 + BLOCKSIZE; void *heapbase2 = (char *)mdp2 + BLOCKSIZE; @@ -180,15 +180,14 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ fprintf(stderr,"Different size of a large cluster : %zu - %zu\n", mdp1->heapinfo[i].busy_block.size, mdp2->heapinfo[i].busy_block.size); fflush(NULL); errors++; - } + } if(mdp1->heapinfo[i].busy_block.busy_size != mdp2->heapinfo[i].busy_block.busy_size){ fprintf(stderr,"Different busy_size of a large cluster : %zu - %zu\n", mdp1->heapinfo[i].busy_block.busy_size, mdp2->heapinfo[i].busy_block.busy_size); fflush(NULL); errors++; - } + } - /* Hamming distance on different blocks */ distance = 0; @@ -199,7 +198,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ fprintf(stderr, "Different byte (offset=%d) (%p - %p) in block %zu\n", k, (char *)addr_block1 + k, (char *)addr_block2 + k, i); fflush(NULL); pointer_align = (k / sizeof(void*)) * sizeof(void*); address_pointed1 = *((void **)((char *)addr_block1 + pointer_align)); - address_pointed2 = *((void **)((char *)addr_block2 + pointer_align)); + address_pointed2 = *((void **)((char *)addr_block2 + pointer_align)); if(((address_pointed1 > (void *)s_heap) && (address_pointed1 < mdp1->breakval)) && ((address_pointed2 > (void *)s_heap) && (address_pointed2 < mdp2->breakval))){ block_pointed1 = ((char*)address_pointed1 - (char*)((struct mdesc*)s_heap)->heapbase) % BLOCKSIZE; block_pointed2 = ((char*)address_pointed2 - (char*)((struct mdesc*)s_heap)->heapbase) % BLOCKSIZE; @@ -239,7 +238,6 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ fprintf(stderr, "Pointers on blocks with different types \n"); distance++; } - }else{ /* FIXME : peut pointer vers le début d'un fragment mais dans un bloc */ fprintf(stderr, "Pointed addresses (%p - %p) not valid\n", address_pointed1, address_pointed2); @@ -249,7 +247,6 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ fprintf(stderr, "Pointed addresses (%p - %p) not in std_heap\n", address_pointed1, address_pointed2); distance++; } - } } } @@ -262,15 +259,14 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ mmalloc_backtrace_block_display(mdp1, i); mmalloc_backtrace_block_display(mdp2, i); fprintf(stderr, "\n"); - errors++; + errors++; total_distance += distance; } - - + i++; - + }else{ - + if(mdp1->heapinfo[i].type > 0){ /* busy fragmented block */ if(mdp1->heapinfo[i].type != mdp2->heapinfo[i].type){ @@ -281,12 +277,12 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ if(mdp1->heapinfo[i].busy_frag.nfree != mdp2->heapinfo[i].busy_frag.nfree){ fprintf(stderr,"Different free fragments in fragmented block %zu : %zu - %zu\n", i, mdp1->heapinfo[i].busy_frag.nfree, mdp2->heapinfo[i].busy_frag.nfree); fflush(NULL); errors++; - } - + } + if(mdp1->heapinfo[i].busy_frag.first != mdp2->heapinfo[i].busy_frag.first){ fprintf(stderr,"Different busy_size of a large cluster : %zu - %zu\n", mdp1->heapinfo[i].busy_block.busy_size, mdp2->heapinfo[i].busy_block.busy_size); fflush(NULL); errors++; - } + } frag_size = pow(2, mdp1->heapinfo[i].type); @@ -298,7 +294,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ } if(mdp1->heapinfo[i].busy_frag.frag_size[j] > 0){ - + addr_frag1 = (char *)addr_block1 + (j * frag_size); xbt_assert(addr_frag1 < breakval1, "Fragment address out of heap memory used"); @@ -314,7 +310,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ 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); pointer_align = (k / sizeof(void*)) * sizeof(void*); address_pointed1 = *((void **)((char *)addr_frag1 + pointer_align)); - address_pointed2 = *((void **)((char *)addr_frag2 + pointer_align)); + address_pointed2 = *((void **)((char *)addr_frag2 + pointer_align)); if(((address_pointed1 > (void *)s_heap) && (address_pointed1 < mdp1->breakval)) && ((address_pointed2 > (void *)s_heap) && (address_pointed2 < mdp2->breakval))){ block_pointed1 = ((char*)address_pointed1 - (char*)((struct mdesc*)s_heap)->heapbase) % BLOCKSIZE; block_pointed2 = ((char*)address_pointed2 - (char*)((struct mdesc*)s_heap)->heapbase) % BLOCKSIZE; @@ -365,7 +361,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ } } - + if(distance > 0){ fprintf(stderr,"\nDifferent data in fragment %zu (size = %zu, size used = %hu) in block %zu \n", j, frag_size, mdp1->heapinfo[i].busy_frag.frag_size[j], i); fprintf(stderr, "Hamming distance between fragments : %d\n", distance); @@ -374,7 +370,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ fprintf(stderr, "\n"); errors++; total_distance += distance; - + } } @@ -387,7 +383,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ i++; } - + } } @@ -407,7 +403,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ /* size_t n = 0; /\* Amount of bytes to read by getline *\/ */ /* fp = fopen("/proc/self/maps", "r"); */ - + /* if(fp == NULL) */ /* perror("fopen failed"); */