1 /* mc_diff - Memory snapshooting and comparison */
3 /* Copyright (c) 2008-2014. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "xbt/ex_interface.h" /* internals of backtrace setup */
12 #include "xbt/mmalloc.h"
13 #include "mc/datatypes.h"
14 #include "mc/mc_private.h"
16 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_diff, xbt,
17 "Logging specific to mc_diff in mc");
19 xbt_dynar_t mc_heap_comparison_ignore;
20 xbt_dynar_t stacks_areas;
21 void *maestro_stack_start, *maestro_stack_end;
24 /********************************* Backtrace ***********************************/
25 /******************************************************************************/
27 static void mmalloc_backtrace_block_display(void *heapinfo, int block)
32 /* if (((malloc_info *)heapinfo)[block].busy_block.bt_size == 0) { */
33 /* fprintf(stderr, "No backtrace available for that block, sorry.\n"); */
37 /* memcpy(&e.bt,&(((malloc_info *)heapinfo)[block].busy_block.bt),sizeof(void*)*XBT_BACKTRACE_SIZE); */
38 /* e.used = ((malloc_info *)heapinfo)[block].busy_block.bt_size; */
40 /* xbt_ex_setup_backtrace(&e); */
41 /* if (e.used == 0) { */
42 /* fprintf(stderr, "(backtrace not set)\n"); */
43 /* } else if (e.bt_strings == NULL) { */
44 /* fprintf(stderr, "(backtrace not ready to be computed. %s)\n",xbt_binary_name?"Dunno why":"xbt_binary_name not setup yet"); */
48 /* fprintf(stderr, "Backtrace of where the block %d was malloced (%d frames):\n", block ,e.used); */
49 /* for (i = 0; i < e.used; i++) /\* no need to display "xbt_backtrace_display" *\/{ */
50 /* fprintf(stderr, "%d ---> %s\n",i, e.bt_strings[i] + 4); */
55 static void mmalloc_backtrace_fragment_display(void *heapinfo, int block,
61 /* memcpy(&e.bt,&(((malloc_info *)heapinfo)[block].busy_frag.bt[frag]),sizeof(void*)*XBT_BACKTRACE_SIZE); */
62 /* e.used = XBT_BACKTRACE_SIZE; */
64 /* xbt_ex_setup_backtrace(&e); */
65 /* if (e.used == 0) { */
66 /* fprintf(stderr, "(backtrace not set)\n"); */
67 /* } else if (e.bt_strings == NULL) { */
68 /* fprintf(stderr, "(backtrace not ready to be computed. %s)\n",xbt_binary_name?"Dunno why":"xbt_binary_name not setup yet"); */
72 /* fprintf(stderr, "Backtrace of where the fragment %d in block %d was malloced (%d frames):\n", frag, block ,e.used); */
73 /* for (i = 0; i < e.used; i++) /\* no need to display "xbt_backtrace_display" *\/{ */
74 /* fprintf(stderr, "%d ---> %s\n",i, e.bt_strings[i] + 4); */
80 static void mmalloc_backtrace_display(void *addr)
83 /* size_t block, frag_nb; */
86 /* xbt_mheap_t heap = __mmalloc_current_heap ?: (xbt_mheap_t) mmalloc_preinit(); */
88 /* block = (((char*) (addr) - (char*) heap -> heapbase) / BLOCKSIZE + 1); */
90 /* type = heap->heapinfo[block].type; */
93 /* case -1 : /\* Free block *\/ */
94 /* fprintf(stderr, "Asked to display the backtrace of a block that is free. I'm puzzled\n"); */
97 /* case 0: /\* Large block *\/ */
98 /* mmalloc_backtrace_block_display(heap->heapinfo, block); */
100 /* default: /\* Fragmented block *\/ */
101 /* frag_nb = RESIDUAL(addr, BLOCKSIZE) >> type; */
102 /* if(heap->heapinfo[block].busy_frag.frag_size[frag_nb] == -1){ */
103 /* fprintf(stderr , "Asked to display the backtrace of a fragment that is free. I'm puzzled\n"); */
106 /* mmalloc_backtrace_fragment_display(heap->heapinfo, block, frag_nb); */
112 static int compare_backtrace(int b1, int f1, int b2, int f2)
116 for(i=0; i< XBT_BACKTRACE_SIZE; i++){
117 if(heapinfo1[b1].busy_frag.bt[f1][i] != heapinfo2[b2].busy_frag.bt[f2][i]){
118 //mmalloc_backtrace_fragment_display((void*)heapinfo1, b1, f1);
119 //mmalloc_backtrace_fragment_display((void*)heapinfo2, b2, f2);
124 for(i=0; i< heapinfo1[b1].busy_block.bt_size; i++){
125 if(heapinfo1[b1].busy_block.bt[i] != heapinfo2[b2].busy_block.bt[i]){
126 //mmalloc_backtrace_block_display((void*)heapinfo1, b1);
127 //mmalloc_backtrace_block_display((void*)heapinfo2, b2);
136 /*********************************** Heap comparison ***********************************/
137 /***************************************************************************************/
139 typedef char *type_name;
142 /** \brief Base address of the real heap */
145 // Number of blocks in the heaps:
146 size_t heapsize1, heapsize2;
147 xbt_dynar_t to_ignore1, to_ignore2;
148 s_heap_area_t *equals_to1, *equals_to2;
149 dw_type_t *types1, *types2;
153 #define equals_to1_(i,j) equals_to1[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
154 #define equals_to2_(i,j) equals_to2[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
155 #define types1_(i,j) types1[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
156 #define types2_(i,j) types2[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
158 __thread struct s_mc_diff *mc_diff_info = NULL;
160 /*********************************** Free functions ************************************/
162 static void heap_area_pair_free(heap_area_pair_t pair)
168 static void heap_area_pair_free_voidp(void *d)
170 heap_area_pair_free((heap_area_pair_t) * (void **) d);
173 static void heap_area_free(heap_area_t area)
179 /************************************************************************************/
181 static s_heap_area_t make_heap_area(int block, int fragment)
186 area.fragment = fragment;
191 static int is_new_heap_area_pair(xbt_dynar_t list, int block1, int fragment1,
192 int block2, int fragment2)
195 unsigned int cursor = 0;
196 heap_area_pair_t current_pair;
198 xbt_dynar_foreach(list, cursor, current_pair) {
199 if (current_pair->block1 == block1 && current_pair->block2 == block2
200 && current_pair->fragment1 == fragment1
201 && current_pair->fragment2 == fragment2)
208 static int add_heap_area_pair(xbt_dynar_t list, int block1, int fragment1,
209 int block2, int fragment2)
212 if (is_new_heap_area_pair(list, block1, fragment1, block2, fragment2)) {
213 heap_area_pair_t pair = NULL;
214 pair = xbt_new0(s_heap_area_pair_t, 1);
215 pair->block1 = block1;
216 pair->fragment1 = fragment1;
217 pair->block2 = block2;
218 pair->fragment2 = fragment2;
220 xbt_dynar_push(list, &pair);
228 static ssize_t heap_comparison_ignore_size(xbt_dynar_t ignore_list,
232 unsigned int cursor = 0;
234 int end = xbt_dynar_length(ignore_list) - 1;
235 mc_heap_ignore_region_t region;
237 while (start <= end) {
238 cursor = (start + end) / 2;
240 (mc_heap_ignore_region_t) xbt_dynar_get_as(ignore_list, cursor,
241 mc_heap_ignore_region_t);
242 if (region->address == address)
244 if (region->address < address)
246 if (region->address > address)
253 static int is_stack(void *address)
255 unsigned int cursor = 0;
256 stack_region_t stack;
258 xbt_dynar_foreach(stacks_areas, cursor, stack) {
259 if (address == stack->address)
266 // TODO, this should depend on the snapshot?
267 static int is_block_stack(int block)
269 unsigned int cursor = 0;
270 stack_region_t stack;
272 xbt_dynar_foreach(stacks_areas, cursor, stack) {
273 if (block == stack->block)
280 static void match_equals(struct s_mc_diff *state, xbt_dynar_t list)
283 unsigned int cursor = 0;
284 heap_area_pair_t current_pair;
286 xbt_dynar_foreach(list, cursor, current_pair) {
288 if (current_pair->fragment1 != -1) {
290 state->equals_to1_(current_pair->block1, current_pair->fragment1) =
291 make_heap_area(current_pair->block2, current_pair->fragment2);
292 state->equals_to2_(current_pair->block2, current_pair->fragment2) =
293 make_heap_area(current_pair->block1, current_pair->fragment1);
297 state->equals_to1_(current_pair->block1, 0) =
298 make_heap_area(current_pair->block2, current_pair->fragment2);
299 state->equals_to2_(current_pair->block2, 0) =
300 make_heap_area(current_pair->block1, current_pair->fragment1);
307 /** Check whether two blocks are known to be matching
309 * @param state State used
310 * @param b1 Block of state 1
311 * @param b2 Block of state 2
312 * @return if the blocks are known to be matching
314 static int equal_blocks(struct s_mc_diff *state, int b1, int b2)
317 if (state->equals_to1_(b1, 0).block == b2
318 && state->equals_to2_(b2, 0).block == b1)
324 /** Check whether two fragments are known to be matching
326 * @param state State used
327 * @param b1 Block of state 1
328 * @param f1 Fragment of state 1
329 * @param b2 Block of state 2
330 * @param f2 Fragment of state 2
331 * @return if the fragments are known to be matching
333 static int equal_fragments(struct s_mc_diff *state, int b1, int f1, int b2,
337 if (state->equals_to1_(b1, f1).block == b2
338 && state->equals_to1_(b1, f1).fragment == f2
339 && state->equals_to2_(b2, f2).block == b1
340 && state->equals_to2_(b2, f2).fragment == f1)
346 int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t i1,
349 if (mc_diff_info == NULL) {
350 mc_diff_info = xbt_new0(struct s_mc_diff, 1);
351 mc_diff_info->equals_to1 = NULL;
352 mc_diff_info->equals_to2 = NULL;
353 mc_diff_info->types1 = NULL;
354 mc_diff_info->types2 = NULL;
356 struct s_mc_diff *state = mc_diff_info;
358 if ((((struct mdesc *) heap1)->heaplimit !=
359 ((struct mdesc *) heap2)->heaplimit)
361 ((((struct mdesc *) heap1)->heapsize !=
362 ((struct mdesc *) heap2)->heapsize)))
365 state->heaplimit = ((struct mdesc *) heap1)->heaplimit;
367 // Mamailloute in order to find the base address of the main heap:
369 (char *) mmalloc_get_current_heap() - STD_HEAP_SIZE - xbt_pagesize;
371 state->heapsize1 = heap1->heapsize;
372 state->heapsize2 = heap2->heapsize;
374 state->to_ignore1 = i1;
375 state->to_ignore2 = i2;
377 if (state->heaplimit > state->available) {
379 realloc(state->equals_to1,
380 state->heaplimit * MAX_FRAGMENT_PER_BLOCK *
381 sizeof(s_heap_area_t));
383 realloc(state->types1,
384 state->heaplimit * MAX_FRAGMENT_PER_BLOCK *
385 sizeof(type_name *));
387 realloc(state->equals_to2,
388 state->heaplimit * MAX_FRAGMENT_PER_BLOCK *
389 sizeof(s_heap_area_t));
391 realloc(state->types2,
392 state->heaplimit * MAX_FRAGMENT_PER_BLOCK *
393 sizeof(type_name *));
394 state->available = state->heaplimit;
397 memset(state->equals_to1, 0,
398 state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t));
399 memset(state->equals_to2, 0,
400 state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t));
401 memset(state->types1, 0,
402 state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *));
403 memset(state->types2, 0,
404 state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *));
410 void reset_heap_information()
415 int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2)
418 struct s_mc_diff *state = mc_diff_info;
420 /* Start comparison */
421 size_t i1, i2, j1, j2, k;
422 void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2;
423 int nb_diff1 = 0, nb_diff2 = 0;
425 int equal, res_compare = 0;
427 /* Check busy blocks */
431 malloc_info heapinfo_temp1, heapinfo_temp2;
432 malloc_info heapinfo_temp2b;
434 mc_mem_region_t heap_region1 = snapshot1->regions[0];
435 mc_mem_region_t heap_region2 = snapshot2->regions[0];
437 // This is in snapshot do not use them directly:
438 malloc_info* heapinfos1 = mc_snapshot_read_pointer(&((xbt_mheap_t)std_heap)->heapinfo, snapshot1);
439 malloc_info* heapinfos2 = mc_snapshot_read_pointer(&((xbt_mheap_t)std_heap)->heapinfo, snapshot2);
441 while (i1 <= state->heaplimit) {
443 // TODO, lookup in the correct region in order to speed it up:
444 malloc_info* heapinfo1 = mc_snapshot_read_region(&heapinfos1[i1], heap_region1, &heapinfo_temp1, sizeof(malloc_info));
445 malloc_info* heapinfo2 = mc_snapshot_read_region(&heapinfos2[i1], heap_region2, &heapinfo_temp2, sizeof(malloc_info));
447 if (heapinfo1->type == -1) { /* Free block */
453 ((void *) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE +
454 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
456 if (heapinfo1->type == 0) { /* Large block */
458 if (is_stack(addr_block1)) {
459 for (k = 0; k < heapinfo1->busy_block.size; k++)
460 state->equals_to1_(i1 + k, 0) = make_heap_area(i1, -1);
461 for (k = 0; k < heapinfo2->busy_block.size; k++)
462 state->equals_to2_(i1 + k, 0) = make_heap_area(i1, -1);
463 i1 += heapinfo1->busy_block.size;
467 if (state->equals_to1_(i1, 0).valid) {
476 /* Try first to associate to same block in the other heap */
477 if (heapinfo2->type == heapinfo1->type) {
479 if (state->equals_to2_(i1, 0).valid == 0) {
482 ((void *) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE +
483 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
486 compare_heap_area(addr_block1, addr_block2, snapshot1, snapshot2,
489 if (res_compare != 1) {
490 for (k = 1; k < heapinfo2->busy_block.size; k++)
491 state->equals_to2_(i1 + k, 0) = make_heap_area(i1, -1);
492 for (k = 1; k < heapinfo1->busy_block.size; k++)
493 state->equals_to1_(i1 + k, 0) = make_heap_area(i1, -1);
495 i1 += heapinfo1->busy_block.size;
502 while (i2 <= state->heaplimit && !equal) {
505 ((void *) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE +
506 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
513 malloc_info* heapinfo2b = mc_snapshot_read_region(&heapinfos2[i2], heap_region2, &heapinfo_temp2b, sizeof(malloc_info));
515 if (heapinfo2b->type != 0) {
520 if (state->equals_to2_(i2, 0).valid) {
526 compare_heap_area(addr_block1, addr_block2, snapshot1, snapshot2,
529 if (res_compare != 1) {
530 for (k = 1; k < heapinfo2b->busy_block.size; k++)
531 state->equals_to2_(i2 + k, 0) = make_heap_area(i1, -1);
532 for (k = 1; k < heapinfo1->busy_block.size; k++)
533 state->equals_to1_(i1 + k, 0) = make_heap_area(i2, -1);
535 i1 += heapinfo1->busy_block.size;
543 XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1,
544 heapinfo1->busy_block.busy_size, addr_block1);
545 i1 = state->heaplimit + 1;
550 } else { /* Fragmented block */
552 for (j1 = 0; j1 < (size_t) (BLOCKSIZE >> heapinfo1->type); j1++) {
554 if (heapinfo1->busy_frag.frag_size[j1] == -1) /* Free fragment */
557 if (state->equals_to1_(i1, j1).valid)
561 (void *) ((char *) addr_block1 + (j1 << heapinfo1->type));
566 /* Try first to associate to same fragment in the other heap */
567 if (heapinfo2->type == heapinfo1->type) {
569 if (state->equals_to2_(i1, j1).valid == 0) {
572 ((void *) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE +
573 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
575 (void *) ((char *) addr_block2 +
576 (j1 << heapinfo2->type));
579 compare_heap_area(addr_frag1, addr_frag2, snapshot1, snapshot2,
582 if (res_compare != 1)
589 while (i2 <= state->heaplimit && !equal) {
591 malloc_info* heapinfo2b = mc_snapshot_read_region(&heapinfos2[i2], heap_region2, &heapinfo_temp2b, sizeof(malloc_info));
592 if (heapinfo2b->type <= 0) {
597 for (j2 = 0; j2 < (size_t) (BLOCKSIZE >> heapinfo2b->type);
600 if (i2 == i1 && j2 == j1)
603 if (state->equals_to2_(i2, j2).valid)
607 ((void *) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE +
608 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
610 (void *) ((char *) addr_block2 +
611 (j2 << heapinfo2b->type));
614 compare_heap_area(addr_frag1, addr_frag2, snapshot2, snapshot2,
617 if (res_compare != 1) {
630 ("Block %zu, fragment %zu not found (size_used = %zd, address = %p)\n",
631 i1, j1, heapinfo1->busy_frag.frag_size[j1],
633 i2 = state->heaplimit + 1;
634 i1 = state->heaplimit + 1;
647 /* All blocks/fragments are equal to another block/fragment ? */
650 for(i = 1; i <= state->heaplimit; i++) {
651 malloc_info* heapinfo1 = mc_snapshot_read_region(&heapinfos1[i], heap_region1, &heapinfo_temp1, sizeof(malloc_info));
652 if (heapinfo1->type == 0) {
653 if (i1 == state->heaplimit) {
654 if (heapinfo1->busy_block.busy_size > 0) {
655 if (state->equals_to1_(i, 0).valid == 0) {
656 if (XBT_LOG_ISENABLED(mc_diff, xbt_log_priority_debug)) {
658 XBT_DEBUG("Block %zu not found (size used = %zu)", i,
659 heapinfo1->busy_block.busy_size);
660 //mmalloc_backtrace_block_display((void*)heapinfo1, i);
667 if (heapinfo1->type > 0) {
668 for (j = 0; j < (size_t) (BLOCKSIZE >> heapinfo1->type); j++) {
669 if (i1 == state->heaplimit) {
670 if (heapinfo1->busy_frag.frag_size[j] > 0) {
671 if (state->equals_to1_(i, j).valid == 0) {
672 if (XBT_LOG_ISENABLED(mc_diff, xbt_log_priority_debug)) {
673 // TODO, print fragment address
675 ("Block %zu, Fragment %zu not found (size used = %zd)",
677 heapinfo1->busy_frag.frag_size[j]);
678 //mmalloc_backtrace_fragment_display((void*)heapinfo1, i, j);
688 if (i1 == state->heaplimit)
689 XBT_DEBUG("Number of blocks/fragments not found in heap1 : %d", nb_diff1);
691 for (i=1; i <= state->heaplimit; i++) {
692 malloc_info* heapinfo2 = mc_snapshot_read_region(&heapinfos2[i], heap_region2, &heapinfo_temp2, sizeof(malloc_info));
693 if (heapinfo2->type == 0) {
694 if (i1 == state->heaplimit) {
695 if (heapinfo2->busy_block.busy_size > 0) {
696 if (state->equals_to2_(i, 0).valid == 0) {
697 if (XBT_LOG_ISENABLED(mc_diff, xbt_log_priority_debug)) {
698 // TODO, print address of the block
699 XBT_DEBUG("Block %zu not found (size used = %zu)", i,
700 heapinfo2->busy_block.busy_size);
701 //mmalloc_backtrace_block_display((void*)heapinfo2, i);
708 if (heapinfo2->type > 0) {
709 for (j = 0; j < (size_t) (BLOCKSIZE >> heapinfo2->type); j++) {
710 if (i1 == state->heaplimit) {
711 if (heapinfo2->busy_frag.frag_size[j] > 0) {
712 if (state->equals_to2_(i, j).valid == 0) {
713 if (XBT_LOG_ISENABLED(mc_diff, xbt_log_priority_debug)) {
714 // TODO, print address of the block
716 ("Block %zu, Fragment %zu not found (size used = %zd)",
718 heapinfo2->busy_frag.frag_size[j]);
719 //mmalloc_backtrace_fragment_display((void*)heapinfo2, i, j);
729 if (i1 == state->heaplimit)
730 XBT_DEBUG("Number of blocks/fragments not found in heap2 : %d", nb_diff2);
732 return ((nb_diff1 > 0) || (nb_diff2 > 0));
738 * @param real_area1 Process address for state 1
739 * @param real_area2 Process address for state 2
740 * @param snapshot1 Snapshot of state 1
741 * @param snapshot2 Snapshot of state 2
744 * @param check_ignore
746 static int compare_heap_area_without_type(struct s_mc_diff *state,
747 void *real_area1, void *real_area2,
748 mc_snapshot_t snapshot1,
749 mc_snapshot_t snapshot2,
750 xbt_dynar_t previous, int size,
755 void *addr_pointed1, *addr_pointed2;
756 int pointer_align, res_compare;
757 ssize_t ignore1, ignore2;
759 mc_mem_region_t heap_region1 = snapshot1->regions[0];
760 mc_mem_region_t heap_region2 = snapshot2->regions[0];
764 if (check_ignore > 0) {
766 heap_comparison_ignore_size(state->to_ignore1,
767 (char *) real_area1 + i)) != -1) {
769 heap_comparison_ignore_size(state->to_ignore2,
770 (char *) real_area2 + i)) == ignore1) {
783 if (mc_snapshot_region_memcmp(((char *) real_area1) + i, heap_region1, ((char *) real_area2) + i, heap_region2, 1) != 0) {
785 pointer_align = (i / sizeof(void *)) * sizeof(void *);
786 addr_pointed1 = mc_snapshot_read_pointer((char *) real_area1 + pointer_align, snapshot1);
787 addr_pointed2 = mc_snapshot_read_pointer((char *) real_area2 + pointer_align, snapshot2);
789 if (addr_pointed1 > maestro_stack_start
790 && addr_pointed1 < maestro_stack_end
791 && addr_pointed2 > maestro_stack_start
792 && addr_pointed2 < maestro_stack_end) {
793 i = pointer_align + sizeof(void *);
795 } else if (addr_pointed1 > state->s_heap
796 && addr_pointed1 < mc_snapshot_get_heap_end(snapshot1)
797 && addr_pointed2 > state->s_heap
798 && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2)) {
799 // Both addreses are in the heap:
801 compare_heap_area(addr_pointed1, addr_pointed2, snapshot1,
802 snapshot2, previous, NULL, 0);
803 if (res_compare == 1) {
806 i = pointer_align + sizeof(void *);
825 * @param real_area1 Process address for state 1
826 * @param real_area2 Process address for state 2
827 * @param snapshot1 Snapshot of state 1
828 * @param snapshot2 Snapshot of state 2
831 * @param area_size either a byte_size or an elements_count (?)
832 * @param check_ignore
833 * @param pointer_level
834 * @return 0 (same), 1 (different), -1 (unknown)
836 static int compare_heap_area_with_type(struct s_mc_diff *state,
837 void *real_area1, void *real_area2,
838 mc_snapshot_t snapshot1,
839 mc_snapshot_t snapshot2,
840 xbt_dynar_t previous, dw_type_t type,
841 int area_size, int check_ignore,
845 if (is_stack(real_area1) && is_stack(real_area2))
848 ssize_t ignore1, ignore2;
850 if ((check_ignore > 0)
851 && ((ignore1 = heap_comparison_ignore_size(state->to_ignore1, real_area1))
853 && ((ignore2 = heap_comparison_ignore_size(state->to_ignore2, real_area2))
858 dw_type_t subtype, subsubtype;
859 int res, elm_size, i;
860 unsigned int cursor = 0;
862 void *addr_pointed1, *addr_pointed2;;
864 mc_mem_region_t heap_region1 = snapshot1->regions[0];
865 mc_mem_region_t heap_region2 = snapshot2->regions[0];
867 switch (type->type) {
868 case DW_TAG_unspecified_type:
871 case DW_TAG_base_type:
872 if (type->name != NULL && strcmp(type->name, "char") == 0) { /* String, hence random (arbitrary ?) size */
873 if (real_area1 == real_area2)
876 return (mc_snapshot_region_memcmp(real_area1, heap_region1, real_area2, heap_region2, area_size) != 0);
878 if (area_size != -1 && type->byte_size != area_size)
881 return (mc_snapshot_region_memcmp(real_area1, heap_region1, real_area2, heap_region2, type->byte_size) != 0);
885 case DW_TAG_enumeration_type:
886 if (area_size != -1 && type->byte_size != area_size)
889 return (mc_snapshot_region_memcmp(real_area1, heap_region1, real_area2, heap_region2, type->byte_size) != 0);
892 case DW_TAG_const_type:
893 case DW_TAG_volatile_type:
895 type = type->subtype;
898 case DW_TAG_array_type:
899 subtype = type->subtype;
900 switch (subtype->type) {
901 case DW_TAG_unspecified_type:
904 case DW_TAG_base_type:
905 case DW_TAG_enumeration_type:
906 case DW_TAG_pointer_type:
907 case DW_TAG_reference_type:
908 case DW_TAG_rvalue_reference_type:
909 case DW_TAG_structure_type:
910 case DW_TAG_class_type:
911 case DW_TAG_union_type:
912 if (subtype->full_type)
913 subtype = subtype->full_type;
914 elm_size = subtype->byte_size;
916 // TODO, just remove the type indirection?
917 case DW_TAG_const_type:
919 case DW_TAG_volatile_type:
920 subsubtype = subtype->subtype;
921 if (subsubtype->full_type)
922 subsubtype = subsubtype->full_type;
923 elm_size = subsubtype->byte_size;
929 for (i = 0; i < type->element_count; i++) {
930 // TODO, add support for variable stride (DW_AT_byte_stride)
932 compare_heap_area_with_type(state,
933 (char *) real_area1 + (i * elm_size),
934 (char *) real_area2 + (i * elm_size),
935 snapshot1, snapshot2, previous,
936 type->subtype, subtype->byte_size,
937 check_ignore, pointer_level);
942 case DW_TAG_reference_type:
943 case DW_TAG_rvalue_reference_type:
944 case DW_TAG_pointer_type:
945 if (type->subtype && type->subtype->type == DW_TAG_subroutine_type) {
946 addr_pointed1 = mc_snapshot_read_pointer(real_area1, snapshot1);
947 addr_pointed2 = mc_snapshot_read_pointer(real_area2, snapshot2);
948 return (addr_pointed1 != addr_pointed2);;
951 if (pointer_level > 1) { /* Array of pointers */
952 for (i = 0; i < (area_size / sizeof(void *)); i++) {
953 addr_pointed1 = mc_snapshot_read_pointer((char*) real_area1 + i * sizeof(void *), snapshot1);
954 addr_pointed2 = mc_snapshot_read_pointer((char*) real_area2 + i * sizeof(void *), snapshot2);
955 if (addr_pointed1 > state->s_heap
956 && addr_pointed1 < mc_snapshot_get_heap_end(snapshot1)
957 && addr_pointed2 > state->s_heap
958 && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2))
960 compare_heap_area(addr_pointed1, addr_pointed2, snapshot1,
961 snapshot2, previous, type->subtype,
964 res = (addr_pointed1 != addr_pointed2);
969 addr_pointed1 = mc_snapshot_read_pointer(real_area1, snapshot1);
970 addr_pointed2 = mc_snapshot_read_pointer(real_area2, snapshot2);
971 if (addr_pointed1 > state->s_heap
972 && addr_pointed1 < mc_snapshot_get_heap_end(snapshot1)
973 && addr_pointed2 > state->s_heap
974 && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2))
975 return compare_heap_area(addr_pointed1, addr_pointed2, snapshot1,
976 snapshot2, previous, type->subtype,
979 return (addr_pointed1 != addr_pointed2);
983 case DW_TAG_structure_type:
984 case DW_TAG_class_type:
986 type = type->full_type;
987 if (area_size != -1 && type->byte_size != area_size) {
988 if (area_size > type->byte_size && area_size % type->byte_size == 0) {
989 for (i = 0; i < (area_size / type->byte_size); i++) {
991 compare_heap_area_with_type(state,
992 (char *) real_area1 + i * type->byte_size,
993 (char *) real_area2 + i * type->byte_size,
994 snapshot1, snapshot2, previous, type, -1,
1004 xbt_dynar_foreach(type->members, cursor, member) {
1005 // TODO, optimize this? (for the offset case)
1006 char *real_member1 =
1007 mc_member_resolve(real_area1, type, member, snapshot1);
1008 char *real_member2 =
1009 mc_member_resolve(real_area2, type, member, snapshot2);
1011 compare_heap_area_with_type(state, real_member1, real_member2,
1012 snapshot1, snapshot2,
1013 previous, member->subtype, -1,
1021 case DW_TAG_union_type:
1022 return compare_heap_area_without_type(state, real_area1, real_area2,
1023 snapshot1, snapshot2, previous,
1024 type->byte_size, check_ignore);
1034 /** Infer the type of a part of the block from the type of the block
1036 * TODO, handle DW_TAG_array_type as well as arrays of the object ((*p)[5], p[5])
1038 * TODO, handle subfields ((*p).bar.foo, (*p)[5].bar…)
1040 * @param type_id DWARF type ID of the root address
1042 * @return DWARF type ID for given offset
1044 static dw_type_t get_offset_type(void *real_base_address, dw_type_t type,
1045 int offset, int area_size,
1046 mc_snapshot_t snapshot)
1049 // Beginning of the block, the infered variable type if the type of the block:
1053 switch (type->type) {
1054 case DW_TAG_structure_type:
1055 case DW_TAG_class_type:
1056 if (type->full_type)
1057 type = type->full_type;
1059 if (area_size != -1 && type->byte_size != area_size) {
1060 if (area_size > type->byte_size && area_size % type->byte_size == 0)
1065 unsigned int cursor = 0;
1067 xbt_dynar_foreach(type->members, cursor, member) {
1069 if (!member->location.size) {
1070 // We have the offset, use it directly (shortcut):
1071 if (member->offset == offset)
1072 return member->subtype;
1075 mc_member_resolve(real_base_address, type, member, snapshot);
1076 if (real_member - (char *) real_base_address == offset)
1077 return member->subtype;
1085 /* FIXME : other cases ? */
1093 * @param area1 Process address for state 1
1094 * @param area2 Process address for state 2
1095 * @param snapshot1 Snapshot of state 1
1096 * @param snapshot2 Snapshot of state 2
1097 * @param previous Pairs of blocks already compared on the current path (or NULL)
1098 * @param type_id Type of variable
1099 * @param pointer_level
1100 * @return 0 (same), 1 (different), -1
1102 int compare_heap_area(void *area1, void *area2, mc_snapshot_t snapshot1,
1103 mc_snapshot_t snapshot2, xbt_dynar_t previous,
1104 dw_type_t type, int pointer_level)
1107 struct s_mc_diff *state = mc_diff_info;
1110 ssize_t block1, frag1, block2, frag2;
1112 int check_ignore = 0;
1114 void *real_addr_block1, *real_addr_block2, *real_addr_frag1, *real_addr_frag2;
1116 int offset1 = 0, offset2 = 0;
1117 int new_size1 = -1, new_size2 = -1;
1118 dw_type_t new_type1 = NULL, new_type2 = NULL;
1120 int match_pairs = 0;
1122 malloc_info* heapinfos1 = mc_snapshot_read_pointer(&((xbt_mheap_t)std_heap)->heapinfo, snapshot1);
1123 malloc_info* heapinfos2 = mc_snapshot_read_pointer(&((xbt_mheap_t)std_heap)->heapinfo, snapshot2);
1125 malloc_info heapinfo_temp1, heapinfo_temp2;
1127 void* real_area1_to_compare = area1;
1128 void* real_area2_to_compare = area2;
1130 if (previous == NULL) {
1132 xbt_dynar_new(sizeof(heap_area_pair_t), heap_area_pair_free_voidp);
1135 // Get block number:
1138 (char *) ((xbt_mheap_t) state->s_heap)->heapbase) / BLOCKSIZE + 1;
1141 (char *) ((xbt_mheap_t) state->s_heap)->heapbase) / BLOCKSIZE + 1;
1143 // If either block is a stack block:
1144 if (is_block_stack((int) block1) && is_block_stack((int) block2)) {
1145 add_heap_area_pair(previous, block1, -1, block2, -1);
1147 match_equals(state, previous);
1148 xbt_dynar_free(&previous);
1152 // If either block is not in the expected area of memory:
1153 if (((char *) area1 < (char *) ((xbt_mheap_t) state->s_heap)->heapbase)
1154 || (block1 > state->heapsize1) || (block1 < 1)
1155 || ((char *) area2 < (char *) ((xbt_mheap_t) state->s_heap)->heapbase)
1156 || (block2 > state->heapsize2) || (block2 < 1)) {
1158 xbt_dynar_free(&previous);
1163 // Process address of the block:
1165 ((void *) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE +
1166 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
1168 ((void *) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE +
1169 (char *) ((xbt_mheap_t) state->s_heap)->heapbase));
1173 if (type->full_type)
1174 type = type->full_type;
1176 // This assume that for "boring" types (volatile ...) byte_size is absent:
1177 while (type->byte_size == 0 && type->subtype != NULL)
1178 type = type->subtype;
1181 if ((type->type == DW_TAG_pointer_type)
1182 || ((type->type == DW_TAG_base_type) && type->name != NULL
1183 && (!strcmp(type->name, "char"))))
1186 type_size = type->byte_size;
1190 mc_mem_region_t heap_region1 = snapshot1->regions[0];
1191 mc_mem_region_t heap_region2 = snapshot2->regions[0];
1193 malloc_info* heapinfo1 = mc_snapshot_read_region(&heapinfos1[block1], heap_region1, &heapinfo_temp1, sizeof(malloc_info));
1194 malloc_info* heapinfo2 = mc_snapshot_read_region(&heapinfos2[block2], heap_region2, &heapinfo_temp2, sizeof(malloc_info));
1196 if ((heapinfo1->type == -1) && (heapinfo2->type == -1)) { /* Free block */
1199 match_equals(state, previous);
1200 xbt_dynar_free(&previous);
1204 } else if ((heapinfo1->type == 0) && (heapinfo2->type == 0)) { /* Complete block */
1206 // TODO, lookup variable type from block type as done for fragmented blocks
1208 offset1 = (char *) area1 - (char *) real_addr_block1;
1209 offset2 = (char *) area2 - (char *) real_addr_block2;
1211 if (state->equals_to1_(block1, 0).valid
1212 && state->equals_to2_(block2, 0).valid) {
1213 if (equal_blocks(state, block1, block2)) {
1215 match_equals(state, previous);
1216 xbt_dynar_free(&previous);
1222 if (type_size != -1) {
1223 if (type_size != heapinfo1->busy_block.busy_size
1224 && type_size != heapinfo2->busy_block.busy_size
1225 && (type->name == NULL || !strcmp(type->name, "struct s_smx_context"))) {
1227 match_equals(state, previous);
1228 xbt_dynar_free(&previous);
1234 if (heapinfo1->busy_block.size !=
1235 heapinfo2->busy_block.size) {
1237 xbt_dynar_free(&previous);
1242 if (heapinfo1->busy_block.busy_size !=
1243 heapinfo2->busy_block.busy_size) {
1245 xbt_dynar_free(&previous);
1250 if (!add_heap_area_pair(previous, block1, -1, block2, -1)) {
1252 match_equals(state, previous);
1253 xbt_dynar_free(&previous);
1258 size = heapinfo1->busy_block.busy_size;
1260 // Remember (basic) type inference.
1261 // The current data structure only allows us to do this for the whole block.
1262 if (type != NULL && area1 == real_addr_block1) {
1263 state->types1_(block1, 0) = type;
1265 if (type != NULL && area2 == real_addr_block2) {
1266 state->types2_(block2, 0) = type;
1271 match_equals(state, previous);
1272 xbt_dynar_free(&previous);
1280 if ((heapinfo1->busy_block.ignore > 0)
1281 && (heapinfo2->busy_block.ignore ==
1282 heapinfo1->busy_block.ignore))
1283 check_ignore = heapinfo1->busy_block.ignore;
1285 } else if ((heapinfo1->type > 0) && (heapinfo2->type > 0)) { /* Fragmented block */
1289 ((uintptr_t) (ADDR2UINT(area1) % (BLOCKSIZE))) >> heapinfo1->type;
1291 ((uintptr_t) (ADDR2UINT(area2) % (BLOCKSIZE))) >> heapinfo2->type;
1293 // Process address of the fragment:
1295 (void *) ((char *) real_addr_block1 +
1296 (frag1 << heapinfo1->type));
1298 (void *) ((char *) real_addr_block2 +
1299 (frag2 << heapinfo2->type));
1301 // Check the size of the fragments against the size of the type:
1302 if (type_size != -1) {
1303 if (heapinfo1->busy_frag.frag_size[frag1] == -1
1304 || heapinfo2->busy_frag.frag_size[frag2] == -1) {
1306 match_equals(state, previous);
1307 xbt_dynar_free(&previous);
1312 if (type_size != heapinfo1->busy_frag.frag_size[frag1]
1313 || type_size != heapinfo2->busy_frag.frag_size[frag2]) {
1315 match_equals(state, previous);
1316 xbt_dynar_free(&previous);
1322 // Check if the blocks are already matched together:
1323 if (state->equals_to1_(block1, frag1).valid
1324 && state->equals_to2_(block2, frag2).valid) {
1325 if (offset1==offset2 && equal_fragments(state, block1, frag1, block2, frag2)) {
1327 match_equals(state, previous);
1328 xbt_dynar_free(&previous);
1333 // Compare the size of both fragments:
1334 if (heapinfo1->busy_frag.frag_size[frag1] !=
1335 heapinfo2->busy_frag.frag_size[frag2]) {
1336 if (type_size == -1) {
1338 match_equals(state, previous);
1339 xbt_dynar_free(&previous);
1344 xbt_dynar_free(&previous);
1350 // Size of the fragment:
1351 size = heapinfo1->busy_frag.frag_size[frag1];
1353 // Remember (basic) type inference.
1354 // The current data structure only allows us to do this for the whole fragment.
1355 if (type != NULL && area1 == real_addr_frag1) {
1356 state->types1_(block1, frag1) = type;
1358 if (type != NULL && area2 == real_addr_frag2) {
1359 state->types2_(block2, frag2) = type;
1361 // The type of the variable is already known:
1366 // Type inference from the block type.
1367 else if (state->types1_(block1, frag1) != NULL
1368 || state->types2_(block2, frag2) != NULL) {
1370 offset1 = (char *) area1 - (char *) real_addr_frag1;
1371 offset2 = (char *) area2 - (char *) real_addr_frag2;
1373 if (state->types1_(block1, frag1) != NULL
1374 && state->types2_(block2, frag2) != NULL) {
1376 get_offset_type(real_addr_frag1, state->types1_(block1, frag1),
1377 offset1, size, snapshot1);
1379 get_offset_type(real_addr_frag2, state->types2_(block2, frag2),
1380 offset1, size, snapshot2);
1381 } else if (state->types1_(block1, frag1) != NULL) {
1383 get_offset_type(real_addr_frag1, state->types1_(block1, frag1),
1384 offset1, size, snapshot1);
1386 get_offset_type(real_addr_frag2, state->types1_(block1, frag1),
1387 offset2, size, snapshot2);
1388 } else if (state->types2_(block2, frag2) != NULL) {
1390 get_offset_type(real_addr_frag1, state->types2_(block2, frag2),
1391 offset1, size, snapshot1);
1393 get_offset_type(real_addr_frag2, state->types2_(block2, frag2),
1394 offset2, size, snapshot2);
1397 match_equals(state, previous);
1398 xbt_dynar_free(&previous);
1403 if (new_type1 != NULL && new_type2 != NULL && new_type1 != new_type2) {
1406 while (type->byte_size == 0 && type->subtype != NULL)
1407 type = type->subtype;
1408 new_size1 = type->byte_size;
1411 while (type->byte_size == 0 && type->subtype != NULL)
1412 type = type->subtype;
1413 new_size2 = type->byte_size;
1417 match_equals(state, previous);
1418 xbt_dynar_free(&previous);
1424 if (new_size1 > 0 && new_size1 == new_size2) {
1429 if (offset1 == 0 && offset2 == 0) {
1430 if (!add_heap_area_pair(previous, block1, frag1, block2, frag2)) {
1432 match_equals(state, previous);
1433 xbt_dynar_free(&previous);
1441 match_equals(state, previous);
1442 xbt_dynar_free(&previous);
1447 if ((heapinfo1->busy_frag.ignore[frag1] > 0)
1448 && (heapinfo2->busy_frag.ignore[frag2] ==
1449 heapinfo1->busy_frag.ignore[frag1]))
1450 check_ignore = heapinfo1->busy_frag.ignore[frag1];
1455 xbt_dynar_free(&previous);
1462 /* Start comparison */
1465 compare_heap_area_with_type(state, real_area1_to_compare, real_area2_to_compare, snapshot1, snapshot2,
1466 previous, type, size, check_ignore,
1470 compare_heap_area_without_type(state, real_area1_to_compare, real_area2_to_compare, snapshot1, snapshot2,
1471 previous, size, check_ignore);
1473 if (res_compare == 1) {
1475 xbt_dynar_free(&previous);
1480 match_equals(state, previous);
1481 xbt_dynar_free(&previous);
1487 /*********************************************** Miscellaneous ***************************************************/
1488 /****************************************************************************************************************/
1490 // Not used and broken code:
1494 static int get_pointed_area_size(void *area, int heap)
1497 struct s_mc_diff *state = mc_diff_info;
1500 malloc_info *heapinfo;
1503 heapinfo = state->heapinfo1;
1505 heapinfo = state->heapinfo2;
1509 (char *) ((xbt_mheap_t) state->s_heap)->heapbase) / BLOCKSIZE + 1;
1511 if (((char *) area < (char *) ((xbt_mheap_t) state->s_heap)->heapbase)
1512 || (block > state->heapsize1) || (block < 1))
1515 if (heapinfo[block].type == -1) { /* Free block */
1517 } else if (heapinfo[block].type == 0) { /* Complete block */
1518 return (int) heapinfo[block].busy_block.busy_size;
1521 ((uintptr_t) (ADDR2UINT(area) % (BLOCKSIZE))) >> heapinfo[block].type;
1522 return (int) heapinfo[block].busy_frag.frag_size[frag];
1527 char *get_type_description(mc_object_info_t info, char *type_name)
1530 xbt_dict_cursor_t dict_cursor;
1534 xbt_dict_foreach(info->types, dict_cursor, type_origin, type) {
1535 if (type->name && (strcmp(type->name, type_name) == 0)
1536 && type->byte_size > 0) {
1537 xbt_dict_cursor_free(&dict_cursor);
1542 xbt_dict_cursor_free(&dict_cursor);
1548 #define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
1552 int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2)
1555 struct s_mc_diff *state = mc_diff_info;
1557 if (heap1 == NULL && heap1 == NULL) {
1558 XBT_DEBUG("Malloc descriptors null");
1562 if (heap1->heaplimit != heap2->heaplimit) {
1563 XBT_DEBUG("Different limit of valid info table indices");
1567 /* Heap information */
1568 state->heaplimit = ((struct mdesc *) heap1)->heaplimit;
1571 // Mamailloute in order to find the base address of the main heap:
1573 (char *) mmalloc_get_current_heap() - STD_HEAP_SIZE - xbt_pagesize;
1575 state->heapbase1 = (char *) heap1 + BLOCKSIZE;
1576 state->heapbase2 = (char *) heap2 + BLOCKSIZE;
1579 (malloc_info *) ((char *) heap1 +
1581 ((char *) heap1->heapinfo - (char *) state->s_heap)));
1583 (malloc_info *) ((char *) heap2 +
1585 ((char *) heap2->heapinfo - (char *) state->s_heap)));
1587 state->heapsize1 = heap1->heapsize;
1588 state->heapsize2 = heap2->heapsize;
1590 /* Start comparison */
1592 void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2;
1596 /* Check busy blocks */
1600 while (i <= state->heaplimit) {
1603 ((void *) (((ADDR2UINT(i)) - 1) * BLOCKSIZE +
1604 (char *) state->heapbase1));
1606 ((void *) (((ADDR2UINT(i)) - 1) * BLOCKSIZE +
1607 (char *) state->heapbase2));
1609 if (state->heapinfo1[i].type != state->heapinfo2[i].type) {
1611 distance += BLOCKSIZE;
1612 XBT_DEBUG("Different type of blocks (%zu) : %d - %d -> distance = %d", i,
1613 state->heapinfo1[i].type, state->heapinfo2[i].type, distance);
1618 if (state->heapinfo1[i].type == -1) { /* Free block */
1623 if (state->heapinfo1[i].type == 0) { /* Large block */
1625 if (state->heapinfo1[i].busy_block.size !=
1626 state->heapinfo2[i].busy_block.size) {
1628 BLOCKSIZE * max(state->heapinfo1[i].busy_block.size,
1629 state->heapinfo2[i].busy_block.size);
1630 i += max(state->heapinfo1[i].busy_block.size,
1631 state->heapinfo2[i].busy_block.size);
1633 ("Different larger of cluster at block %zu : %zu - %zu -> distance = %d",
1634 i, state->heapinfo1[i].busy_block.size,
1635 state->heapinfo2[i].busy_block.size, distance);
1639 /*if(heapinfo1[i].busy_block.busy_size != heapinfo2[i].busy_block.busy_size){
1640 distance += max(heapinfo1[i].busy_block.busy_size, heapinfo2[i].busy_block.busy_size);
1641 i += max(heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size);
1642 XBT_DEBUG("Different size used oin large cluster at block %zu : %zu - %zu -> distance = %d", i, heapinfo1[i].busy_block.busy_size, heapinfo2[i].busy_block.busy_size, distance);
1648 //while(k < (heapinfo1[i].busy_block.busy_size)){
1649 while (k < state->heapinfo1[i].busy_block.size * BLOCKSIZE) {
1650 if (memcmp((char *) addr_block1 + k, (char *) addr_block2 + k, 1) !=
1659 } else { /* Fragmented block */
1661 for (j = 0; j < (size_t) (BLOCKSIZE >> state->heapinfo1[i].type); j++) {
1664 (void *) ((char *) addr_block1 + (j << state->heapinfo1[i].type));
1666 (void *) ((char *) addr_block2 + (j << state->heapinfo2[i].type));
1668 if (state->heapinfo1[i].busy_frag.frag_size[j] == 0
1669 && state->heapinfo2[i].busy_frag.frag_size[j] == 0) {
1674 /*if(heapinfo1[i].busy_frag.frag_size[j] != heapinfo2[i].busy_frag.frag_size[j]){
1675 distance += max(heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j]);
1676 XBT_DEBUG("Different size used in fragment %zu in block %zu : %d - %d -> distance = %d", j, i, heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j], distance);
1682 //while(k < max(heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j])){
1683 while (k < (BLOCKSIZE / (BLOCKSIZE >> state->heapinfo1[i].type))) {
1684 if (memcmp((char *) addr_frag1 + k, (char *) addr_frag2 + k, 1) !=