X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8b5a3bd2ffa7cff8ae4b0d67cac8c49a22bc673e..16365fb35791e405d690c88d8c0cd0b28ed10be5:/src/xbt/mmalloc/mm_diff.c diff --git a/src/xbt/mmalloc/mm_diff.c b/src/xbt/mmalloc/mm_diff.c index 42112bdaba..0a56adc95d 100644 --- a/src/xbt/mmalloc/mm_diff.c +++ b/src/xbt/mmalloc/mm_diff.c @@ -130,77 +130,19 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ int errors = 0; - /*if(mdp1->headersize != mdp2->headersize){ - fprintf(stderr, "Different size of the file header for the mapped files\n"); - return 1; - } - - if(mdp1->refcount != mdp2->refcount){ - fprintf(stderr, "Different number of processes that attached the heap\n"); - return 1; - } - - if(strcmp(mdp1->magic, mdp2->magic) != 0){ - fprintf(stderr,"Different magic number\n"); - return 1; - } - - if(mdp1->flags != mdp2->flags){ - fprintf(stderr,"Different flags\n"); - return 1; - } - - if(mdp1->heapsize != mdp2->heapsize){ - fprintf(stderr,"Different number of info entries\n"); - return 1; - } - - if(mdp1->heapbase != mdp2->heapbase){ - fprintf(stderr,"Different first block of the heap\n"); - return 1; - } - - if(mdp1->heapindex != mdp2->heapindex){ - fprintf(stderr,"Different index for the heap table : %zu - %zu\n", mdp1->heapindex, mdp2->heapindex); - return 1; - } - - if(mdp1->base != mdp2->base){ - fprintf(stderr,"Different base address of the memory region\n"); - return 1; - } - - if(mdp1->breakval != mdp2->breakval){ - fprintf(stderr,"Different current location in the memory region\n"); - return 1; - } - - if(mdp1->top != mdp2->top){ - fprintf(stderr,"Different end of the current location in the memory region\n"); - return 1; - } - if(mdp1->heaplimit != mdp2->heaplimit){ fprintf(stderr,"Different limit of valid info table indices\n"); return 1; } - if(mdp1->fd != mdp2->fd){ - fprintf(stderr,"Different file descriptor for the file to which this malloc heap is mapped\n"); - return 1; - } - - if(mdp1->version != mdp2->version){ - fprintf(stderr,"Different version of the mmalloc package\n"); - return 1; - }*/ - - void* s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - getpagesize(); void *heapbase1 = (char *)mdp1 + BLOCKSIZE; void *heapbase2 = (char *)mdp2 + BLOCKSIZE; + void * breakval1 = (char *)mdp1 + ((char *)mdp1->breakval - (char *)s_heap); + void * breakval2 = (char *)mdp2 + ((char *)mdp2->breakval - (char *)s_heap); + size_t i, j; void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2; size_t frag_size = 0; /* FIXME: arbitrary initialization */ @@ -228,7 +170,10 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ } addr_block1 = (char*)heapbase1 + ((i-1)*BLOCKSIZE); + xbt_assert(addr_block1 < breakval1, "Block address out of heap memory used"); + addr_block2 = (char*)heapbase2 + ((i-1)*BLOCKSIZE); + xbt_assert(addr_block2 < breakval2, "Block address out of heap memory used"); if(mdp1->heapinfo[i].type == 0){ /* busy large block */ @@ -305,9 +250,11 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ } }else{ + fprintf(stderr, "Pointers on blocks with different types \n"); distance++; } }else{ + fprintf(stderr, "Pointed addresses (%p - %p) not in std_heap\n", address_pointed1, address_pointed2); distance++; } @@ -321,6 +268,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ fprintf(stderr, "Hamming distance between blocks : %d\n", distance); mmalloc_backtrace_block_display(mdp1, i); mmalloc_backtrace_block_display(mdp2, i); + fprintf(stderr, "\n"); errors++; total_distance += distance; } @@ -359,8 +307,10 @@ 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); - addr_frag2 = (char *)addr_block2 + (j * frag_size); + xbt_assert(addr_frag1 < breakval1, "Fragment address out of heap memory used"); + addr_frag2 = (char *)addr_block2 + (j * frag_size); + xbt_assert(addr_frag1 < breakval1, "Fragment address out of heap memory used"); /* Hamming distance on different blocks */ distance = 0; @@ -418,9 +368,11 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ } } }else{ + fprintf(stderr, "Pointers on blocks with different types \n"); distance++; } }else{ + fprintf(stderr, "Pointed addresses (%p - %p) not in std_heap\n", address_pointed1, address_pointed2); distance++; } } @@ -432,6 +384,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){ fprintf(stderr, "Hamming distance between fragments : %d\n", distance); mmalloc_backtrace_fragment_display(mdp1, i, j); mmalloc_backtrace_fragment_display(mdp2, i, j); + fprintf(stderr, "\n"); errors++; total_distance += distance;