* RFA: make test suite transcripts
@ 2009-07-09 17:42 Tom Tromey
2009-07-09 19:26 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2009-07-09 17:42 UTC (permalink / raw)
To: gdb-patches
I've often wished there were a simple way to ask the test suite to
record all the commands sent to gdb, so that I could more easily
reproduce a failure.
This patch adds a simple transcription facility to the test suite.
This will record the gdb command line and all commands sent to gdb;
the transcript for each invocation of gdb is written to a separate
file. While imperfect (it doesn't handle readline stuff well), it has
already saved me quite a bit of futzing.
Let me know what you think.
The documentation needs a review.
Tom
2009-07-09 Tom Tromey <tromey@redhat.com>
* gdbint.texinfo (Testsuite): Document test transcripts.
2009-07-09 Tom Tromey <tromey@redhat.com>
* lib/gdb.exp: Handle LOG_GDB_SCRIPT.
(remote_spawn, remote_close, send_gdb): New procs.
diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo
index a51f077..1a54940 100644
--- a/gdb/doc/gdbint.texinfo
+++ b/gdb/doc/gdbint.texinfo
@@ -7560,6 +7560,27 @@ 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
+Sometimes it is convenient to get a transcript of the commands which
+the testsuite sends to @value{GDBN}. For example, if @value{GDBN}
+crashes during testing, a transcript can be used to more easily
+reconstruct the failure when running @value{GDBN} under @value{GDBN}.
+
+You can instruct the @value{GDBN} testsuite to write transcripts by
+setting the environment variable @code{LOG_GDB_SCRIPT} (to any value)
+before invoking @code{runtest} or @code{make check}. The transcripts
+will be written into DejaGNU's output directory. One transcript will
+be made for each invocation of @value{GDBN}; they will be named
+@file{transcript.@var{n}}, where @var{n} is an integer. The first
+line of the transcript file will show how @value{GDBN} was invoked;
+each subsequent line is a command sent as input to @value{GDBN}.
+
+@smallexample
+LOG_GDB_SCRIPT=y make check
+@end smallexample
+
+Note that the transcript is not always complete. In particular, tests
+of completion can yield partial command lines.
+
@section Testsuite Organization
@cindex test suite organization
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 200ab35..6964b96 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2983,3 +2983,49 @@ proc get_sizeof { type default } {
return [get_integer_valueof "sizeof (${type})" $default]
}
+# Log gdb command line and script if requested.
+if {[info exists env(LOG_GDB_SCRIPT)]} {
+ rename send_gdb real_send_gdb
+ rename remote_spawn real_remote_spawn
+ rename remote_close real_remote_close
+
+ global gdb_transcript
+ set gdb_transcript ""
+
+ global gdb_trans_count
+ set gdb_trans_count 1
+
+ proc remote_spawn {args} {
+ global gdb_transcript gdb_trans_count outdir
+
+ if {$gdb_transcript != ""} {
+ close $gdb_transcript
+ }
+ set gdb_transcript [open [file join $outdir transcript.$gdb_trans_count] w]
+ puts $gdb_transcript [lindex $args 1]
+ incr gdb_trans_count
+
+ return [uplevel real_remote_spawn $args]
+ }
+
+ proc remote_close {args} {
+ global gdb_transcript
+
+ if {$gdb_transcript != ""} {
+ close $gdb_transcript
+ set gdb_transcript ""
+ }
+
+ return [uplevel real_remote_close $args]
+ }
+
+ proc send_gdb {args} {
+ global gdb_transcript
+
+ if {$gdb_transcript != ""} {
+ puts -nonewline $gdb_transcript [lindex $args 0]
+ }
+
+ return [uplevel real_send_gdb $args]
+ }
+}
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: RFA: make test suite transcripts
2009-07-09 17:42 RFA: make test suite transcripts Tom Tromey
@ 2009-07-09 19:26 ` Eli Zaretskii
2009-07-10 19:37 ` Tom Tromey
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2009-07-09 19:26 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
> From: Tom Tromey <tromey@redhat.com>
> Date: Thu, 09 Jul 2009 11:00:16 -0600
>
> The documentation needs a review.
Thanks. The documentation patch is approved subject to the same
comments as for your previous patch to gdbint.texinfo.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: make test suite transcripts
2009-07-09 19:26 ` Eli Zaretskii
@ 2009-07-10 19:37 ` Tom Tromey
2009-07-10 19:50 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2009-07-10 19:37 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>> The documentation needs a review.
Eli> Thanks. The documentation patch is approved subject to the same
Eli> comments as for your previous patch to gdbint.texinfo.
Thanks. BTW, this sort of detail work would be simpler if the manuals
were internally consistent. I mostly copied existing texinfo usage
from elsewhere in gdbint.texinfo.
Anyway, later I decided that it is preferable to use a DejaGNU
variable, instead of an environment variable. So, the text changed.
Let me know what you think.
Tom
2009-07-09 Tom Tromey <tromey@redhat.com>
* gdbint.texinfo (Testsuite): Document test transcripts.
2009-07-09 Tom Tromey <tromey@redhat.com>
* lib/gdb.exp: Handle LOG_GDB_SCRIPT.
(remote_spawn, remote_close, send_gdb): New procs.
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.307
diff -u -r1.307 gdbint.texinfo
--- doc/gdbint.texinfo 2 Jul 2009 17:21:07 -0000 1.307
+++ doc/gdbint.texinfo 10 Jul 2009 17:22:10 -0000
@@ -7560,6 +7560,27 @@
UNRESOLVED: gdb.base/example.exp: This test script does not work on a remote host.
@end smallexample
+Sometimes it is convenient to get a transcript of the commands which
+the testsuite sends to @value{GDBN}. For example, if @value{GDBN}
+crashes during testing, a transcript can be used to more easily
+reconstruct the failure when running @value{GDBN} under @value{GDBN}.
+
+You can instruct the @value{GDBN} testsuite to write transcripts by
+setting the DejaGNU variable @code{TRANSCRIPT} (to any value)
+before invoking @code{runtest} or @kbd{make check}. The transcripts
+will be written into DejaGNU's output directory. One transcript will
+be made for each invocation of @value{GDBN}; they will be named
+@file{transcript.@var{n}}, where @var{n} is an integer. The first
+line of the transcript file will show how @value{GDBN} was invoked;
+each subsequent line is a command sent as input to @value{GDBN}.
+
+@smallexample
+make check RUNTESTFLAGS=TRANSCRIPT=y
+@end smallexample
+
+Note that the transcript is not always complete. In particular, tests
+of completion can yield partial command lines.
+
@section Testsuite Organization
@cindex test suite organization
Index: testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.117
diff -u -r1.117 gdb.exp
--- testsuite/lib/gdb.exp 28 Jun 2009 00:20:24 -0000 1.117
+++ testsuite/lib/gdb.exp 10 Jul 2009 17:22:12 -0000
@@ -2983,3 +2983,49 @@
return [get_integer_valueof "sizeof (${type})" $default]
}
+# Log gdb command line and script if requested.
+if {[info exists TRANSCRIPT]} {
+ rename send_gdb real_send_gdb
+ rename remote_spawn real_remote_spawn
+ rename remote_close real_remote_close
+
+ global gdb_transcript
+ set gdb_transcript ""
+
+ global gdb_trans_count
+ set gdb_trans_count 1
+
+ proc remote_spawn {args} {
+ global gdb_transcript gdb_trans_count outdir
+
+ if {$gdb_transcript != ""} {
+ close $gdb_transcript
+ }
+ set gdb_transcript [open [file join $outdir transcript.$gdb_trans_count] w]
+ puts $gdb_transcript [lindex $args 1]
+ incr gdb_trans_count
+
+ return [uplevel real_remote_spawn $args]
+ }
+
+ proc remote_close {args} {
+ global gdb_transcript
+
+ if {$gdb_transcript != ""} {
+ close $gdb_transcript
+ set gdb_transcript ""
+ }
+
+ return [uplevel real_remote_close $args]
+ }
+
+ proc send_gdb {args} {
+ global gdb_transcript
+
+ if {$gdb_transcript != ""} {
+ puts -nonewline $gdb_transcript [lindex $args 0]
+ }
+
+ return [uplevel real_send_gdb $args]
+ }
+}
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: RFA: make test suite transcripts
2009-07-10 19:37 ` Tom Tromey
@ 2009-07-10 19:50 ` Eli Zaretskii
0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2009-07-10 19:50 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
> Cc: gdb-patches@sourceware.org
> From: Tom Tromey <tromey@redhat.com>
> Date: Fri, 10 Jul 2009 11:22:38 -0600
>
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>
> >> The documentation needs a review.
>
> Eli> Thanks. The documentation patch is approved subject to the same
> Eli> comments as for your previous patch to gdbint.texinfo.
>
> Thanks. BTW, this sort of detail work would be simpler if the manuals
> were internally consistent.
True. Maybe I will find some time to do that.
> Anyway, later I decided that it is preferable to use a DejaGNU
> variable, instead of an environment variable. So, the text changed.
> Let me know what you think.
Fine with me.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-07-10 18:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-09 17:42 RFA: make test suite transcripts Tom Tromey
2009-07-09 19:26 ` Eli Zaretskii
2009-07-10 19:37 ` Tom Tromey
2009-07-10 19:50 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox