+ return 0;
+
+}
+
+
+static int compare_heap_area_with_type(void *real_area1, void *real_area2, void *area1, void *area2,
+ xbt_dynar_t previous, xbt_dict_t all_types, xbt_dict_t other_types, char *type_id,
+ int area_size, int check_ignore, int pointer_level){
+
+ if(is_stack(real_area1) && is_stack(real_area2))
+ return 0;
+
+ size_t ignore1, ignore2;
+
+ if((check_ignore > 0) && ((ignore1 = heap_comparison_ignore_size(to_ignore1, real_area1)) > 0) && ((ignore2 = heap_comparison_ignore_size(to_ignore2, real_area2)) == ignore1)){
+ return 0;
+ }
+
+ dw_type_t type = xbt_dict_get_or_null(all_types, type_id);
+ dw_type_t subtype, subsubtype;
+ int res, elm_size, i, switch_types = 0;
+ unsigned int cursor = 0;
+ dw_type_t member;
+ void *addr_pointed1, *addr_pointed2;;
+ char *type_desc;
+
+ switch(type->type){
+ case e_dw_base_type:
+ if(strcmp(type->name, "char") == 0){ /* String, hence random (arbitrary ?) size */
+ if(real_area1 == real_area2)
+ return -1;
+ else
+ return (memcmp(area1, area2, area_size) != 0);
+ }else{
+ if(area_size != -1 && type->size != area_size)
+ return -1;
+ else{
+ return (memcmp(area1, area2, type->size) != 0);
+ }
+ }
+ break;
+ case e_dw_enumeration_type:
+ if(area_size != -1 && type->size != area_size)
+ return -1;
+ else
+ return (memcmp(area1, area2, type->size) != 0);
+ break;
+ case e_dw_typedef:
+ return compare_heap_area_with_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->dw_type_id, area_size, check_ignore, pointer_level);
+ break;
+ case e_dw_const_type:
+ return 0;
+ break;
+ case e_dw_array_type:
+ subtype = xbt_dict_get_or_null(all_types, type->dw_type_id);
+ switch(subtype->type){
+ case e_dw_base_type:
+ case e_dw_enumeration_type:
+ case e_dw_pointer_type:
+ case e_dw_structure_type:
+ case e_dw_union_type:
+ if(subtype->size == 0){ /*declaration of the type, need the complete description */
+ type_desc = get_type_description(all_types, subtype->name);
+ if(type_desc){
+ subtype = xbt_dict_get_or_null(all_types, type_desc);
+ }else{
+ subtype = xbt_dict_get_or_null(other_types, get_type_description(other_types, subtype->name));
+ switch_types = 1;
+ }
+ }
+ elm_size = subtype->size;
+ break;
+ case e_dw_typedef:
+ case e_dw_volatile_type:
+ subsubtype = xbt_dict_get_or_null(all_types, subtype->dw_type_id);
+ if(subsubtype->size == 0){ /*declaration of the type, need the complete description */
+ type_desc = get_type_description(all_types, subsubtype->name);
+ if(type_desc){
+ subsubtype = xbt_dict_get_or_null(all_types, type_desc);
+ }else{
+ subsubtype = xbt_dict_get_or_null(other_types, get_type_description(other_types, subtype->name));
+ switch_types = 1;
+ }
+ }
+ elm_size = subsubtype->size;
+ break;
+ default :
+ return 0;
+ break;
+ }
+ for(i=0; i<type->size; i++){
+ if(switch_types)
+ res = compare_heap_area_with_type((char *)real_area1 + (i*elm_size), (char *)real_area2 + (i*elm_size), (char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), previous, other_types, all_types, type->dw_type_id, type->size, check_ignore, pointer_level);
+ else
+ res = compare_heap_area_with_type((char *)real_area1 + (i*elm_size), (char *)real_area2 + (i*elm_size), (char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), previous, all_types, other_types, type->dw_type_id, type->size, check_ignore, pointer_level);
+ if(res == 1)
+ return res;
+ }
+ break;
+ case e_dw_pointer_type:
+ if(type->dw_type_id && ((dw_type_t)xbt_dict_get_or_null(all_types, type->dw_type_id))->type == e_dw_subroutine_type){
+ addr_pointed1 = *((void **)(area1));
+ addr_pointed2 = *((void **)(area2));
+ return (addr_pointed1 != addr_pointed2);;
+ }else{
+ pointer_level++;
+ if(pointer_level > 1){ /* Array of pointers */
+ for(i=0; i<(area_size/sizeof(void *)); i++){
+ addr_pointed1 = *((void **)((char *)area1 + (i*sizeof(void *))));
+ addr_pointed2 = *((void **)((char *)area2 + (i*sizeof(void *))));
+ if(addr_pointed1 > s_heap && (char *)addr_pointed1 < (char*) s_heap + STD_HEAP_SIZE && addr_pointed2 > s_heap && (char *)addr_pointed2 < (char*) s_heap + STD_HEAP_SIZE)
+ res = compare_heap_area(addr_pointed1, addr_pointed2, previous, all_types, other_types, type->dw_type_id, pointer_level);
+ else
+ res = (addr_pointed1 != addr_pointed2);
+ if(res == 1)
+ return res;
+ }
+ }else{
+ addr_pointed1 = *((void **)(area1));
+ addr_pointed2 = *((void **)(area2));
+ if(addr_pointed1 > s_heap && (char *)addr_pointed1 < (char*) s_heap + STD_HEAP_SIZE && addr_pointed2 > s_heap && (char *)addr_pointed2 < (char*) s_heap + STD_HEAP_SIZE)
+ return compare_heap_area(addr_pointed1, addr_pointed2, previous, all_types, other_types, type->dw_type_id, pointer_level);
+ else
+ return (addr_pointed1 != addr_pointed2);
+ }
+ }
+ break;
+ case e_dw_structure_type:
+ if(type->size == 0){ /*declaration of the structure, need the complete description */
+ type_desc = get_type_description(all_types, type->name);
+ if(type_desc){
+ type = xbt_dict_get_or_null(all_types, type_desc);
+ }else{
+ type = xbt_dict_get_or_null(other_types, get_type_description(other_types, type->name));
+ switch_types = 1;
+ }
+ }
+ if(area_size != -1 && type->size != area_size){
+ if(area_size>type->size && area_size%type->size == 0){
+ for(i=0; i<(area_size/type->size); i++){
+ if(switch_types)
+ res = compare_heap_area_with_type((char *)real_area1 + (i*type->size), (char *)real_area2 + (i*type->size), (char *)area1 + (i*type->size), (char *)area2 + (i*type->size), previous, other_types, all_types, type_id, -1, check_ignore, 0);
+ else
+ res = compare_heap_area_with_type((char *)real_area1 + (i*type->size), (char *)real_area2 + (i*type->size), (char *)area1 + (i*type->size), (char *)area2 + (i*type->size), previous, all_types, other_types, type_id, -1, check_ignore, 0);
+ if(res == 1)
+ return res;
+ }
+ }else{
+ return -1;
+ }
+ }else{
+ cursor = 0;
+ xbt_dynar_foreach(type->members, cursor, member){
+ if(switch_types)
+ res = compare_heap_area_with_type((char *)real_area1 + member->offset, (char *)real_area2 + member->offset, (char *)area1 + member->offset, (char *)area2 + member->offset, previous, other_types, all_types, member->dw_type_id, -1, check_ignore, 0);
+ else
+ res = compare_heap_area_with_type((char *)real_area1 + member->offset, (char *)real_area2 + member->offset, (char *)area1 + member->offset, (char *)area2 + member->offset, previous, all_types, other_types, member->dw_type_id, -1, check_ignore, 0);
+ if(res == 1){
+ return res;
+ }
+ }
+ }
+ break;
+ case e_dw_union_type:
+ return compare_heap_area_without_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->size, check_ignore);
+ break;
+ case e_dw_volatile_type:
+ return compare_heap_area_with_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->dw_type_id, area_size, check_ignore, pointer_level);
+ break;
+ default:
+ break;