Fix some minor bugs in test suite command logging
authorTom Tromey <tom@tromey.com>
Mon, 26 Oct 2020 23:10:25 +0000 (17:10 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 26 Oct 2020 23:10:25 +0000 (17:10 -0600)
I noticed that the test suite command logging would create a file like
"gdb.cmd.-1".  I tracked this down to a substraction in
standard_output_file_with_gdb_instance.

Then, I saw that the .in file was not created for MI.  This is fixed
by adding a call to default_mi_gdb_start.

Finally, commands might not end up in the .in file in some cases.  For
me this happened because the test took a long time, so I got impatient
and killed it.  Flushing the file after each write seemed like a good
thing to do here.

gdb/testsuite/ChangeLog
2020-10-26  Tom Tromey  <tom@tromey.com>

* lib/mi-support.exp (default_mi_gdb_start): Call
gdb_stdin_log_init.
* lib/gdb.exp (standard_output_file_with_gdb_instance): Don't
subtract one from gdb_instances.
(gdb_stdin_log_write): Flush in_file.

gdb/testsuite/ChangeLog
gdb/testsuite/lib/gdb.exp
gdb/testsuite/lib/mi-support.exp

index 48139f248d28f0fc9bf150fa3c24639cf1092a1b..29db747877c9c77d5bf618f55b97041ee26d8ff7 100644 (file)
@@ -1,3 +1,11 @@
+2020-10-26  Tom Tromey  <tom@tromey.com>
+
+       * lib/mi-support.exp (default_mi_gdb_start): Call
+       gdb_stdin_log_init.
+       * lib/gdb.exp (standard_output_file_with_gdb_instance): Don't
+       subtract one from gdb_instances.
+       (gdb_stdin_log_write): Flush in_file.
+
 2020-10-26  Tom de Vries  <tdevries@suse.de>
 
        * gdb.dwarf2/enqueued-cu-base-addr.exp: New file.
index 197542eec3ba4864dbcbffcdc7b1ff9153895c27..8b00ee0f54be260359d5b1bacc96fefd0cef77b0 100644 (file)
@@ -5213,7 +5213,7 @@ proc standard_output_file {basename} {
 
 proc standard_output_file_with_gdb_instance {basename} {
     global gdb_instances
-    set count [expr $gdb_instances - 1 ]
+    set count $gdb_instances
 
     if {$count == 0} {
       return [standard_output_file $basename]
@@ -7216,8 +7216,10 @@ proc gdb_stdin_log_write { message {type standard} } {
         }
     }
 
-    #Write to the log
+    # Write to the log and make sure the output is there, even in case
+    # of crash.
     puts -nonewline $in_file "$message"
+    flush $in_file
 }
 
 # Write the command line used to invocate gdb to the cmd file.
index 3dea699a0b2997a10670166067e359663fb40f6a..8e7b0ab79e2b22e38c0049b088616988a71134b5 100644 (file)
@@ -206,6 +206,12 @@ proc default_mi_gdb_start { args } {
     global MIFLAGS
     global FORCE_SEPARATE_MI_TTY
 
+    # Keep track of the number of times GDB has been launched.
+    global gdb_instances
+    incr gdb_instances
+
+    gdb_stdin_log_init
+
     if {[info exists FORCE_SEPARATE_MI_TTY]} {
        set separate_mi_pty $FORCE_SEPARATE_MI_TTY
     } else {