[GDBserver]: Silence exits if GDB is connected through stdio.
authorPedro Alves <palves@redhat.com>
Wed, 2 Oct 2013 11:42:35 +0000 (11:42 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 2 Oct 2013 11:42:35 +0000 (11:42 +0000)
If we make gdbserver gdb_continue_to_end actually expect a process
exit with GDBserver, we get many testsuite failures with the remote
stdio board:

-PASS: gdb.arch/amd64-disp-step.exp: continue until exit at amd64-disp-step
+FAIL: gdb.arch/amd64-disp-step.exp: continue until exit at amd64-disp-step (the program exited)
-PASS: gdb.base/break.exp: continue until exit at recursive next test
+FAIL: gdb.base/break.exp: continue until exit at recursive next test (the program exited)
-PASS: gdb.base/chng-syms.exp: continue until exit at breakpoint first time through
+FAIL: gdb.base/chng-syms.exp: continue until exit at breakpoint first time through (the program exited)
... etc. ...

This is what the log shows for all of them:

 (gdb) continue
 Continuing.

 Child exited with status 0
 GDBserver exiting
 [Inferior 1 (process 22721) exited normally]
 (gdb) FAIL: gdb.arch/amd64-disp-step.exp: continue until exit (the program exited)

The problem is the whole "Child exited ... GDBserver exiting" output,
that comes out of GDBserver, and that the testsuite is not expecting.

I pondered somehow making the testsuite adjust to this.  But,
testsuite aside, I think GDBserver should not be outputting this at
all when GDB is connected through stdio.  GDBserver will be printing
this in GDB's console, but the user can already tell from the regular
output that the inferior is gone.

Again, manually:

 (gdb) tar remote | ./gdbserver/gdbserver - program
 Remote debugging using | ./gdbserver/gdbserver - program
 Process program created; pid = 22486
 stdin/stdout redirected
 Remote debugging using stdio
 done.
 Loaded symbols for /lib64/ld-linux-x86-64.so.2
 0x000000323d001530 in _start () from /lib64/ld-linux-x86-64.so.2
 (gdb) c
 Continuing.
 Child exited with status 1
 ^^^^^^^^^^^^^^^^^^^^^^^^^^
 GDBserver exiting
 ^^^^^^^^^^^^^^^^^
 [Inferior 1 (process 22486) exited with code 01]
 (gdb)

Suppressing those two lines makes the output be exactly like when
debugging against a remote tcp gdbserver:

 (gdb) c
 Continuing.
 [Inferior 1 (process 22914) exited with code 01]
 (gdb)

2013-10-02  Pedro Alves  <palves@redhat.com>

* server.c (process_serial_event): Don't output "GDBserver
exiting" if GDB is connected through stdio.
* target.c (mywait): Likewise, be silent if GDB is connected
through stdio.

gdb/gdbserver/ChangeLog
gdb/gdbserver/server.c
gdb/gdbserver/target.c

index 469a2df1a42c77e66c58c1604e6a516c083d012c..3138f478682e0920b80f8f4f1c284117f792b93e 100644 (file)
@@ -1,3 +1,10 @@
+2013-10-02  Pedro Alves  <palves@redhat.com>
+
+       * server.c (process_serial_event): Don't output "GDBserver
+       exiting" if GDB is connected through stdio.
+       * target.c (mywait): Likewise, be silent if GDB is connected
+       through stdio.
+
 2013-10-01  Joel Brobecker  <brobecker@adacore.com>
 
        * lynx-low.c (lynx_add_threads_after_attach): New function.
index 4de20d5bb869e12e75ddd06186a0e75d8989c524..e0af78547e30ff38eaf68ddf998e7f696a367350 100644 (file)
@@ -3550,7 +3550,10 @@ process_serial_event (void)
         the whole vStopped list (until it gets an OK).  */
       if (QUEUE_is_empty (notif_event_p, notif_stop.queue))
        {
-         fprintf (stderr, "GDBserver exiting\n");
+         /* Be transparent when GDB is connected through stdio -- no
+            need to spam GDB's console.  */
+         if (!remote_connection_is_stdio ())
+           fprintf (stderr, "GDBserver exiting\n");
          remote_close ();
          exit (0);
        }
index 1a0dee280edb7b048e5676e06d9bfdd3bab5a383..d4a2a98721a9bfa2ee2cc092c66d3fe32ea21e52 100644 (file)
@@ -82,13 +82,22 @@ mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
 
   ret = (*the_target->wait) (ptid, ourstatus, options);
 
-  if (ourstatus->kind == TARGET_WAITKIND_EXITED)
-    fprintf (stderr,
-            "\nChild exited with status %d\n", ourstatus->value.integer);
-  else if (ourstatus->kind == TARGET_WAITKIND_SIGNALLED)
-    fprintf (stderr, "\nChild terminated with signal = 0x%x (%s)\n",
-            gdb_signal_to_host (ourstatus->value.sig),
-            gdb_signal_to_name (ourstatus->value.sig));
+  /* If GDB is connected through TCP/serial, then GDBserver will most
+     probably be running on its own terminal/console, so it's nice to
+     print there why is GDBserver exiting.  If however, GDB is
+     connected through stdio, then there's no need to spam the GDB
+     console with this -- the user will already see the exit through
+     regular GDB output, in that same terminal.  */
+  if (!remote_connection_is_stdio ())
+    {
+      if (ourstatus->kind == TARGET_WAITKIND_EXITED)
+       fprintf (stderr,
+                "\nChild exited with status %d\n", ourstatus->value.integer);
+      else if (ourstatus->kind == TARGET_WAITKIND_SIGNALLED)
+       fprintf (stderr, "\nChild terminated with signal = 0x%x (%s)\n",
+                gdb_signal_to_host (ourstatus->value.sig),
+                gdb_signal_to_name (ourstatus->value.sig));
+    }
 
   if (connected_wait)
     server_waiting = 0;
This page took 0.032958 seconds and 4 git commands to generate.