/* 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; */
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++)
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;
}
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++) {
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) {
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) {
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
|| (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 =
} 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) {