X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d9af5d6fa719c7b91b887ad7fb6ccaf9a3313a89..0ab6b907319bfb2726f97ed2d21b9f4d6992ca86:/src/mc/mc_diff.c diff --git a/src/mc/mc_diff.c b/src/mc/mc_diff.c index 9748eeeef3..1c606b7db6 100644 --- a/src/mc/mc_diff.c +++ b/src/mc/mc_diff.c @@ -90,7 +90,8 @@ static void mmalloc_backtrace_display(void *addr) /* type = heap->heapinfo[block].type; */ /* switch(type){ */ - /* case -1 : /\* Free block *\/ */ + /* case MMALLOC_TYPE_HEAPINFO : */ + /* case MMALLOC_TYPE_FREE : /\* Free block *\/ */ /* fprintf(stderr, "Asked to display the backtrace of a block that is free. I'm puzzled\n"); */ /* xbt_abort(); */ /* break; */ @@ -444,16 +445,21 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) malloc_info* heapinfo1 = mc_snapshot_read_region(&heapinfos1[i1], heap_region1, &heapinfo_temp1, sizeof(malloc_info)); malloc_info* heapinfo2 = mc_snapshot_read_region(&heapinfos2[i1], heap_region2, &heapinfo_temp2, sizeof(malloc_info)); - if (heapinfo1->type == -1) { /* Free block */ - i1++; + if (heapinfo1->type == MMALLOC_TYPE_FREE || heapinfo1->type == MMALLOC_TYPE_HEAPINFO) { /* Free block */ + i1 += heapinfo1->free_block.size; continue; } + if (heapinfo1->type < 0) { + fprintf(stderr, "Unkown mmalloc block type.\n"); + abort(); + } + addr_block1 = ((void *) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char *) ((xbt_mheap_t) state->s_heap)->heapbase)); - if (heapinfo1->type == 0) { /* Large block */ + if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED) { /* Large block */ if (is_stack(addr_block1)) { for (k = 0; k < heapinfo1->busy_block.size; k++) @@ -512,7 +518,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) malloc_info* heapinfo2b = mc_snapshot_read_region(&heapinfos2[i2], heap_region2, &heapinfo_temp2b, sizeof(malloc_info)); - if (heapinfo2b->type != 0) { + if (heapinfo2b->type != MMALLOC_TYPE_UNFRAGMENTED) { i2++; continue; } @@ -589,11 +595,17 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) while (i2 <= state->heaplimit && !equal) { malloc_info* heapinfo2b = mc_snapshot_read_region(&heapinfos2[i2], heap_region2, &heapinfo_temp2b, sizeof(malloc_info)); - if (heapinfo2b->type <= 0) { - i2++; + + if (heapinfo2b->type == MMALLOC_TYPE_FREE || heapinfo2b->type == MMALLOC_TYPE_HEAPINFO) { + i2 += heapinfo2b->free_block.size; continue; } + if (heapinfo2b->type < 0) { + fprintf(stderr, "Unkown mmalloc block type.\n"); + abort(); + } + for (j2 = 0; j2 < (size_t) (BLOCKSIZE >> heapinfo2b->type); j2++) { @@ -649,7 +661,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) for(i = 1; i <= state->heaplimit; i++) { malloc_info* heapinfo1 = mc_snapshot_read_region(&heapinfos1[i], heap_region1, &heapinfo_temp1, sizeof(malloc_info)); - if (heapinfo1->type == 0) { + if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED) { if (i1 == state->heaplimit) { if (heapinfo1->busy_block.busy_size > 0) { if (state->equals_to1_(i, 0).valid == 0) { @@ -690,7 +702,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) for (i=1; i <= state->heaplimit; i++) { malloc_info* heapinfo2 = mc_snapshot_read_region(&heapinfos2[i], heap_region2, &heapinfo_temp2, sizeof(malloc_info)); - if (heapinfo2->type == 0) { + if (heapinfo2->type == MMALLOC_TYPE_UNFRAGMENTED) { if (i1 == state->heaplimit) { if (heapinfo2->busy_block.busy_size > 0) { if (state->equals_to2_(i, 0).valid == 0) { @@ -1193,15 +1205,19 @@ int compare_heap_area(void *area1, void *area2, mc_snapshot_t snapshot1, malloc_info* heapinfo1 = mc_snapshot_read_region(&heapinfos1[block1], heap_region1, &heapinfo_temp1, sizeof(malloc_info)); malloc_info* heapinfo2 = mc_snapshot_read_region(&heapinfos2[block2], heap_region2, &heapinfo_temp2, sizeof(malloc_info)); - if ((heapinfo1->type == -1) && (heapinfo2->type == -1)) { /* Free block */ + if ((heapinfo1->type == MMALLOC_TYPE_FREE || heapinfo1->type==MMALLOC_TYPE_HEAPINFO) + && (heapinfo2->type == MMALLOC_TYPE_FREE || heapinfo2->type ==MMALLOC_TYPE_HEAPINFO)) { + /* Free block */ if (match_pairs) { match_equals(state, previous); xbt_dynar_free(&previous); } return 0; - } else if ((heapinfo1->type == 0) && (heapinfo2->type == 0)) { /* Complete block */ + } else if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED + && heapinfo2->type == MMALLOC_TYPE_UNFRAGMENTED) { + /* Complete block */ // TODO, lookup variable type from block type as done for fragmented blocks @@ -1512,9 +1528,9 @@ static int get_pointed_area_size(void *area, int heap) || (block > state->heapsize1) || (block < 1)) return -1; - if (heapinfo[block].type == -1) { /* Free block */ + if (heapinfo[block].type == MMALLOC_TYPE_FREE || heapinfo[block].type == MMALLOC_TYPE_HEAPINFO) { /* Free block */ return -1; - } else if (heapinfo[block].type == 0) { /* Complete block */ + } else if (heapinfo[block].type == MMALLOC_TYPE_UNFRAGMENTED) { /* Complete block */ return (int) heapinfo[block].busy_block.busy_size; } else { frag = @@ -1615,12 +1631,13 @@ int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2) } else { - if (state->heapinfo1[i].type == -1) { /* Free block */ + if (state->heapinfo1[i].type == MMALLOC_TYPE_FREE + || state->heapinfo1[i].type == MMALLOC_TYPE_HAPINFO) { /* Free block */ i++; continue; } - if (state->heapinfo1[i].type == 0) { /* Large block */ + if (state->heapinfo1[i].type == MMALLOC_TYPE_UNFRAGMENTED) { /* Large block */ if (state->heapinfo1[i].busy_block.size != state->heapinfo2[i].busy_block.size) {