typedef struct s_stack_region{
void *address;
char *process_name;
+ void *context;
size_t size;
}s_stack_region_t, *stack_region_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 */
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)
{
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);
}
}
-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();
}
-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;
}
- free(stack_name);
+ //free(stack_name);
return variables;
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);
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;
}
}
context->data = data;
- if(MC_IS_ENABLED && code)
- MC_new_stack_area(context, ((smx_process_t)context->data)->name);
-
return context;
}
#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 */
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;
}
#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). */
/* 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);