From 001af98d95108465ad06cb0f6668402d29246b86 Mon Sep 17 00:00:00 2001 From: mquinson Date: Tue, 3 Jun 2008 20:56:06 +0000 Subject: [PATCH] =?utf8?q?Inform=20valgrind=20about=20ucontextes=20[S?= =?utf8?q?=C3=A9kou=20Diakite]?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5512 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/xbt/xbt_context_sysv.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/xbt/xbt_context_sysv.c b/src/xbt/xbt_context_sysv.c index bf0558853e..c3dfdd0a46 100644 --- a/src/xbt/xbt_context_sysv.c +++ b/src/xbt/xbt_context_sysv.c @@ -6,12 +6,18 @@ #include "portable.h" #include /* context relative declarations */ #define STACK_SIZE 128*1024 /* lower this if you want to reduce the memory consumption */ +#ifdef HAVE_VALGRIND_VALGRIND_H +# include +#endif /* HAVE_VALGRIND_VALGRIND_H */ typedef struct s_xbt_ctx_sysv { XBT_CTX_BASE_T; - ucontext_t uc; /* the thread that execute the code */ - char stack[STACK_SIZE]; /* the thread stack size */ - struct s_xbt_ctx_sysv *prev; /* the previous thread */ + ucontext_t uc; /* the thread that execute the code */ + char stack[STACK_SIZE]; /* the thread stack size */ + struct s_xbt_ctx_sysv *prev; /* the previous thread */ +#ifdef HAVE_VALGRIND_VALGRIND_H + unsigned int valgrind_stack_id; /* the valgrind stack id. */ +#endif /* HAVE_VALGRIND_VALGRIND_H */ } s_xbt_ctx_sysv_t, *xbt_ctx_sysv_t; @@ -130,6 +136,12 @@ xbt_ctx_sysv_factory_create_context(const char *name, xbt_main_func_t code, pth_skaddr_makecontext(context->stack, STACK_SIZE); context->uc.uc_stack.ss_size = pth_sksize_makecontext(context->stack, STACK_SIZE); + #ifdef HAVE_VALGRIND_VALGRIND_H + context->valgrind_stack_id = VALGRIND_STACK_REGISTER( + context->uc.uc_stack.ss_sp, + ((char *)context->uc.uc_stack.ss_sp) + context->uc.uc_stack.ss_size + ); + #endif /* HAVE_VALGRIND_VALGRIND_H */ context->exception = xbt_new(ex_ctx_t, 1); XBT_CTX_INITIALIZE(context->exception); @@ -170,6 +182,10 @@ static void xbt_ctx_sysv_free(xbt_context_t context) if (context->exception) free(context->exception); + #ifdef HAVE_VALGRIND_VALGRIND_H + VALGRIND_STACK_DEREGISTER(((xbt_ctx_sysv_t)context)->valgrind_stack_id); + #endif /* HAVE_VALGRIND_VALGRIND_H */ + /* finally destroy the context */ free(context); } -- 2.20.1