Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 11 Feb 2016 21:42:53 +0000 (22:42 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 11 Feb 2016 21:42:53 +0000 (22:42 +0100)
src/include/mc/datatypes.h
src/include/mc/mc.h
src/mc/ObjectInformation.cpp
src/mc/mc_diff.cpp
src/mc/mc_ignore.cpp
src/simix/UContext.cpp
src/xbt/mmalloc/mm_module.c

index 763b60d..0b45c09 100644 (file)
@@ -7,6 +7,8 @@
 #ifndef MC_DATATYPE_H
 #define MC_DATATYPE_H
 
+#include <ucontext.h>
+
 #include "xbt/misc.h"
 #include "xbt/swag.h"
 #include "xbt/fifo.h"
@@ -26,7 +28,7 @@ typedef struct s_mc_transition *mc_transition_t;
 
 typedef struct s_stack_region{
   void *address;
-  void *context;
+  ucontext_t* context;
   size_t size;
   int block;
   int process_index;
index eaeb396..d3eadea 100644 (file)
@@ -7,6 +7,8 @@
 #ifndef _MC_MC_H
 #define _MC_MC_H
 
+#include <ucontext.h>
+
 #include "xbt/base.h"
 #include "xbt/misc.h"
 #include "xbt/fifo.h"
@@ -87,7 +89,7 @@ XBT_PUBLIC(void) MC_ignore_heap(void *address, size_t size);
 XBT_PUBLIC(void) MC_remove_ignore_heap(void *address, size_t size);
 XBT_PUBLIC(void) MC_ignore_local_variable(const char *var_name, const char *frame);
 XBT_PUBLIC(void) MC_ignore_global_variable(const char *var_name);
-XBT_PUBLIC(void) MC_register_stack_area(void *stack, smx_process_t process, void *context, size_t size);
+XBT_PUBLIC(void) MC_register_stack_area(void *stack, smx_process_t process, ucontext_t* context, size_t size);
 
 /********************************* Memory *************************************/
 XBT_PUBLIC(void) MC_memory_init(void);  /* Initialize the memory subsystem */
index 9d66b0e..08a75fa 100644 (file)
@@ -108,32 +108,35 @@ void ObjectInformation::remove_global_variable(const char* name)
     return;
 
   // Binary search:
-  size_type start = 0;
-  size_type end = this->global_variables.size() - 1;
+  size_type first = 0;
+  size_type last = this->global_variables.size() - 1;
 
-  while (start <= end) {
-    size_type cursor = start + (end - start) / 2;
+  while (first <= last) {
+    size_type cursor = first + (last - first) / 2;
     simgrid::mc::Variable& current_var = this->global_variables[cursor];
     int cmp = current_var.name.compare(name);
 
     if (cmp == 0) {
+  
       // Find the whole range:
-      start = cursor;
-      while (start != 0 && this->global_variables[start - 1].name == name)
-        start--;
+      size_type first = cursor;
+      while (first != 0 && this->global_variables[first - 1].name == name)
+        first--;
       size_type size = this->global_variables.size();
-      end = cursor;
-      while (end != size - 1 && this->global_variables[end + 1].name == name)
-        end++;
+      size_type last = cursor;
+      while (last != size - 1 && this->global_variables[last + 1].name == name)
+        last++;
+  
       // Remove the whole range:
       this->global_variables.erase(
-        this->global_variables.begin() + cursor,
-        this->global_variables.begin() + end + 1);
+        this->global_variables.begin() + first,
+        this->global_variables.begin() + last + 1);
+  
       return;
     } else if (cmp < 0)
-      start = cursor + 1;
+      first = cursor + 1;
     else if (cursor != 0)
-      end = cursor - 1;
+      last = cursor - 1;
     else
       break;
   }
index 93fd254..f8bbd84 100644 (file)
@@ -337,7 +337,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2)
   const malloc_info* heapinfos2 = snapshot2->read<malloc_info*>(
     (std::uint64_t)heapinfo_address, simgrid::mc::ProcessIndexMissing);
 
-  while (i1 < state->heaplimit) {
+  while (i1 <= state->heaplimit) {
 
     const malloc_info* heapinfo1 = (const malloc_info*) MC_region_read(heap_region1, &heapinfo_temp1, &heapinfos1[i1], sizeof(malloc_info));
     const malloc_info* heapinfo2 = (const malloc_info*) MC_region_read(heap_region2, &heapinfo_temp2, &heapinfos2[i1], sizeof(malloc_info));
@@ -401,7 +401,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2)
 
       }
 
-      while (i2 < state->heaplimit && !equal) {
+      while (i2 <= state->heaplimit && !equal) {
 
         addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE +
                        (char *) state->std_heap_copy.heapbase;
@@ -486,7 +486,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2)
 
         }
 
-        while (i2 < state->heaplimit && !equal) {
+        while (i2 <= state->heaplimit && !equal) {
 
           const malloc_info* heapinfo2b = (const malloc_info*) MC_region_read(
             heap_region2, &heapinfo_temp2b, &heapinfos2[i2],
@@ -560,7 +560,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2)
   /* All blocks/fragments are equal to another block/fragment ? */
   size_t i = 1, j = 0;
 
-  for(i = 1; i < state->heaplimit; i++) {
+  for(i = 1; i <= state->heaplimit; i++) {
     const malloc_info* heapinfo1 = (const malloc_info*) MC_region_read(
       heap_region1, &heapinfo_temp1, &heapinfos1[i], sizeof(malloc_info));
     if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED) {
@@ -602,7 +602,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2)
   if (i1 == state->heaplimit)
     XBT_DEBUG("Number of blocks/fragments not found in heap1 : %d", nb_diff1);
 
-  for (i=1; i < state->heaplimit; i++) {
+  for (i=1; i <= state->heaplimit; i++) {
     const malloc_info* heapinfo2 = (const malloc_info*) MC_region_read(
       heap_region2, &heapinfo_temp2, &heapinfos2[i], sizeof(malloc_info));
     if (heapinfo2->type == MMALLOC_TYPE_UNFRAGMENTED) {
@@ -758,9 +758,13 @@ static int compare_heap_area_with_type(struct s_mc_diff *state, int process_inde
                                        int pointer_level)
 {
 top:
-  if (is_stack(real_area1) && is_stack(real_area2))
+  // HACK: This should not happen but in pratice, there is some
+  // DW_TAG_typedef without DW_AT_type. We should fix this somehow.
+  if (type == nullptr)
     return 0;
 
+  if (is_stack(real_area1) && is_stack(real_area2))
+    return 0;
   ssize_t ignore1, ignore2;
 
   if ((check_ignore > 0)
@@ -925,7 +929,7 @@ top:
         void *real_member2 = simgrid::dwarf::resolve_member(
             real_area2, type, &member, (simgrid::mc::AddressSpace*) snapshot2, process_index);
         res =
-            compare_heap_area_with_type(state, process_index, real_member1, real_member2,
+          compare_heap_area_with_type(state, process_index, real_member1, real_member2,
                                         snapshot1, snapshot2,
                                         previous, member.type, -1,
                                         check_ignore, 0);
index ccac733..6017779 100644 (file)
@@ -77,7 +77,7 @@ 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;
index 33532bb..45b50be 100644 (file)
@@ -76,6 +76,10 @@ static unsigned long sysv_process_index = 0;   /* index of the next process to r
 static simgrid::simix::UContext* sysv_maestro_context;
 static bool sysv_parallel;
 
+// The name of this function is currently hardcoded in the code (as string).
+// Do not change it without fixing those references as well.
+static void smx_ctx_sysv_wrapper(int first, ...);
+
 namespace simgrid {
 namespace simix {
 
@@ -88,8 +92,6 @@ public:
   UContext(std::function<void()>  code,
     void_pfn_smxprocess_t cleanup_func, smx_process_t process);
   ~UContext();
-protected:
-  static void wrapper(int first, ...);
 };
 
 class SerialUContext : public UContext {
@@ -224,7 +226,7 @@ UContext::UContext(std::function<void()> code,
           this->stack_, smx_context_usable_stack_size);
     this->uc_.uc_stack.ss_size = pth_sksize_makecontext(
           this->stack_, smx_context_usable_stack_size);
-    simgrid_makecontext(&this->uc_, UContext::wrapper, this);
+    simgrid_makecontext(&this->uc_, smx_ctx_sysv_wrapper, this);
   } else {
     if (process != NULL && sysv_maestro_context == NULL)
       sysv_maestro_context = this;
@@ -243,11 +245,14 @@ UContext::~UContext()
   SIMIX_context_stack_delete(this->stack_);
 }
 
-void UContext::wrapper(int first, ...)
+}
+}
+
+static void smx_ctx_sysv_wrapper(int first, ...)
 {
   // Rebuild the Context* pointer from the integers:
   int ctx_addr[CTX_ADDR_LEN];
-  UContext* context;
+  simgrid::simix::UContext* context;
   ctx_addr[0] = first;
   if (CTX_ADDR_LEN > 1) {
     va_list ap;
@@ -256,12 +261,15 @@ void UContext::wrapper(int first, ...)
       ctx_addr[i] = va_arg(ap, int);
     va_end(ap);
   }
-  memcpy(&context, ctx_addr, sizeof(UContext*));
+  memcpy(&context, ctx_addr, sizeof(simgrid::simix::UContext*));
 
   (*context)();
   context->stop();
 }
 
+namespace simgrid {
+namespace simix {
+
 void SerialUContext::stop()
 {
   Context::stop();
index 8b9ebaa..3440236 100644 (file)
@@ -359,7 +359,7 @@ void mmalloc_postexit(void)
 size_t mmalloc_get_bytes_used_remote(size_t heaplimit, const malloc_info* heapinfo)
 {
   int bytes = 0;
-  for (size_t i=0; i < heaplimit; ++i){
+  for (size_t i=0; i<=heaplimit; ++i){
     if (heapinfo[i].type == MMALLOC_TYPE_UNFRAGMENTED){
       if (heapinfo[i].busy_block.busy_size > 0)
         bytes += heapinfo[i].busy_block.busy_size;