X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/58d501820579989d9072d04845b09b0c2d21d05e..5e456059d43336fe91a373969f4a2c983ae844f9:/src/sthread/sthread.c diff --git a/src/sthread/sthread.c b/src/sthread/sthread.c index dd9a67c198..24213e0c72 100644 --- a/src/sthread/sthread.c +++ b/src/sthread/sthread.c @@ -1,12 +1,18 @@ /* SimGrid's pthread interposer. Redefinition of the pthread symbols (see the comment in sthread.h) */ #define _GNU_SOURCE +#include "src/internal_config.h" #include "src/sthread/sthread.h" #include #include #include #include +#if HAVE_VALGRIND_H +#include +#include +#endif + /* We don't want to intercept pthread within simgrid. Instead we should provide the real implem to simgrid */ static int (*raw_pthread_create)(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*); static int (*raw_pthread_join)(pthread_t, void**); @@ -211,7 +217,11 @@ int __libc_start_main(int (*main)(int, char**, char**), int argc, char** argv, i /* Find the real __libc_start_main()... */ typeof(&__libc_start_main) orig = dlsym(RTLD_NEXT, "__libc_start_main"); - fprintf(stderr, "__libc_start_main\n"); /* ... and call it with our custom main function */ +#if HAVE_VALGRIND_H + /* ... unless valgrind is used, and this instance is not the target program (but the valgrind launcher) */ + if (getenv("VALGRIND_LIB") && !RUNNING_ON_VALGRIND) + return orig(raw_main, argc, argv, init, fini, rtld_fini, stack_end); +#endif return orig(main_hook, argc, argv, init, fini, rtld_fini, stack_end); }