Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : get std_heap with mmalloc_get_current_heap instead of function argument
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Wed, 13 Jun 2012 13:26:47 +0000 (15:26 +0200)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Wed, 13 Jun 2012 13:26:47 +0000 (15:26 +0200)
include/xbt/mmalloc.h
src/mc/mc_liveness.c
src/mc/mc_private.h
src/xbt/mmalloc/mm_diff.c
src/xbt/mmalloc/mmprivate.h

index 71efba7..93ba1f5 100644 (file)
@@ -58,7 +58,7 @@ extern void mmalloc_display_info_heap(xbt_mheap_t h);
 void mmalloc_set_current_heap(xbt_mheap_t new_heap);
 xbt_mheap_t mmalloc_get_current_heap(void);
 
-int mmalloc_compare_heap(xbt_mheap_t mdp1, xbt_mheap_t mdp2, void* s_heap);
+int mmalloc_compare_heap(xbt_mheap_t mdp1, xbt_mheap_t mdp2);
 
 void mmalloc_backtrace_display(xbt_mheap_t mdp, void *addr);
 
index ad69283..66e290f 100644 (file)
@@ -65,7 +65,7 @@ int data_libsimgrid_region_compare(void *d1, void *d2, size_t size){
   return distance;
 }
 
-int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2, void* s_heap){
+int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
 
   
   if(s1->num_reg != s2->num_reg){
@@ -93,7 +93,7 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2, void* s_heap){
        XBT_INFO("Different start addr of heap (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
        errors++;
       }
-      if(mmalloc_compare_heap(s1->regions[i]->data, s2->regions[i]->data, s_heap)){
+      if(mmalloc_compare_heap(s1->regions[i]->data, s2->regions[i]->data)){
        XBT_INFO("Different heap (mmalloc_compare)");
        errors++; 
       }
@@ -174,7 +174,7 @@ int reached(xbt_state_t st){
          //XBT_INFO("Rdv points size %d - %d", xbt_dict_length(pair_test->rdv_points), xbt_dict_length(current_rdv_points));
          //if(xbt_dict_length(pair_test->rdv_points) == xbt_dict_length(current_rdv_points)){
          //if(rdv_points_compare(pair_test->rdv_points, current_rdv_points) == 0){
-         if(snapshot_compare(pair_test->system_state, sn, std_heap) == 0){
+         if(snapshot_compare(pair_test->system_state, sn) == 0){
           
            MC_free_snapshot(sn);
            xbt_dynar_reset(prop_ato);
@@ -573,7 +573,7 @@ int visited(xbt_state_t st, int sc){
       if(pair_test->search_cycle == sc) {
        if(automaton_state_compare(pair_test->automaton_state, st) == 0){
          if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
-           if(snapshot_compare(pair_test->system_state, sn, std_heap) == 0){
+           if(snapshot_compare(pair_test->system_state, sn) == 0){
            
              MC_free_snapshot(sn);
              xbt_dynar_reset(prop_ato);
@@ -1302,7 +1302,7 @@ XBT_TEST_UNIT("snapshots_comparison", test_compare_snapshot, "Comparison of snap
 
   MC_UNSET_RAW_MEM;
 
-  xbt_test_assert(snapshot_compare(snapshot1, snapshot2, std_heap, raw_heap) == 0, "Different consecutive snapshot");
+  xbt_test_assert(snapshot_compare(snapshot1, snapshot2) == 0, "Different consecutive snapshot");
   
 
 }
@@ -1331,7 +1331,7 @@ XBT_TEST_UNIT("snapshots_comparison2", test2_compare_snapshot, "Comparison of sn
 
   MC_UNSET_RAW_MEM;
 
-  xbt_test_assert(snapshot_compare(snapshot1, snapshot2, std_heap) != 0, "Same snapshot with new allocations");
+  xbt_test_assert(snapshot_compare(snapshot1, snapshot2) != 0, "Same snapshot with new allocations");
   
 
 }
index 4493561..a64ca64 100644 (file)
@@ -253,7 +253,7 @@ int reached(xbt_state_t st);
 void set_pair_reached(xbt_state_t st);
 int reached_hash(xbt_state_t st);
 void set_pair_reached_hash(xbt_state_t st);
-int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2, void* s_heap);
+int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2);
 int data_program_region_compare(void *d1, void *d2, size_t size);
 int data_libsimgrid_region_compare(void *d1, void *d2, size_t size);
 void MC_pair_delete(mc_pair_t pair);
index 498622f..6e54a5d 100644 (file)
@@ -112,20 +112,20 @@ void mmalloc_backtrace_fragment_display(xbt_mheap_t mdp, size_t block, size_t fr
   }
 }
 
-int mmalloc_compare_heap(xbt_mheap_t mdp1, xbt_mheap_t mdp2, void* s_heap){
+int mmalloc_compare_heap(xbt_mheap_t mdp1, xbt_mheap_t mdp2){
 
   if(mdp1 == NULL && mdp2 == NULL){
     fprintf(stderr, "Malloc descriptors null\n");
     return 0;
   }
 
-  int errors = mmalloc_compare_mdesc(mdp1, mdp2, s_heap);
+  int errors = mmalloc_compare_mdesc(mdp1, mdp2);
 
   return (errors > 0);
 
 }
 
-int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void* s_heap){
+int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2){
 
   int errors = 0;
 
@@ -196,6 +196,8 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void* s_heap){
 
   //void* heapbase1 = (char *)mdp1 + ((char *)mdp1->heapbase - (char *)s_heap);
   //void* heapbase2 = (char *)mdp2 + ((char *)mdp2->heapbase - (char *)s_heap);
+
+  xbt_mheap_t s_heap = mmalloc_get_current_heap();
     
   void *heapbase1 = (char *)mdp1 + BLOCKSIZE;
   void *heapbase2 = (char *)mdp2 + BLOCKSIZE;
@@ -264,7 +266,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void* s_heap){
          pointer_align = (k / sizeof(void*)) * sizeof(void*); 
          address_pointed1 = *((void **)((char *)addr_block1 + pointer_align));
          address_pointed2 = *((void **)((char *)addr_block2 + pointer_align));                            
-         if(((address_pointed1 > s_heap) && (address_pointed1 < end_heap)) && ((address_pointed2 > s_heap) && (address_pointed2 < end_heap))){
+         if(((address_pointed1 > (void *)s_heap) && (address_pointed1 < end_heap)) && ((address_pointed2 > (void *)s_heap) && (address_pointed2 < end_heap))){
            block_pointed1 = ((char*)address_pointed1 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
            block_pointed2 = ((char*)address_pointed2 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
            //fprintf(stderr, "Blocks pointed : %d - %d\n", block_pointed1, block_pointed2);
@@ -386,7 +388,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void* s_heap){
                pointer_align = (k / sizeof(void*)) * sizeof(void*);
                address_pointed1 = *((void **)((char *)addr_frag1 + pointer_align));
                address_pointed2 = *((void **)((char *)addr_frag2 + pointer_align));                               
-               if(((address_pointed1 > s_heap) && (address_pointed1 < end_heap)) && ((address_pointed2 > s_heap) && (address_pointed2 < end_heap))){
+               if(((address_pointed1 > (void *)s_heap) && (address_pointed1 < end_heap)) && ((address_pointed2 > (void *)s_heap) && (address_pointed2 < end_heap))){
                  block_pointed1 = ((char*)address_pointed1 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
                  block_pointed2 = ((char*)address_pointed2 - (char*)((struct mdesc*)s_heap)->heapbase) / BLOCKSIZE + 1;
                  //fprintf(stderr, "Blocks pointed : %d - %d\n", block_pointed1, block_pointed2);
@@ -482,7 +484,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void* s_heap){
 }
 
 
-void *get_end_addr_heap(void *s_heap){
+void *get_end_addr_heap(void *heap){
 
   FILE *fp;                     /* File pointer to process's proc maps file */
   char *line = NULL;            /* Temporal storage for each line that is readed */
@@ -510,7 +512,7 @@ void *get_end_addr_heap(void *s_heap){
     start_addr = (void *) strtoul(xbt_dynar_get_as(start_end, 0, char*), NULL, 16);
     end_addr = (void *) strtoul(xbt_dynar_get_as(start_end, 1, char*), NULL, 16);
 
-    if(start_addr == s_heap){
+    if(start_addr == heap){
       free(line);
       fclose(fp);
       xbt_dynar_reset(lfields);
index b3fcff6..1e2d6aa 100644 (file)
@@ -224,7 +224,7 @@ struct mdesc {
 
 };
 
-int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void* s_heap);
+int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2);
 
 void mmalloc_display_info(void *h);