From 6aa249b5fbead5507a40500d29ef1640832eb2fc Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 18 Oct 2012 16:41:20 -0400 Subject: [PATCH] Add valgrind suppression file for libpopt Signed-off-by: Mathieu Desnoyers --- Makefile.am | 2 +- configure.ac | 2 ++ doc/development.txt | 13 ++++++++++++- extras/Makefile.am | 1 + extras/valgrind/Makefile.am | 1 + extras/valgrind/popt.supp | 8 ++++++++ 6 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 extras/Makefile.am create mode 100644 extras/valgrind/Makefile.am create mode 100644 extras/valgrind/popt.supp diff --git a/Makefile.am b/Makefile.am index 308ee16e7..7a636128d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = include types lib formats converter tests doc +SUBDIRS = include types lib formats converter tests doc extras dist_doc_DATA = ChangeLog LICENSE mit-license.txt gpl-2.0.txt \ std-ext-lib.txt diff --git a/configure.ac b/configure.ac index 118b8d392..24a9db607 100644 --- a/configure.ac +++ b/configure.ac @@ -106,5 +106,7 @@ AC_CONFIG_FILES([ lib/prio_heap/Makefile include/Makefile tests/Makefile + extras/Makefile + extras/valgrind/Makefile ]) AC_OUTPUT diff --git a/doc/development.txt b/doc/development.txt index f18070c1e..7b6c9e352 100644 --- a/doc/development.txt +++ b/doc/development.txt @@ -2,9 +2,20 @@ This document describes some principles that should be respected when developing in Babeltrace. Memory usage : + Since Babeltrace exports a library, we need to make sure that all allocated memory is freed, we do not want any memory leaks. Since Babeltrace uses the glib, it is necessary to assist a little valgrind when trying to identify memory leaks. + +libpopt has issues with inconsistency between versions. Namely, libpopt +0.16 allocates memory for the string returned by poptgetArg(), but not +libpopt 0.13. Therefore, we are providing a warning suppression file +that covers this case in the extras/ directory of the source code. + So the proper invocation of Babeltrace with Valgrind is : -G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --leak-check=full babeltrace + +G_SLICE=always-malloc G_DEBUG=gc-friendly \ + valgrind --leak-check=full \ + --suppressions=path_to_babeltrace_src/extras/valgrind/popt.supp \ + babeltrace diff --git a/extras/Makefile.am b/extras/Makefile.am new file mode 100644 index 000000000..3e142d45a --- /dev/null +++ b/extras/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = valgrind diff --git a/extras/valgrind/Makefile.am b/extras/valgrind/Makefile.am new file mode 100644 index 000000000..47dcc332f --- /dev/null +++ b/extras/valgrind/Makefile.am @@ -0,0 +1 @@ +EXTRA_DIST = popt.supp diff --git a/extras/valgrind/popt.supp b/extras/valgrind/popt.supp new file mode 100644 index 000000000..61b5465af --- /dev/null +++ b/extras/valgrind/popt.supp @@ -0,0 +1,8 @@ +{ + + Memcheck:Leak + fun:malloc + fun:poptGetNextOpt + fun:main +} + -- 2.34.1