When building even a most simplistic C program on this box, valgrind spits out a handful of warnings which are not terribly useful since they originate from code in other system libraries. This is because some libraries shipped with FreeBSD have problematic code sequences themselves. Fix: It would be most excellent if a few default supression files could be shipped with the valgrind port, to make the software even more useful out of the box. What I did was simply running a command sequence as the one given in the "How-To-Repeat" section, but passing an additional "--gen-suppressions=yes" switch to valgrind. That way, it will (after asking for confirmation) generate a suitable supression rule for each error it finds. Those rules can then be stored in a file (e.g. "freebsd-5.2.1.supp"), and enabled by default by installing a "valgrindrc" file containing "--suppressions=/path/to/supressions/freebsd-5.2.1.supp". I'll try to generate suppresion files for different FreeBSD versions, and attach them to this report as I get them. How-To-Repeat: % echo "int main(){}" > mini.c % cc -o mini mini.c % valgrind --tool=memcheck ./mini valgrind will now print a bunch of warnings, depending on what FreeBSD version (and thus, what libraries) is used.
> When building even a most simplistic C program on this box, valgrind spits > out a handful of warnings which are not terribly useful since they originate > from code in other system libraries. This is because some libraries shipped > with FreeBSD have problematic code sequences themselves. [...] > I'll try to generate suppresion files for different FreeBSD versions, and > attach them to this report as I get them. Hi, I am the maintainer of the valgrind ports. Thanks for looking into this! If you want, you can send me those suppression files before submitting them to GNATs, so I can have a look at them. Or just Cc: them to me, and I can give my commit approval (I will also forward them to Doug Rabson, who is the person who actually ported valgrind to FreeBSD). Simon
On Tuesday 21 September 2004 03:22, Simon Barner wrote: > > I'll try to generate suppresion files for different FreeBSD versions, and > > attach them to this report as I get them. > If you want, you can send me those suppression files before submitting > them to GNATs, so I can have a look at them. Actually, I came up with a different (IMHO superior) way to implement this. The most flexible solution would be to run a script at post-install time which automatically generates a suppression file for whatever system the port is being built on. I attached a patch which attempts to implement this, it would be much appreciated if you could review it. - Frerich
Hi, I attached a patch to the devel/valgrind port which is functionally equivalent to the last patch I sent, but does not need any external script such as make-suppressions.sh IMHO it's thus superior to the last patch and supersedes it. - Frerich
Dear maintainer! What is the status of the PR? -- Sem.
I have modified Frerich's second implementation of an automatic supression file generator, so that emtpy suppression files are not installed. Currently, neither FreeBSD 4.11-RC nor 5-STABLE need suppression files, but I think it's a good idea to have Frerich Raabe (please give him credits in the commit message!) in the port, just in case valgrind default suppression should be necessary on future versions of FreeBSD. Additionally, for valgrind-snapshot, the plist was fixed on FreeBSD 4! The patches for devel/valgrind and devel/valgrind-snapshot follow... -- valgrind.patch begins here diff -ruN valgrind.orig/Makefile valgrind/Makefile --- valgrind.orig/Makefile Sun Dec 19 20:16:18 2004 +++ valgrind/Makefile Mon Dec 20 23:00:33 2004 @@ -7,7 +7,7 @@ PORTNAME= valgrind PORTVERSION= 352 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= devel MASTER_SITES= http://www.rabson.org/ DISTNAME= ${PORTNAME}-stable-${PORTVERSION} @@ -66,12 +66,26 @@ .endif post-install: - ${INSTALL_DATA} ${WRKSRC}/coregrind/vg_unistd.h \ + @${INSTALL_DATA} ${WRKSRC}/coregrind/vg_unistd.h \ ${PREFIX}/include/valgrind + @yes | ${PREFIX}/bin/valgrind --tool=memcheck --gen-suppressions=yes true \ + | ${SED} -e 's,.*{$$,{,' \ + | ${GREP} -v '^=' \ + > ${WRKDIR}/freebsd-default.supp || \ + ${RM} ${WRKDIR}/freebsd-default.supp + @${ECHO} "" @${ECHO} "" - @${CAT} ${PKGMESSAGE} + @${CAT} ${PKGMESSAGE} | ${SED} -e 's,%%PREFIX%%,${PREFIX},g' @${ECHO} "" + +.if exists(${WRKDIR}/freebsd-default.supp) + @${INSTALL_DATA} ${WRKDIR}/freebsd-default.supp \ + ${PREFIX}/lib/valgrind +PLIST_SUB+= VALGRIND_SUPPFILE="" +.else +PLIST_SUB+= VALGRIND_SUPPFILE="@comment " +.endif .include <bsd.port.post.mk> diff -ruN valgrind.orig/pkg-message valgrind/pkg-message --- valgrind.orig/pkg-message Sun Dec 19 20:16:18 2004 +++ valgrind/pkg-message Mon Dec 20 23:01:17 2004 @@ -7,3 +7,13 @@ As a workaround you can use the devel/valgrind-snapshot port, which is based on a more recent snapshot. + +Note 2: A sample suppression file might have been installed to \ + %%PREFIX%%/etc/freebsd-default.supp. It makes Valgrind hide warnings + caused by flawed code sequences - if any - in your system libraries, + so that you can concentrate on the warnings issued for your own code. + + To use these suppressions, either pass + --suppressions=%%PREFIX%%/etc/freebsd-default.supp + to Valgrind on the commandline, or add that line to your + ~/.valgrindrc file, which is the recommended way. diff -ruN valgrind.orig/pkg-plist valgrind/pkg-plist --- valgrind.orig/pkg-plist Sun Dec 19 20:16:18 2004 +++ valgrind/pkg-plist Mon Dec 20 22:58:38 2004 @@ -36,6 +36,7 @@ lib/valgrind/xfree-3.supp lib/valgrind/xfree-4.supp libdata/pkgconfig/valgrind.pc +%%VALGRIND_SUPPFILE%%etc/freebsd-default.supp %%PORTDOCS%%%%DOCSDIR%%/ac_main.html %%PORTDOCS%%%%DOCSDIR%%/cc_main.html %%PORTDOCS%%%%DOCSDIR%%/cg_main.html -- valgrind.patch ends here -- valgrind-snapshot.patch begins here diff -ruN valgrind-snapshot.orig/Makefile valgrind-snapshot/Makefile --- valgrind-snapshot.orig/Makefile Sun Dec 19 20:33:32 2004 +++ valgrind-snapshot/Makefile Mon Dec 20 23:04:31 2004 @@ -7,7 +7,7 @@ PORTNAME= valgrind PORTVERSION= 352 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= devel MASTER_SITES= http://www.rabson.org/ PKGNAMESUFFIX= -snapshot @@ -32,6 +32,14 @@ .include <bsd.port.pre.mk> +.if ${OSVERSION} >= 500000 +PLIST_SUB+= RELENG_4="@comment" +PLIST_SUB+= RELENG_5="" +.else +PLIST_SUB+= RELENG_4="" +PLIST_SUB+= PRELENG_5="@comment" +.endif + .if ${PERL_LEVEL} < 500601 IGNORE= "can\'t be built. Your Perl version is too old. Please use lang/perl5.8 port to upgrade your Perl" .endif @@ -62,7 +70,25 @@ .endif post-install: - ${INSTALL_DATA} ${WRKSRC}/coregrind/vg_unistd.h \ + @${INSTALL_DATA} ${WRKSRC}/coregrind/vg_unistd.h \ ${PREFIX}/include/valgrind + + @yes | ${PREFIX}/bin/valgrind --tool=memcheck --gen-suppressions=yes true \ + | ${SED} -e 's,.*{$$,{,' \ + | ${GREP} -v '^=' \ + > ${WRKDIR}/freebsd-default.supp || \ + ${RM} ${WRKDIR}/freebsd-default.supp + +.if exists(${WRKDIR}/freebsd-default.supp) + @${INSTALL_DATA} ${WRKDIR}/freebsd-default.supp \ + ${PREFIX}/lib/valgrind +PLIST_SUB+= VALGRIND_SUPPFILE="" + @${ECHO} "" + @${ECHO} "" + @${CAT} ${PKGMESSAGE} | ${SED} -e 's,%%PREFIX%%,${PREFIX},g' + @${ECHO} "" +.else +PLIST_SUB+= VALGRIND_SUPPFILE="@comment " +.endif .include <bsd.port.post.mk> diff -ruN valgrind-snapshot.orig/pkg-message valgrind-snapshot/pkg-message --- valgrind-snapshot.orig/pkg-message Thu Jan 1 01:00:00 1970 +++ valgrind-snapshot/pkg-message Mon Dec 20 22:59:50 2004 @@ -0,0 +1,10 @@ +Note : A sample suppression file was installed to \ + %%PREFIX%%/lib/valgrind/freebsd-default.supp. + It makes Valgrind hide warnings caused by flawed code sequences + -if any - in your system libraries, so that you can concentrate + on the warnings issued for your own code. + + To use these suppressions, either pass + --suppressions=%%PREFIX%%/lib/valgrind/freebsd-default.supp + to Valgrind on the commandline, or add that line to your + ~/.valgrindrc file, which is the recommended way. diff -ruN valgrind-snapshot.orig/pkg-plist valgrind-snapshot/pkg-plist --- valgrind-snapshot.orig/pkg-plist Sun Dec 19 20:33:32 2004 +++ valgrind-snapshot/pkg-plist Mon Dec 20 22:58:40 2004 @@ -13,12 +13,13 @@ lib/valgrind/glibc-2.2.supp lib/valgrind/glibc-2.3.supp lib/valgrind/hp2ps -lib/valgrind/libc_r.so.5 -lib/valgrind/libkse.so.1 +%%RELENG_4%%lib/valgrind/libc_r.so.4 +%%RELENG_5%%lib/valgrind/libc_r.so.5 +%%RELENG_5%%lib/valgrind/libkse.so.1 lib/valgrind/libpthread.so lib/valgrind/libpthread.so.0 -lib/valgrind/libpthread.so.1 -lib/valgrind/libthr.so.1 +%%RELENG_5%%lib/valgrind/libpthread.so.1 +%%RELENG_5%%lib/valgrind/libthr.so.1 lib/valgrind/stage2 lib/valgrind/valgrind lib/valgrind/vg_inject.so @@ -37,6 +38,7 @@ lib/valgrind/vgskin_none.so lib/valgrind/xfree-3.supp lib/valgrind/xfree-4.supp +%%VALGRIND_SUPPFILE%%lib/valgrind/freebsd-default.supp libdata/pkgconfig/valgrind.pc %%PORTDOCS%%%%DOCSDIR%%/ac_main.html %%PORTDOCS%%%%DOCSDIR%%/cc_main.html -- valgrind-snapshot.patch ends here --
State Changed From-To: open->closed Committed, thanks!