Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Make s_mc_snapshot_stack::stack_frames a std::vector
[simgrid.git] / src / mc / mc_ignore.cpp
index a9f49f2..f1ac12e 100644 (file)
@@ -25,21 +25,23 @@ void MC_ignore_heap(void *address, size_t size)
   if (mc_mode != MC_MODE_CLIENT)
     return;
 
+  xbt_mheap_t heap = mmalloc_get_current_heap();
+
   s_mc_heap_ignore_region_t region;
   memset(&region, 0, sizeof(region));
   region.address = address;
   region.size = size;
   region.block =
    ((char *) address -
-    (char *) std_heap->heapbase) / BLOCKSIZE + 1;
-  if (std_heap->heapinfo[region.block].type == 0) {
+    (char *) heap->heapbase) / BLOCKSIZE + 1;
+  if (heap->heapinfo[region.block].type == 0) {
     region.fragment = -1;
-    std_heap->heapinfo[region.block].busy_block.ignore++;
+    heap->heapinfo[region.block].busy_block.ignore++;
   } else {
     region.fragment =
-        ((uintptr_t) (ADDR2UINT(address) % (BLOCKSIZE))) >> std_heap->
-        heapinfo[region.block].type;
-    std_heap->heapinfo[region.block].busy_frag.ignore[region.fragment]++;
+        ((uintptr_t) (ADDR2UINT(address) % (BLOCKSIZE))) >>
+        heap->heapinfo[region.block].type;
+    heap->heapinfo[region.block].busy_frag.ignore[region.fragment]++;
   }
 
   s_mc_ignore_heap_message_t message;
@@ -67,17 +69,6 @@ void MC_ignore_global_variable(const char *name)
   xbt_die("Unimplemented");
 }
 
-// *****
-
-extern xbt_dynar_t stacks_areas;
-
-void MC_stack_area_add(stack_region_t stack_area)
-{
-  if (stacks_areas == NULL)
-    stacks_areas = xbt_dynar_new(sizeof(stack_region_t), NULL);
-  xbt_dynar_push(stacks_areas, &stack_area);
-}
-
 /** @brief Register a stack in the model checker
  *
  *  The stacks are allocated in the heap. The MC handle them especially
@@ -89,34 +80,32 @@ void MC_stack_area_add(stack_region_t stack_area)
  *  @param context
  *  @param size    Size of the stack
  */
-void MC_new_stack_area(void *stack, smx_process_t process, void *context, size_t size)
+void MC_register_stack_area(void *stack, smx_process_t process, void *context, size_t size)
 {
-  xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
+  if (mc_mode != MC_MODE_CLIENT)
+    return;
 
-  stack_region_t region = xbt_new0(s_stack_region_t, 1);
-  region->address = stack;
-  region->context = context;
-  region->size = size;
-  region->block =
+  xbt_mheap_t heap = mmalloc_get_current_heap();
+
+  s_stack_region_t region;
+  memset(&region, 0, sizeof(region));
+  region.address = stack;
+  region.context = context;
+  region.size = size;
+  region.block =
       ((char *) stack -
-       (char *) std_heap->heapbase) / BLOCKSIZE + 1;
+       (char *) heap->heapbase) / BLOCKSIZE + 1;
 #ifdef HAVE_SMPI
   if (smpi_privatize_global_variables && process) {
-    region->process_index = smpi_process_index_of_smx_process(process);
+    region.process_index = smpi_process_index_of_smx_process(process);
   } else
 #endif
-  region->process_index = -1;
+  region.process_index = -1;
 
-  if (mc_mode == MC_MODE_CLIENT) {
-    s_mc_stack_region_message_t message;
-    message.type = MC_MESSAGE_STACK_REGION;
-    message.stack_region = *region;
-    MC_client_send_message(&message, sizeof(message));
-  }
-
-  MC_stack_area_add(region);
-
-  mmalloc_set_current_heap(heap);
+  s_mc_stack_region_message_t message;
+  message.type = MC_MESSAGE_STACK_REGION;
+  message.stack_region = region;
+  MC_client_send_message(&message, sizeof(message));
 }
 
 }