From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16533 invoked by alias); 2 Oct 2013 11:49:17 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 16517 invoked by uid 89); 2 Oct 2013 11:49:17 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Oct 2013 11:49:17 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r92BnErf011208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 2 Oct 2013 07:49:14 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r92BnCAn005576; Wed, 2 Oct 2013 07:49:13 -0400 Message-ID: <524C0838.2010400@redhat.com> Date: Wed, 02 Oct 2013 11:49:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Sergio Durigan Junior CC: gdb-patches@sourceware.org Subject: Re: [PATCH 2/2] [GDBserver]: Silence exits if GDB is connected through stdio. References: <1380309731-29881-1-git-send-email-palves@redhat.com> <1380309731-29881-3-git-send-email-palves@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-10/txt/msg00090.txt.bz2 On 09/27/2013 09:41 PM, Sergio Durigan Junior wrote: > FWIW, I agree with this patch. I hadn't tested catch syscall using > neither native{,-stdio}-gdbserver, so I didn't catch those errors. > Sorry about that. No worries. >> > >> > Comments? > Patch is fine by me, thanks! Great, I've applied this now, as below. ------- [GDBserver]: Silence exits if GDB is connected through stdio. 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 * 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/server.c | 5 ++++- gdb/gdbserver/target.c | 23 ++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 4de20d5..e0af785 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -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); } diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c index 1a0dee2..d4a2a98 100644 --- a/gdb/gdbserver/target.c +++ b/gdb/gdbserver/target.c @@ -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;