Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / src / mc / mc_ignore.cpp
index 250c9e4..6017779 100644 (file)
@@ -1,17 +1,17 @@
-/* Copyright (c) 2008-2014. The SimGrid Team.
+/* Copyright (c) 2008-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "internal_config.h"
-#include "mc_object_info.h"
-#include "mc_private.h"
-#include "smpi/private.h"
-#include "mc/mc_snapshot.h"
-#include "mc_ignore.h"
-#include "mc_protocol.h"
-#include "mc_client.h"
+#include "src/internal_config.h"
+#include "src/mc/mc_object_info.h"
+#include "src/mc/mc_private.h"
+#include "src/smpi/private.h"
+#include "src/mc/mc_snapshot.h"
+#include "src/mc/mc_ignore.h"
+#include "src/mc/mc_protocol.h"
+#include "src/mc/mc_client.h"
 
 extern "C" {
 
@@ -25,26 +25,25 @@ void MC_ignore_heap(void *address, size_t size)
   if (mc_mode != MC_MODE_CLIENT)
     return;
 
-  s_mc_heap_ignore_region_t region;
-  memset(&region, 0, sizeof(region));
-  region.address = address;
-  region.size = size;
-  region.block =
+  xbt_mheap_t heap = mmalloc_get_current_heap();
+
+  s_mc_ignore_heap_message_t message;
+  message.type = MC_MESSAGE_IGNORE_HEAP;
+  message.address = address;
+  message.size = size;
+  message.block =
    ((char *) address -
-    (char *) std_heap->heapbase) / BLOCKSIZE + 1;
-  if (std_heap->heapinfo[region.block].type == 0) {
-    region.fragment = -1;
-    std_heap->heapinfo[region.block].busy_block.ignore++;
+    (char *) heap->heapbase) / BLOCKSIZE + 1;
+  if (heap->heapinfo[message.block].type == 0) {
+    message.fragment = -1;
+    heap->heapinfo[message.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]++;
+    message.fragment =
+        ((uintptr_t) (ADDR2UINT(address) % (BLOCKSIZE))) >>
+        heap->heapinfo[message.block].type;
+    heap->heapinfo[message.block].busy_frag.ignore[message.fragment]++;
   }
 
-  s_mc_ignore_heap_message_t message;
-  message.type = MC_MESSAGE_IGNORE_HEAP;
-  message.region = region;
   if (MC_protocol_send(mc_client->fd, &message, sizeof(message)))
     xbt_die("Could not send ignored region to MCer");
 }
@@ -56,7 +55,7 @@ void MC_remove_ignore_heap(void *address, size_t size)
 
   s_mc_ignore_memory_message_t message;
   message.type = MC_MESSAGE_UNIGNORE_HEAP;
-  message.addr = address;
+  message.addr = (std::uintptr_t) address;
   message.size = size;
   MC_client_send_message(&message, sizeof(message));
 }
@@ -78,11 +77,13 @@ void MC_ignore_global_variable(const char *name)
  *  @param context
  *  @param size    Size of the stack
  */
-void MC_register_stack_area(void *stack, smx_process_t process, void *context, size_t size)
+void MC_register_stack_area(void *stack, smx_process_t process, ucontext_t* context, size_t size)
 {
   if (mc_mode != MC_MODE_CLIENT)
     return;
 
+  xbt_mheap_t heap = mmalloc_get_current_heap();
+
   s_stack_region_t region;
   memset(&region, 0, sizeof(region));
   region.address = stack;
@@ -90,7 +91,7 @@ void MC_register_stack_area(void *stack, smx_process_t process, void *context, s
   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);