From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22207 invoked by alias); 9 Jul 2009 17:19:53 -0000 Received: (qmail 22199 invoked by uid 22791); 9 Jul 2009 17:19:52 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Jul 2009 17:19:44 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n69HJgC2029038 for ; Thu, 9 Jul 2009 13:19:42 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n69HJffI017349; Thu, 9 Jul 2009 13:19:41 -0400 Received: from opsy.redhat.com (vpn-225-106.phx2.redhat.com [10.3.225.106]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n69HJeN3025684; Thu, 9 Jul 2009 13:19:41 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 2E6B0508288; Thu, 9 Jul 2009 11:19:40 -0600 (MDT) To: gdb-patches@sourceware.org Subject: RFA: valgrind -vs- the testsuite From: Tom Tromey Reply-To: Tom Tromey Date: Thu, 09 Jul 2009 18:02:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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/msg00286.txt.bz2 I've often found it useful to run gdb under valgrind in the testsuite. I 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. The 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 Tom Tromey * gdbint.texinfo (Testsuite): Document valgrind usage. 2009-07-09 Tom Tromey * 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: UNRESOLVED: gdb.base/example.exp: This test script does not work on a remote host. @end smallexample +You can instruct the testsuite to run @value{GDBN} under +@code{valgrind}. You can do this by setting the DejaGNU variable +@code{VALGRIND} on the @code{runtest} command line. The testsuite +will use the contents of this variable as arguments to pass to +@code{valgrind}. The 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. Here, +@var{pid} is the process id of the @value{GDBN} process. + +@smallexample +make check RUNTESTFLAGS='VALGRIND=--leak-check=full' +@end smallexample + @section Testsuite Organization @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] { } verbose "using GDB = $GDB" 2 +# If VALGRIND is set, we run gdb under valgrind and use $VALGRIND as +# arguments to valgrind. +if {[info exists VALGRIND]} { + global outdir + set GDB "valgrind $VALGRIND --log-file=$outdir/valgrind.%p $GDB" +} + # GDBFLAGS is available for the user to set on the command line. # E.g. make check RUNTESTFLAGS=GDBFLAGS=mumble # Testcases may use it to add additional flags, but they must: