From 1199d8fec83b48b87e248552137fa554fba0ce69 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 20 Feb 2014 10:23:45 -0500 Subject: [PATCH] Fix: add missing VALGRIND ifdef checks and documentation Signed-off-by: Mathieu Desnoyers Signed-off-by: David Goulet --- doc/Makefile.am | 2 +- doc/valgrind-howto.txt | 4 ++++ src/common/hashtable/rculfhash.c | 2 +- src/common/runas.c | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 doc/valgrind-howto.txt diff --git a/doc/Makefile.am b/doc/Makefile.am index 6f05d7a78..4ff71ebbf 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -5,4 +5,4 @@ EXTRA_DIST = quickstart.txt streaming-howto.txt python-howto.txt \ dist_doc_DATA = quickstart.txt streaming-howto.txt python-howto.txt \ snapshot-howto.txt calibrate.txt live-reading-howto.txt \ - live-reading-protocol.txt + live-reading-protocol.txt valgrind-howto.txt diff --git a/doc/valgrind-howto.txt b/doc/valgrind-howto.txt new file mode 100644 index 000000000..68dcaba1c --- /dev/null +++ b/doc/valgrind-howto.txt @@ -0,0 +1,4 @@ +Build lttng-tools with "-DVALGRIND" to create executables compatible +with the valgrind tool. The start with e.g.: + +valgrind --leak-check=full lttng-sessiond diff --git a/src/common/hashtable/rculfhash.c b/src/common/hashtable/rculfhash.c index 0ddd21a3b..ee09afd1b 100644 --- a/src/common/hashtable/rculfhash.c +++ b/src/common/hashtable/rculfhash.c @@ -627,7 +627,7 @@ void free_split_items_count(struct cds_lfht *ht) poison_free(ht->split_count); } -#if defined(HAVE_SCHED_GETCPU) +#if defined(HAVE_SCHED_GETCPU) && !defined(VALGRIND) static int ht_get_split_count_index(unsigned long hash) { diff --git a/src/common/runas.c b/src/common/runas.c index 9029f8f74..5ab42717a 100644 --- a/src/common/runas.c +++ b/src/common/runas.c @@ -77,6 +77,20 @@ struct run_as_open_data { mode_t mode; }; +#ifdef VALGRIND +static +int use_clone(void) +{ + return 0; +} +#else +static +int use_clone(void) +{ + return !getenv("LTTNG_DEBUG_NOCLONE"); +} +#endif + /* * Create recursively directory using the FULL path. */ @@ -271,7 +285,7 @@ int run_as_noclone(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid) static int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid) { - if (!getenv("LTTNG_DEBUG_NOCLONE")) { + if (use_clone()) { int ret; DBG("Using run_as_clone"); -- 2.34.1