From: Marion Guthmuller Date: Mon, 8 Oct 2012 12:35:58 +0000 (+0200) Subject: model-checker : restore struct smx_ctx_sysv in smx_context_sysv.c X-Git-Tag: v3_8~105 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0b892a9de2e4218184dc0b0726773f386bb38b65 model-checker : restore struct smx_ctx_sysv in smx_context_sysv.c --- diff --git a/src/include/mc/datatypes.h b/src/include/mc/datatypes.h index db6d8344a7..a31625a9f8 100644 --- a/src/include/mc/datatypes.h +++ b/src/include/mc/datatypes.h @@ -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; diff --git a/src/include/mc/mc.h b/src/include/mc/mc.h index 0a9ae5bd84..920739da22 100644 --- a/src/include/mc/mc.h +++ b/src/include/mc/mc.h @@ -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 */ diff --git a/src/mc/mc_checkpoint.c b/src/mc/mc_checkpoint.c index 3e1f5a0271..1a80fd5136 100644 --- a/src/mc/mc_checkpoint.c +++ b/src/mc/mc_checkpoint.c @@ -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; diff --git a/src/mc/mc_global.c b/src/mc/mc_global.c index 6a4b83b010..421479dbd6 100644 --- a/src/mc/mc_global.c +++ b/src/mc/mc_global.c @@ -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, ®ion); MC_UNSET_RAW_MEM; } diff --git a/src/simix/smx_context_base.c b/src/simix/smx_context_base.c index e248369e7a..a7a9f49bc1 100644 --- a/src/simix/smx_context_base.c +++ b/src/simix/smx_context_base.c @@ -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; } diff --git a/src/simix/smx_context_sysv.c b/src/simix/smx_context_sysv.c index b292db75d3..f65212cc2e 100644 --- a/src/simix/smx_context_sysv.c +++ b/src/simix/smx_context_sysv.c @@ -12,6 +12,13 @@ #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 /* context relative declarations */ +#else +# include /* context relative declarations */ +#endif #ifdef HAVE_VALGRIND_VALGRIND_H # include @@ -19,6 +26,15 @@ 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; } diff --git a/src/simix/smx_private.h b/src/simix/smx_private.h index fcf7fd10a6..8d6f5f52c6 100644 --- a/src/simix/smx_private.h +++ b/src/simix/smx_private.h @@ -25,12 +25,6 @@ #include "smx_smurf_private.h" #include "smx_synchro_private.h" -#ifdef _XBT_WIN32 -# include /* context relative declarations */ -#else -# include /* 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);