From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: RFA: valgrind -vs- the testsuite
Date: Thu, 09 Jul 2009 18:02:00 -0000 [thread overview]
Message-ID: <m3k52hn590.fsf@fleche.redhat.com> (raw)
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 <tromey@redhat.com>
* gdbint.texinfo (Testsuite): Document valgrind usage.
2009-07-09 Tom Tromey <tromey@redhat.com>
* 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:
next reply other threads:[~2009-07-09 17:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-09 18:02 Tom Tromey [this message]
2009-07-09 19:29 ` Eli Zaretskii
2009-07-10 6:35 ` Doug Evans
2009-07-10 18:02 ` Tom Tromey
2009-07-16 20:38 ` Joel Brobecker
2009-07-17 0:24 ` Tom Tromey
2009-07-20 1:17 ` Samuel Bronson
2009-07-20 5:18 ` Thiago Jung Bauermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3k52hn590.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox