From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: RFA: valgrind and the test suite, take 2
Date: Fri, 19 Feb 2010 17:24:00 -0000 [thread overview]
Message-ID: <m3ljep9m1j.fsf@fleche.redhat.com> (raw)
This needs a documentation review. I would also appreciate other
comments, as usual.
This patch adds support for valgrind to the test suite. Unlike my last
patch along these lines, this one adds value above just setting GDB.
In particular, it adds a new test at each point where the tested gdb
exits. If that gdb run caused valgrind to log any errors, the test
fails.
I ran the entire test suite this way on the compile farm and found a
number of problems (perhaps not all of our causing ... I'm still sorting
through the logs).
Tom
2010-02-19 Tom Tromey <tromey@redhat.com>
* gdbint.texinfo (Testsuite): Document use of VALGRIND setting.
2010-02-19 Tom Tromey <tromey@redhat.com>
* lib/gdb.exp: Recognize VALGRIND variable.
(remote_spawn): New wrapper proc.
(gdb_exit): Likewise.
diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo
index 7741855..8b02ed8 100644
--- a/gdb/doc/gdbint.texinfo
+++ b/gdb/doc/gdbint.texinfo
@@ -7674,6 +7674,19 @@ HOME=`pwd` runtest \
INTERNAL_GDBFLAGS=-nw
@end smallexample
+@item @code{VALGRIND}
+
+It is useful to occasionally run @value{GDBN} under @code{valgrind},
+to find bugs that do not always result in an immediate failure. This
+can be accomplished by setting @code{VALGRIND}. The contents of this
+will be appended to the internal @code{valgrind} command line that the
+test suite computes. @code{VALGRIND} can be empty.
+
+Setting this will add an additional check; each time @value{GDBN}
+exits, the contents of a the @code{valgrind} log file are examined
+and, if there was any output, the @samp{valgrind check} test will
+fail.
+
@end itemize
There are two ways to run the testsuite and pass additional parameters
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index a42d551..7bf1ea9 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -42,6 +42,14 @@ if ![info exists GDB] {
}
verbose "using GDB = $GDB" 2
+# If VALGRIND is set, we run gdb under valgrind.
+if {[info exists VALGRIND]} {
+ global outdir env vg_basename
+ set env(VGNAME) 0
+ set vg_basename "$outdir/valgrind."
+ set GDB "valgrind --quiet --trace-children=no --child-silent-after-fork=yes --log-file=${vg_basename}%q{VGNAME} $VALGRIND $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:
@@ -3139,6 +3147,50 @@ if {[info exists TRANSCRIPT]} {
}
}
+# Support for running gdb under valgrind and checking the results.
+if {[info exists VALGRIND]} {
+ rename remote_spawn vg_remote_spawn
+ rename gdb_exit vg_gdb_exit
+
+ proc remote_spawn {args} {
+ global env vg_basename
+ incr env(VGNAME)
+ file delete -force ${vg_basename}$env(VGNAME)
+ return [uplevel vg_remote_spawn $args]
+ }
+
+ proc gdb_exit {args} {
+ global env vg_basename vg_reported
+
+ # We can sometimes see multiple consecutive calls to gdb_exit
+ # without an intervening spawn. In this case we only want to
+ # report the valgrind results once.
+ if {![info exists vg_reported($env(VGNAME))]} {
+ set vg_reported($env(VGNAME)) 1
+
+ # FIXME: how can we name this test consistently across
+ # runs?
+ if {[file exists ${vg_basename}$env(VGNAME)]
+ && [file size ${vg_basename}$env(VGNAME)] > 0} {
+ send_log "Valgrind output:\n"
+ set fd [open ${vg_basename}$env(VGNAME)]
+ send_log [read $fd]
+ close $fd
+ send_log "\n"
+ fail "valgrind check $env(VGNAME)"
+ } else {
+ pass "valgrind check $env(VGNAME)"
+ }
+ }
+
+ return [uplevel vg_gdb_exit $args]
+ }
+
+ # Valgrind slows everything down, so boost the default timeout.
+ global gdb_test_timeout
+ set gdb_test_timeout [expr {20 * $gdb_test_timeout}]
+}
+
proc core_find {binfile {deletefiles {}} {arg ""}} {
global objdir subdir
next reply other threads:[~2010-02-19 17:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-19 17:24 Tom Tromey [this message]
2010-02-19 17:45 ` Pedro Alves
2010-02-19 18:09 ` Joel Brobecker
2010-02-19 19:34 ` Pedro Alves
2010-02-19 20:24 ` Joel Brobecker
2010-02-19 20:02 ` Tom Tromey
2010-02-19 20:28 ` Pedro Alves
2010-02-19 21:09 ` Tom Tromey
2010-02-19 21:27 ` Pedro Alves
2010-02-19 18:42 ` Eli Zaretskii
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=m3ljep9m1j.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