Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : restore struct smx_ctx_sysv in smx_context_sysv.c
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Mon, 8 Oct 2012 12:35:58 +0000 (14:35 +0200)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Mon, 8 Oct 2012 12:41:59 +0000 (14:41 +0200)
src/include/mc/datatypes.h
src/include/mc/mc.h
src/mc/mc_checkpoint.c
src/mc/mc_global.c
src/simix/smx_context_base.c
src/simix/smx_context_sysv.c
src/simix/smx_private.h

index db6d834..a31625a 100644 (file)
@@ -28,6 +28,7 @@ typedef struct s_mc_ignore_region{
 typedef struct s_stack_region{
   void *address;
   char *process_name;
+  void *context;
   size_t size;
 }s_stack_region_t, *stack_region_t;
 
index 0a9ae5b..920739d 100644 (file)
@@ -42,7 +42,7 @@ XBT_PUBLIC(double) MC_process_clock_get(smx_process_t);
 void MC_automaton_load(const char *file);
 
 XBT_PUBLIC(void) MC_ignore(void *address, size_t size);
-void MC_new_stack_area(void *stack, char *name);
+void MC_new_stack_area(void *stack, char *name, void *context);
 
 /********************************* Memory *************************************/
 XBT_PUBLIC(void) MC_memory_init(void);  /* Initialize the memory subsystem */
index 3e1f5a0..1a80fd5 100644 (file)
@@ -29,9 +29,9 @@ static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start
 
 static void add_value(xbt_dynar_t *list, const char *type, unsigned long int val);
 static xbt_dynar_t take_snapshot_stacks(void *heap);
-static xbt_strbuff_t get_local_variables_values(stack_region_t stack, void *heap);
+static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap);
 static void print_local_variables_values(xbt_dynar_t all_variables);
-static void *get_stack_pointer(stack_region_t stack, void *heap);
+static void *get_stack_pointer(void *stack_context, void *heap);
 
 static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
 {
@@ -303,7 +303,7 @@ static xbt_dynar_t take_snapshot_stacks(void *heap){
   
   xbt_dynar_foreach(stacks_areas, cursor1, current_stack){
     mc_snapshot_stack_t st = xbt_new(s_mc_snapshot_stack_t, 1);
-    st->local_variables = get_local_variables_values(current_stack, heap);
+    st->local_variables = get_local_variables_values(current_stack->context, heap);
     st->stack_pointer = get_stack_pointer(current_stack, heap);
     xbt_dynar_push(res, &st);
   }
@@ -312,13 +312,13 @@ static xbt_dynar_t take_snapshot_stacks(void *heap){
 
 }
 
-static void *get_stack_pointer(stack_region_t stack, void *heap){
+static void *get_stack_pointer(void *stack_context, void *heap){
 
   unw_cursor_t c;
   int ret;
   unw_word_t sp;
 
-  ret = unw_init_local(&c, (unw_context_t *)&(((smx_ctx_sysv_t)(stack->address))->uc));
+  ret = unw_init_local(&c, (unw_context_t *)stack_context);
   if(ret < 0){
     XBT_INFO("unw_init_local failed");
     xbt_abort();
@@ -330,21 +330,21 @@ static void *get_stack_pointer(stack_region_t stack, void *heap){
 
 }
 
-static xbt_strbuff_t get_local_variables_values(stack_region_t stack, void *heap){
+static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap){
   
   unw_cursor_t c;
   int ret;
-  char *stack_name;
+  //char *stack_name;
 
   char buf[512], frame_name[256];
   
-  ret = unw_init_local(&c, (unw_context_t *)&(((smx_ctx_sysv_t)(stack->address))->uc));
+  ret = unw_init_local(&c, (unw_context_t *)stack_context);
   if(ret < 0){
     XBT_INFO("unw_init_local failed");
     xbt_abort();
   }
 
-  stack_name = strdup(((smx_process_t)((smx_ctx_sysv_t)(stack->address))->super.data)->name);
+  //stack_name = strdup(((smx_process_t)((smx_ctx_sysv_t)(stack->address))->super.data)->name);
 
   unw_word_t ip, sp, off;
   dw_frame_t frame;
@@ -503,7 +503,7 @@ static xbt_strbuff_t get_local_variables_values(stack_region_t stack, void *heap
      
   }
 
-  free(stack_name);
+  //free(stack_name);
 
   return variables;
 
index 6a4b83b..421479d 100644 (file)
@@ -700,7 +700,7 @@ void MC_ignore(void *address, size_t size){
   MC_UNSET_RAW_MEM;
 }
 
-void MC_new_stack_area(void *stack, char *name){
+void MC_new_stack_area(void *stack, char *name, void* context){
 
   if(stacks_areas == NULL)
     stacks_areas = xbt_dynar_new(sizeof(stack_region_t), NULL);
@@ -710,6 +710,7 @@ void MC_new_stack_area(void *stack, char *name){
   region = xbt_new0(s_stack_region_t, 1);
   region->address = stack;
   region->process_name = strdup(name);
+  region->context = context;
   xbt_dynar_push(stacks_areas, &region);
   MC_UNSET_RAW_MEM;
 }
index e248369..a7a9f49 100644 (file)
@@ -64,9 +64,6 @@ smx_ctx_base_factory_create_context_sized(size_t size,
   }
   context->data = data;
 
-  if(MC_IS_ENABLED && code)
-    MC_new_stack_area(context, ((smx_process_t)context->data)->name);
-
   return context;
 }
 
index b292db7..f65212c 100644 (file)
 #include "smx_private.h"
 #include "gras_config.h"
 #include "context_sysv_config.h"        /* loads context system definitions */
+#include "mc/mc.h"
+
+#ifdef _XBT_WIN32
+#  include <win32_ucontext.h>     /* context relative declarations */
+#else
+#  include <ucontext.h>           /* context relative declarations */
+#endif
 
 #ifdef HAVE_VALGRIND_VALGRIND_H
 #  include <valgrind/valgrind.h>
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
 
+typedef struct s_smx_ctx_sysv {
+  s_smx_ctx_base_t super;       /* Fields of super implementation */
+  ucontext_t uc;                /* the ucontext that executes the code */
+#ifdef HAVE_VALGRIND_VALGRIND_H
+  unsigned int valgrind_stack_id;       /* the valgrind stack id */
+#endif
+  char stack[0];                /* the thread stack (must remain the last element of the structure) */
+} s_smx_ctx_sysv_t, *smx_ctx_sysv_t;
+
 #ifdef CONTEXT_THREADS
 static xbt_parmap_t sysv_parmap;
 static ucontext_t* sysv_workers_stacks;        /* space to save the worker's stack in each thread */
@@ -152,6 +168,9 @@ smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code,
     sysv_maestro_context = context;
   }
 
+  if(MC_IS_ENABLED && code)
+    MC_new_stack_area(context, ((smx_process_t)((smx_context_t)context)->data)->name, &(context->uc));
+
   return (smx_context_t) context;
 }
 
index fcf7fd1..8d6f5f5 100644 (file)
 #include "smx_smurf_private.h"
 #include "smx_synchro_private.h"
 
-#ifdef _XBT_WIN32
-#  include <win32_ucontext.h>     /* context relative declarations */
-#else
-#  include <ucontext.h>           /* context relative declarations */
-#endif
-
 /* Define only for SimGrid benchmarking purposes */
 //#define TIME_BENCH_PER_SR /* this aims at measuring the time spent in each scheduling round per each thread. The code is thus run in sequential to bench separately each SSR */
 //#define TIME_BENCH_AMDAHL /* this aims at measuring the porting of time that could be parallelized at maximum (to get the optimal speedup by applying the amdahl law). */
@@ -211,15 +205,6 @@ smx_context_t SIMIX_context_get_current(void);
 
 /* All factories init */
 
-typedef struct s_smx_ctx_sysv {
-  s_smx_ctx_base_t super;       /* Fields of super implementation */
-  ucontext_t uc;                /* the ucontext that executes the code */
-#ifdef HAVE_VALGRIND_VALGRIND_H
-  unsigned int valgrind_stack_id;       /* the valgrind stack id */
-#endif
-  char stack[0];                /* the thread stack (must remain the last element of the structure) */
-} s_smx_ctx_sysv_t, *smx_ctx_sysv_t;
-
 void SIMIX_ctx_thread_factory_init(smx_context_factory_t *factory);
 void SIMIX_ctx_sysv_factory_init(smx_context_factory_t *factory);
 void SIMIX_ctx_raw_factory_init(smx_context_factory_t *factory);