From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30802 invoked by alias); 9 Jul 2009 23:44:42 -0000 Received: (qmail 30790 invoked by uid 22791); 9 Jul 2009 23:44:41 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Jul 2009 23:44:35 +0000 Received: from spaceape9.eur.corp.google.com (spaceape9.eur.corp.google.com [172.28.16.143]) by smtp-out.google.com with ESMTP id n69NiWxS007013 for ; Fri, 10 Jul 2009 00:44:32 +0100 Received: from bwz18 (bwz18.prod.google.com [10.188.26.18]) by spaceape9.eur.corp.google.com with ESMTP id n69NiTMw024571 for ; Thu, 9 Jul 2009 16:44:30 -0700 Received: by bwz18 with SMTP id 18so497832bwz.7 for ; Thu, 09 Jul 2009 16:44:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.212.2 with SMTP id o2mr750323muq.18.1247183069576; Thu, 09 Jul 2009 16:44:29 -0700 (PDT) In-Reply-To: References: Date: Fri, 10 Jul 2009 06:35:00 -0000 Message-ID: Subject: Re: RFA: valgrind -vs- the testsuite From: Doug Evans To: Tom Tromey Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-07/txt/msg00299.txt.bz2 On Thu, Jul 9, 2009 at 10:19 AM, Tom Tromey wrote: > I've often found it useful to run gdb under valgrind in the > testsuite. =A0I keep this patch around to make this very easy; but I > figured I'd submit this in case other people find it useful. > > With this patch you can set a dejagnu variable and have each gdb > invocation in the test suite automatically run using valgrind. =A0The > valgrind output is sent to a separate file per gdb invocation, so it > doesn't mess up the test suite results. > > This needs a documentation review. > > Tom > > 2009-07-09 =A0Tom Tromey =A0 > > =A0 =A0 =A0 =A0* gdbint.texinfo (Testsuite): Document valgrind usage. > > 2009-07-09 =A0Tom Tromey =A0 > > =A0 =A0 =A0 =A0* lib/gdb.exp: Recognize VALGRIND variable. > > diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo > index a51f077..e15af88 100644 > --- a/gdb/doc/gdbint.texinfo > +++ b/gdb/doc/gdbint.texinfo > @@ -7560,6 +7560,19 @@ will give a result of ``UNRESOLVED'', like this: > =A0UNRESOLVED: gdb.base/example.exp: This test script does not work on a = remote host. > =A0@end smallexample > > +You can instruct the testsuite to run @value{GDBN} under > +@code{valgrind}. =A0You can do this by setting the DejaGNU variable > +@code{VALGRIND} on the @code{runtest} command line. =A0The testsuite > +will use the contents of this variable as arguments to pass to > +@code{valgrind}. =A0The testsuite also automatically adds a > +@code{--log-file} option to put the logs in files named > +@file{valgrind.@var{pid}} in DejaGNU's output directory. =A0Here, > +@var{pid} is the process id of the @value{GDBN} process. > + > +@smallexample > +make check RUNTESTFLAGS=3D'VALGRIND=3D--leak-check=3Dfull' > +@end smallexample > + > =A0@section Testsuite Organization > > =A0@cindex test suite organization > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 200ab35..25ccacb 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -42,6 +42,13 @@ if ![info exists GDB] { > =A0} > =A0verbose "using GDB =3D $GDB" 2 > > +# If VALGRIND is set, we run gdb under valgrind and use $VALGRIND as > +# arguments to valgrind. > +if {[info exists VALGRIND]} { > + =A0global outdir > + =A0set GDB "valgrind $VALGRIND --log-file=3D$outdir/valgrind.%p $GDB" > +} > + > =A0# GDBFLAGS is available for the user to set on the command line. > =A0# E.g. make check RUNTESTFLAGS=3DGDBFLAGS=3Dmumble > =A0# Testcases may use it to add additional flags, but they must: > I always just use: cd testsuite && runtest --tool gdb GDB=3D"valgrind ../gdb" or make check RUNTESTFLAGS=3D'"valgrind ../gdb"' (suitably augmented as desired), [not that I'm complaining about the option, valgrind is used often enough]